def check_payment_gateway(cls, client_args): access_token = client_args.get('access_token') account_id = client_args.get('account_id') payment_data = {} client = cls.get_configured_instance(access_token) account_api = AccountsApi(api_client=client) response = account_api.get_all_payment_gateway_accounts( account_id=account_id) if response.payment_gateway_accounts: payment_gateways = [ gateway for gateway in response.payment_gateway_accounts if gateway.is_enabled == 'true' ] if payment_gateways: payment_data = { 'payment_display_name': payment_gateways[0].display_name, 'payment_gateway': payment_gateways[0].payment_gateway, 'payment_gateway_account_id': payment_gateways[0].payment_gateway_account_id } cls.payment_gateway = payment_gateways[0] return payment_data
def worker(args): """ 1. Create an API client 2. Create a permission profile object 3. Get existing profile settings 4. Change the permission profile setting using the SDK """ # Step 2. Construct your API headers api_client = create_api_client(base_path=args["base_path"], access_token=args["access_token"]) # Step 3. Construct your request body permission_profile = PermissionProfile(settings=args["settings"]) account_api = AccountsApi(api_client) previous_settings = account_api.get_permission_profile( account_id=args["account_id"], permission_profile_id=args["permission_profile_id"] ).settings.to_dict() # Step 4. Call the eSignature REST API response = account_api.update_permission_profile( account_id=args["account_id"], permission_profile_id=args["permission_profile_id"], permission_profile=permission_profile) new_settings = response.settings.to_dict() changed_settings = {} # Save only changed settings for k, v in new_settings.items(): if v != previous_settings[k]: key = " ".join(k.split("_")) changed_settings[key] = v return response, changed_settings
def get_workflow(args): """Retrieve the workflow id""" try: api_client = create_api_client(base_path=args["base_path"], access_token=args["access_token"]) workflow_details = AccountsApi(api_client) workflow_response = workflow_details.get_account_identity_verification( account_id=args["account_id"]) # Check that idv authentication is enabled if workflow_response.identity_verification: workflow_id = workflow_response.identity_verification[ 0].workflow_id app.logger.info("We found the following workflowID: " + workflow_id) session['workflow_id'] = workflow_id return workflow_id else: return None except ApiException as err: return process_error(err)
def get_brands(args): """Retrieve all brands using the AccountBrands::List""" api_client = create_api_client(base_path=args["base_path"], access_token=args["access_token"]) try: account_api = AccountsApi(api_client) response = account_api.list_brands(account_id=args["account_id"]) return response.brands except ApiException as err: return process_error(err)
def get_permissions_profiles(args): """Retrieve all permissions profiles""" api_client = create_api_client(base_path=args["base_path"], access_token=args["access_token"]) try: account_api = AccountsApi(api_client) response = account_api.list_permissions(account_id=args["account_id"]) return response.permission_profiles except ApiException as err: return process_error(err)
def get_data(args): """Retrieve groups and permission profiles""" api_client = create_api_client(base_path=args["base_path"], access_token=args["access_token"]) try: account_api = AccountsApi(api_client) group_api = GroupsApi(api_client) permission_profiles = account_api.list_permissions(account_id=args["account_id"]).permission_profiles groups = group_api.list_groups(account_id=args["account_id"]).groups return permission_profiles, groups except ApiException as err: return process_error(err)
def testPutUpdateBrandResourceByContentType(self): try: from docusign_esign import AccountsApi acc_api = AccountsApi(self.api_client) acc_obj = acc_api.update_brand_resources_by_content_type( self.user_info.accounts[0].account_id, BrandId, "email", brandFile) assert acc_obj is not None assert acc_obj.resources_content_uri is not None except ApiException as e: print("\nException when calling DocuSign API: %s" % e) assert e is None # make the test case fail in case of an API exception
def worker(args): """ Step 1: Create an API client Step 2: Delete the permission profile using SDK """ # Step 2. Construct your API headers api_client = create_api_client(base_path=args["base_path"], access_token=args["access_token"]) account_api = AccountsApi(api_client) # Step 3. Call the eSignature REST API account_api.delete_permission_profile( account_id=args["account_id"], permission_profile_id=args["permission_profile_id"])
def get_data(args): """Retrieve brands and envelope templates""" api_client = create_api_client(base_path=args["base_path"], access_token=args["access_token"]) try: """Retrieve all brands using the AccountBrands::List""" account_api = AccountsApi(api_client) brands = account_api.list_brands(account_id=args["account_id"]).brands """Retrieve all templates using the Templates::List""" template_api = TemplatesApi(api_client) envelope_templates = template_api.list_templates(account_id=args["account_id"]).envelope_templates return brands, envelope_templates except ApiException as err: return process_error(err)
def worker(args): """ 1. Create an API client with headers 2. Create a brand object 3. Post the brand using SDK """ # Step 2. Construct your API headers api_client = create_api_client(base_path=args["base_path"], access_token=args["access_token"]) # Step 3. Construct your request body brand = Brand( brand_name=args["brand_name"], default_brand_language=args["default_language"], ) # Step 4. Call the eSignature REST API account_api = AccountsApi(api_client) response = account_api.create_brand(account_id=args["account_id"], brand=brand) return response
def worker(args): """ 1. Create an api client 2. Create a permission profile object 3. Create the permission profile using the SDK """ # Step 2. Construct your API request headers api_client = create_api_client(base_path=args["base_path"], access_token=args["access_token"]) # Step 3. Construct your request body permission_profile = PermissionProfile( permission_profile_name=args["permission_profile_name"], settings=args["settings"]) # Step 4. Call the eSignature REST API account_api = AccountsApi(api_client) response = account_api.create_permission_profile( account_id=args["account_id"], permission_profile=permission_profile) return response