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 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:
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)})