def sample32(request): clientId = request.POST.get('client_id') privateKey = request.POST.get('private_key') formGuid = request.POST.get('form_guid') templateGuid = request.POST.get('template_guid') callbackUrl = request.POST.get('callbackUrl') basePath = request.POST.get('server_type') email = request.POST.get('email') message = "" # Checking clientId, privateKey and file_Id if IsNotNull(clientId) == False or IsNotNull(privateKey) == False: return render_to_response('__main__:templates/sample32.pt', { 'error' : 'You do not enter all parameters' }) #Get curent work directory currentDir = os.path.dirname(os.path.realpath(__file__)) #Create text file fp = open(currentDir + '/../user_info.txt', 'w') #Write user info to text file fp.write(clientId + "\r\n" + privateKey + "\r\n" + email) fp.close() ####Create Signer, ApiClient and Storage Api objects #Create signer object signer = GroupDocsRequestSigner(privateKey) #Create apiClient object apiClient = ApiClient(signer) #Create Storage Api object signatureApi = SignatureApi(apiClient) #Set base Path if basePath == "": basePath = "https://api.groupdocs.com/v2.0" signatureApi.basePath = basePath #Create webHook and set callback URL webHook = WebhookInfo() webHook.callbackUrl = callbackUrl ####Make a request to Signature API using clientId if formGuid != "": try: #Post form by entered form GUID postForm = signatureApi.PublishSignatureForm(clientId, formGuid, body=webHook) if postForm.status == "Ok": message = '<font color="green">Form is published successfully</font>' #Generate iframe url if basePath == "https://api.groupdocs.com/v2.0": iframe = 'https://apps.groupdocs.com/signature2/forms/signembed/' + formGuid #iframe to dev server elif basePath == "https://dev-api.groupdocs.com/v2.0": iframe = 'https://dev-apps.groupdocs.com/signature2/forms/signembed/' + formGuid #iframe to test server elif basePath == "https://stage-apps-groupdocs.dynabic.com/v2.0": iframe = 'https://stage-apps-groupdocs.dynabic.com/signature2/forms/signembed/' + formGuid elif basePath == "http://realtime-api.groupdocs.com": iframe = 'https://relatime-apps.groupdocs.com/signature2/forms/signembed/' + formGuid iframe = signer.signUrl(iframe) else: raise Exception(postForm.error_message) except Exception, e: return render_to_response('__main__:templates/sample32.pt', { 'error' : str(e) })
def sample36(request): clientId = request.POST.get("clientId") privateKey = request.POST.get("privateKey") basePath = request.POST.get("basePath") envelopeGuid = request.POST.get("envelopeGuid") # Checking clientId, privateKey and envelopeGuid if not clientId or not privateKey or not envelopeGuid: return render_to_response("__main__:templates/sample36.pt", dict(error="You do not enter all parameters")) ####Create Signer, ApiClient and Storage Api objects # Create signer object signer = GroupDocsRequestSigner(privateKey) # Create apiClient object apiClient = ApiClient(signer) # Create Storage Api object signatureApi = SignatureApi(apiClient) if not basePath: # If base path empty set base path to the dev server basePath = "https://api.groupdocs.com/v2.0" signatureApi.basePath = basePath ####Make a request to Signature API using envelopeGuid try: ####Make a request to Storage Api for downloading file # Obtaining file stream of downloading file and definition of folder where to download file # Set path for local storage were to download file currentDir = os.path.dirname(os.path.realpath(__file__)) newPath = currentDir + "/../templates/downloads/" # Create folder for downloads if not exist if not os.path.exists(newPath): os.makedirs(newPath) # Get envelop info envelopInfo = signatureApi.GetSignatureEnvelopeDocuments(clientId, envelopeGuid) if envelopInfo.status == "Ok": # Get document name from envelop info documentName = envelopInfo.result.documents[0].name # Get file stream for signed document from envelop getSignedFile = signatureApi.GetSignedEnvelopeDocuments(clientId, envelopeGuid) if getSignedFile: # Write file stream to file filePath = newPath + documentName with open(filePath, "wb") as fp: shutil.copyfileobj(getSignedFile.inputStream, fp) # Result message with link to downloaded file for view in browser message = ( '<span style="color:green">Files from the envelope were downloaded to server\'s local folder. You can check them <a href="/downloads/' + documentName + '">here</a></span>' ) else: raise Exception("Wrong envelop GUID!") else: raise Exception(envelopInfo.error_message) except Exception, e: return render_to_response("__main__:templates/sample36.pt", {"error": str(e)})
def sample44(request): clientId = request.POST.get('clientId') privateKey = request.POST.get('privateKey') inputFile = request.POST.get('file') basePath = request.POST.get('basePath') firstName = request.POST.get('firstName') gender = request.POST.get('gender') lastName = request.POST.get('lastName') firstEmail = request.POST.get('firstEmail') secondEmail = request.POST.get('secondEmail') fileGuId = None # Checking clientId and privateKey if not clientId or not privateKey or not firstEmail or not firstName or not secondEmail: return render_to_response('__main__:templates/sample44.pt', dict(error='Please enter all required data', url1='')) ####Create Signer, ApiClient and Storage Api objects #Create signer object signer = GroupDocsRequestSigner(privateKey) #Create apiClient object apiClient = ApiClient(signer) #Create Storage Api object storage = StorageApi(apiClient) #Create AsyncApi object async = AsyncApi(apiClient) #Create MergeApi object merge = MergeApi(apiClient) #Create DocApi object doc = DocApi(apiClient) #Create Signature object signature = SignatureApi(apiClient) #Check is base path entered if not basePath: #If base path empty set base path to the dev server basePath = 'https://api.groupdocs.com/v2.0' #Set base path for api storage.basePath = basePath async.basePath = basePath merge.basePath = basePath doc.basePath = basePath signature.basePath = basePath #A hack to get uploaded file size inputFile.file.seek(0, 2) fileSize = inputFile.file.tell() inputFile.file.seek(0) fs = FileStream.fromStream(inputFile.file, fileSize) ####Make a request to Storage API using clientId try: #Upload file to current user storage upload = storage.Upload(clientId, inputFile.filename, fs, overrideMode=0) if upload.status == "Ok": #Get file guid fileGuId = upload.result.guid except Exception, e: return render_to_response('__main__:templates/sample44.pt', dict(error=str(e), url1=''))
# Create signer object signer = GroupDocsRequestSigner(privateKey) # Create apiClient object apiClient = ApiClient(signer) # Create StorageApi object storage = StorageApi(apiClient) # Create SignatureApi object signature = SignatureApi(apiClient) docApi = DocApi(apiClient) mergeApi = MergeApi(apiClient) asyncApi = AsyncApi(apiClient) if basePath == "": basePath = 'https://api.groupdocs.com/v2.0' #Set base path storage.basePath = basePath signature.basePath = basePath docApi.basePath = basePath mergeApi.basePath = basePath asyncApi.basePath = basePath guid = fileId #Create list with entered data enteredData = { "email": email, "country": country, "name": name, "street": street, "city": city } #Create new Datasource object dataSource = Datasource array = []
def sample40(request): clientId = request.POST.get('clientId') privateKey = request.POST.get('privateKey') formGuid = request.POST.get('formGuid') callbackUrl = request.POST.get('callbackUrl') basePath = request.POST.get('basePath') # Checking clientId, privateKey and form GUID if not clientId or not privateKey or not formGuid: return render_to_response('__main__:templates/sample40.pt', dict(error='You do not enter all parameters')) #Get current work directory currentDir = os.path.dirname(os.path.realpath(__file__)) #Create temporary text file fp = open(currentDir + '/../user_info.txt', 'w') #Write user info to text file fp.write(clientId + "\r\n" + privateKey) fp.close() #Check is temporary file with callback info is exist if os.path.exists(currentDir + '/../callback_info.txt'): #If exist delete it os.remove(currentDir + '/../callback_info.txt') ####Create Signer, ApiClient and Storage Api objects #Create signer object signer = GroupDocsRequestSigner(privateKey) #Create apiClient object apiClient = ApiClient(signer) #Create Storage Api object signatureApi = SignatureApi(apiClient) #Set base Path if not basePath: basePath = "https://api.groupdocs.com/v2.0" signatureApi.basePath = basePath #Create webHook and set callback URL webHook = WebhookInfo() webHook.callbackUrl = callbackUrl ####Make a request to Signature API using clientId #create random number rand = random.randint(0, 500) #Create string variable with new form name formName = 'test' + str(rand) try: #Copy form createForm = signatureApi.CreateSignatureForm(clientId, name=formName, formGuid=formGuid) if createForm.status == "Ok": try: #Publish created form postForm = signatureApi.PublishSignatureForm(clientId, createForm.result.form.id, body=webHook) if postForm.status == "Ok": message = '<font color="green">Form is published successfully</font>' iframe = None #Generate iframe url if basePath == "https://api.groupdocs.com/v2.0": iframe = 'https://apps.groupdocs.com/signature2/forms/signembed/' + \ createForm.result.form.id #iframe to dev server elif basePath == "https://dev-api-groupdocs.dynabic.com/v2.0": iframe = 'https://dev-apps-groupdocs.dynabic.com/signature2/forms/signembed/' + \ createForm.result.form.id #iframe to test server elif basePath == "https://stage-apps-groupdocs.dynabic.com/v2.0": iframe = 'https://stage-apps-groupdocs.dynabic.com/signature2/forms/signembed/' + \ createForm.result.form.id elif basePath == "http://realtime-api-groupdocs.dynabic.com": iframe = 'https://relatime-apps-groupdocs.dynabic.com/signature2/forms/signembed/' + \ createForm.result.form.id iframe = signer.signUrl(iframe) else: raise Exception(postForm.error_message) except Exception, e: return render_to_response('__main__:templates/sample40.pt', dict(error=str(e))) else:
print e ### Create Signer, ApiClient and Annotation Api objects # Create signer object signer = GroupDocsRequestSigner(privateKey) # Create apiClient object apiClient = ApiClient(signer) # Create StorageApi object storage = StorageApi(apiClient) # Create SignatureApi object signature = SignatureApi(apiClient) if not basePath: basePath = 'https://api.groupdocs.com/v2.0' #Set base path storage.basePath = basePath signature.basePath = basePath if url: try: # Upload file to current user storage using entered URl to the file upload = storage.UploadWeb(clientId, url) guid = upload.result.guid try: ####Make a request to Storage API using clientId #Obtaining all Entities from current user files = storage.ListEntities(userId=clientId, path='My Web Documents', pageIndex=0) #Obtaining file name for item in files.result.files: #selecting file names if item.guid == guid: fileName = item.name
def sample32(request): clientId = request.POST.get('client_id') privateKey = request.POST.get('private_key') formGuid = request.POST.get('form_guid') templateGuid = request.POST.get('template_guid') callbackUrl = request.POST.get('callbackUrl') basePath = request.POST.get('server_type') email = request.POST.get('email') message = "" # Checking clientId, privateKey and file_Id if IsNotNull(clientId) == False or IsNotNull(privateKey) == False: return render_to_response('__main__:templates/sample32.pt', {'error': 'You do not enter all parameters'}) #Get curent work directory currentDir = os.path.dirname(os.path.realpath(__file__)) #Create text file fp = open(currentDir + '/../user_info.txt', 'w') #Write user info to text file fp.write(clientId + "\r\n" + privateKey + "\r\n" + email) fp.close() ####Create Signer, ApiClient and Storage Api objects #Create signer object signer = GroupDocsRequestSigner(privateKey) #Create apiClient object apiClient = ApiClient(signer) #Create Storage Api object signatureApi = SignatureApi(apiClient) #Set base Path if basePath == "": basePath = "https://api.groupdocs.com/v2.0" signatureApi.basePath = basePath #Create webHook and set callback URL webHook = WebhookInfo() webHook.callbackUrl = callbackUrl ####Make a request to Signature API using clientId if formGuid != "": try: #Post form by entered form GUID postForm = signatureApi.PublishSignatureForm(clientId, formGuid, body=webHook) if postForm.status == "Ok": message = '<font color="green">Form is published successfully</font>' #Generate iframe url if basePath == "https://api.groupdocs.com/v2.0": iframe = 'https://apps.groupdocs.com/signature2/forms/signembed/' + formGuid #iframe to dev server elif basePath == "https://dev-api.groupdocs.com/v2.0": iframe = 'https://dev-apps.groupdocs.com/signature2/forms/signembed/' + formGuid #iframe to test server elif basePath == "https://stage-apps-groupdocs.dynabic.com/v2.0": iframe = 'https://stage-apps-groupdocs.dynabic.com/signature2/forms/signembed/' + formGuid elif basePath == "http://realtime-api.groupdocs.com": iframe = 'https://relatime-apps.groupdocs.com/signature2/forms/signembed/' + formGuid iframe = signer.signUrl(iframe) else: raise Exception(postForm.error_message) except Exception, e: return render_to_response('__main__:templates/sample32.pt', {'error': str(e)})