### Python SDK: Get SKU Source: https://github.com/voucherifyio/voucherify-python-sdk/blob/master/docs/ProductsApi.md Example demonstrating how to fetch SKU details using the Voucherify Python SDK. It covers API client configuration, authentication setup, and the execution of the `get_sku` method. ```python import voucherify from voucherify.models.skus_get_response_body import SkusGetResponseBody from voucherify.rest import ApiException from pprint import pprint import os configuration = voucherify.Configuration( host = "https://api.voucherify.io" ) configuration.api_key['X-App-Id'] = os.environ["API_KEY"] configuration.api_key['X-App-Token'] = os.environ["API_KEY"] with voucherify.ApiClient(configuration) as api_client: api_instance = voucherify.ProductsApi(api_client) sku_id = 'sku_id_example' try: api_response = api_instance.get_sku(sku_id) print("The response of ProductsApi->get_sku:\n") pprint(api_response) except Exception as e: print("Exception when calling ProductsApi->get_sku: %s\n" % e) ``` -------------------------------- ### Loyalties API - Transfer Points Example Setup Source: https://github.com/voucherifyio/voucherify-python-sdk/blob/master/docs/LoyaltiesApi.md Provides an example setup for using the `transfer_points` method in the Loyalties API, including API key configuration for authentication. ```Python import voucherify from voucherify.models.loyalties_members_transfers_create_response_body import LoyaltiesMembersTransfersCreateResponseBody from voucherify.models.loyalties_transfer_points import LoyaltiesTransferPoints from voucherify.rest import ApiException from pprint import pprint import os # Defining the host is optional and defaults to https://api.voucherify.io # See configuration.py for a list of all supported configuration parameters. configuration = voucherify.Configuration( host = "https://api.voucherify.io" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure API key authorization: X-App-Id configuration.api_key['X-App-Id'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['X-App-Id'] = 'Bearer' # Configure API key authorization: X-App-Token configuration.api_key['X-App-Token'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['X-App-Token'] = 'Bearer' ``` -------------------------------- ### Python SDK: Get Product Source: https://github.com/voucherifyio/voucherify-python-sdk/blob/master/docs/ProductsApi.md Example of how to use the Voucherify Python SDK to retrieve product details. It demonstrates setting up the API client, authentication, and making the `get_product` call. ```python import voucherify from voucherify.models.products_get_response_body import ProductsGetResponseBody from voucherify.rest import ApiException from pprint import pprint import os configuration = voucherify.Configuration( host = "https://api.voucherify.io" ) configuration.api_key['X-App-Id'] = os.environ["API_KEY"] configuration.api_key['X-App-Token'] = os.environ["API_KEY"] with voucherify.ApiClient(configuration) as api_client: api_instance = voucherify.ProductsApi(api_client) product_id = 'product_id_example' try: api_response = api_instance.get_product(product_id) print("The response of ProductsApi->get_product:\n") pprint(api_response) except Exception as e: print("Exception when calling ProductsApi->get_product: %s\n" % e) ``` -------------------------------- ### Voucherify Python SDK - List Customer Activity Example Source: https://github.com/voucherifyio/voucherify-python-sdk/blob/master/docs/CustomersApi.md Example demonstrating how to use the Voucherify Python SDK to list customer activities. It shows authentication setup, API client instantiation, and calling the `list_customer_activity` method with various parameters. ```Python import voucherify from voucherify.models.customers_activity_list_response_body import CustomersActivityListResponseBody from voucherify.models.parameter_activity_category import ParameterActivityCategory from voucherify.models.parameter_campaign_type import ParameterCampaignType from voucherify.models.parameter_order_created_at import ParameterOrderCreatedAt from voucherify.rest import ApiException from pprint import pprint import os # Defining the host is optional and defaults to https://api.voucherify.io configuration = voucherify.Configuration( host = "https://api.voucherify.io" ) # Configure API key authorization: X-App-Id configuration.api_key['X-App-Id'] = os.environ.get("API_KEY") # Configure API key authorization: X-App-Token configuration.api_key['X-App-Token'] = os.environ.get("API_KEY") with voucherify.ApiClient(configuration) as api_client: api_instance = voucherify.CustomersApi(api_client) customer_id = 'customer_id_example' limit = 56 order = voucherify.ParameterOrderCreatedAt() starting_after_id = 'starting_after_id_example' start_date = '2013-10-20T19:20:30+01:00' end_date = '2013-10-20T19:20:30+01:00' campaign_id = 'campaign_id_example' campaign_type = voucherify.ParameterCampaignType() category = voucherify.ParameterActivityCategory() type = 'type_example' try: api_response = api_instance.list_customer_activity(customer_id, limit=limit, order=order, starting_after_id=starting_after_id, start_date=start_date, end_date=end_date, campaign_id=campaign_id, campaign_type=campaign_type, category=category, type=type) print("The response of CustomersApi->list_customer_activity:\n") pprint(api_response) except Exception as e: print("Exception when calling CustomersApi->list_customer_activity: %s\n" % e) ``` -------------------------------- ### Voucherify Python SDK - Get Loyalty Campaign Example Source: https://github.com/voucherifyio/voucherify-python-sdk/blob/master/docs/LoyaltiesApi.md Example of how to use the Voucherify Python SDK to retrieve a loyalty campaign. It demonstrates setting up the client, authentication, and making the API call. ```python import voucherify from voucherify.models.loyalties_get_campaign_response_body import LoyaltiesGetCampaignResponseBody from voucherify.rest import ApiException from pprint import pprint import os configuration = voucherify.Configuration( host = "https://api.voucherify.io" ) configuration.api_key['X-App-Id'] = os.environ["API_KEY"] configuration.api_key['X-App-Token'] = os.environ["API_KEY"] with voucherify.ApiClient(configuration) as api_client: api_instance = voucherify.LoyaltiesApi(api_client) campaign_id = 'campaign_id_example' try: api_response = api_instance.get_loyalty_program(campaign_id) print("The response of LoyaltiesApi->get_loyalty_program:\n") pprint(api_response) except Exception as e: print("Exception when calling LoyaltiesApi->get_loyalty_program: %s\n" % e) ``` -------------------------------- ### Python SDK Example: List Promotion Stacks Source: https://github.com/voucherifyio/voucherify-python-sdk/blob/master/docs/PromotionsApi.md Example demonstrating how to use the Voucherify Python SDK to list promotion stacks within a campaign, including API key authentication. ```python import voucherify import os from voucherify.models.promotions_stacks_list_response_body import PromotionsStacksListResponseBody from voucherify.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to https://api.voucherify.io configuration = voucherify.Configuration( host = "https://api.voucherify.io" ) # Configure API key authorization: X-App-Id configuration.api_key['X-App-Id'] = os.environ["API_KEY"] # Configure API key authorization: X-App-Token configuration.api_key['X-App-Token'] = os.environ["API_KEY"] # Enter a context with an instance of the API client with voucherify.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = voucherify.PromotionsApi(api_client) campaign_id = 'campaign_id_example' # str | Unique campaign ID. try: # List Promotion Stacks in Campaign api_response = api_instance.list_promotion_stacks_in_campaign(campaign_id) print("The response of PromotionsApi->list_promotion_stacks_in_campaign:\n") pprint(api_response) except Exception as e: print("Exception when calling PromotionsApi->list_promotion_stacks_in_campaign: %s\n" % e) ``` -------------------------------- ### Execute Get Promotion Stack API Call Source: https://github.com/voucherifyio/voucherify-python-sdk/blob/master/docs/PromotionsApi.md Shows how to instantiate the Voucherify PromotionsApi client and call the `get_promotion_stack` method with example IDs. Includes error handling for the API call. ```python import voucherify from voucherify.rest import ApiException from pprint import pprint # ... (configuration and authentication code from above) ... # Enter a context with an instance of the API client with voucherify.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = voucherify.PromotionsApi(api_client) campaign_id = 'campaign_id_example' # str | ID of the promotion campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty Campaign. stack_id = 'stack_id_example' # str | Promotion stack ID. try: # Get Promotion Stack api_response = api_instance.get_promotion_stack(campaign_id, stack_id) print("The response of PromotionsApi->get_promotion_stack:\n") pprint(api_response) except Exception as e: print("Exception when calling PromotionsApi->get_promotion_stack: %s\n" % e) ``` -------------------------------- ### Python SDK Example: List Customer Redeemables Source: https://github.com/voucherifyio/voucherify-python-sdk/blob/master/docs/CustomersApi.md Example of how to use the Voucherify Python SDK to list customer redeemables. Demonstrates API key authentication and basic usage. ```python import voucherify import os from voucherify.models.customers_redeemables_list_response_body import CustomersRedeemablesListResponseBody from voucherify.models.parameter_filters_list_customer_redeemables import ParameterFiltersListCustomerRedeemables from voucherify.models.parameter_order_list_redeemables import ParameterOrderListRedeemables from voucherify.rest import ApiException from pprint import pprint configuration = voucherify.Configuration( host = "https://api.voucherify.io" ) configuration.api_key['X-App-Id'] = os.environ["API_KEY"] configuration.api_key['X-App-Token'] = os.environ["API_KEY"] api_client = voucherify.ApiClient(configuration) customers_api = voucherify.CustomersApi(api_client) try: response = customers_api.list_customer_redeemables(customer_id='cust_123') pprint(response) except ApiException as e: print(f"Exception when calling CustomersApi->list_customer_redeemables: {e}") ``` -------------------------------- ### Install Voucherify Python SDK Source: https://github.com/voucherifyio/voucherify-python-sdk/blob/master/README.md Installs the Voucherify API client library using pip. This is the first step to integrate Voucherify functionalities into your Python application. ```sh pip install 'Voucherify' ``` -------------------------------- ### Python SDK Authentication and Import Example Source: https://github.com/voucherifyio/voucherify-python-sdk/blob/master/docs/VouchersApi.md Demonstrates how to configure the Voucherify Python SDK, set up API key authentication for both 'X-App-Id' and 'X-App-Token', and make a call to the `import_vouchers_using_csv` function. It includes necessary imports and error handling setup. ```Python import voucherify from voucherify.models.vouchers_import_csv_create_response_body import VouchersImportCsvCreateResponseBody from voucherify.rest import ApiException from pprint import pprint import os # Defining the host is optional and defaults to https://api.voucherify.io # See configuration.py for a list of all supported configuration parameters. configuration = voucherify.Configuration( host = "https://api.voucherify.io" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure API key authorization: X-App-Id configuration.api_key['X-App-Id'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['X-App-Id'] = 'Bearer' # Configure API key authorization: X-App-Token configuration.api_key['X-App-Token'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['X-App-Token'] = 'Bearer' # Example usage: # api = voucherify.api.vouchers_api.VouchersApi(voucherify.ApiClient(configuration)) # file_path = 'path/to/your/vouchers.csv' # try: # with open(file_path, 'rb') as f: # response = api.import_vouchers_using_csv(file=f) # pprint(response) # except ApiException as e: # print(f"Exception when calling Voucherify API: {e}") ``` -------------------------------- ### Python SDK Example: Import SKUs using CSV Source: https://github.com/voucherifyio/voucherify-python-sdk/blob/master/docs/ProductsApi.md Example of how to use the Voucherify Python SDK to import SKUs via CSV. Demonstrates API client configuration, authentication (API Key), and making the import request. ```Python import voucherify from voucherify.models.skus_import_csv_create_response_body import SkusImportCsvCreateResponseBody from voucherify.rest import ApiException from pprint import pprint import os # Defining the host is optional and defaults to https://api.voucherify.io configuration = voucherify.Configuration( host = "https://api.voucherify.io" ) # Configure API key authorization: X-App-Id configuration.api_key['X-App-Id'] = os.environ.get("API_KEY") # Configure API key authorization: X-App-Token configuration.api_key['X-App-Token'] = os.environ.get("API_KEY") # Enter a context with an instance of the API client with voucherify.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = voucherify.ProductsApi(api_client) file = None # bytearray | File path. (optional) try: # Import SKUs using CSV api_response = api_instance.import_skus_using_csv(file=file) print("The response of ProductsApi->import_skus_using_csv:\n") pprint(api_response) except Exception as e: print("Exception when calling ProductsApi->import_skus_using_csv: %s\n" % e) ``` -------------------------------- ### Python SDK Example: Copy Campaign Template Source: https://github.com/voucherifyio/voucherify-python-sdk/blob/master/docs/ManagementApi.md Example of using the Voucherify Python SDK to copy a campaign template to a new project. This includes setting up the API client with authentication and making the API call. ```Python import voucherify from voucherify.models.management_projects_templates_campaigns_copy_create_request_body import ManagementProjectsTemplatesCampaignsCopyCreateRequestBody from voucherify.models.management_projects_templates_campaigns_copy_create_response_body import ManagementProjectsTemplatesCampaignsCopyCreateResponseBody from voucherify.rest import ApiException from pprint import pprint import os # Defining the host is optional and defaults to https://api.voucherify.io configuration = voucherify.Configuration( host = "https://api.voucherify.io" ) # Configure API key authorization: X-Management-Token configuration.api_key['X-Management-Token'] = os.environ["API_KEY"] # Configure API key authorization: X-Management-Id configuration.api_key['X-Management-Id'] = os.environ["API_KEY"] with voucherify.ApiClient(configuration) as api_client: api_instance = voucherify.ManagementApi(api_client) project_id = 'project_id_example' campaign_template_id = 'campaign_template_id_example' management_projects_templates_campaigns_copy_create_request_body = voucherify.ManagementProjectsTemplatesCampaignsCopyCreateRequestBody() try: api_response = api_instance.management_copy_campaign_template(project_id, campaign_template_id, management_projects_templates_campaigns_copy_create_request_body=management_projects_templates_campaigns_copy_create_request_body) print("The response of ManagementApi->management_copy_campaign_template:\n") pprint(api_response) except Exception as e: print("Exception when calling ManagementApi->management_copy_campaign_template: %s\n" % e) ``` -------------------------------- ### Python SDK Example: List Referral Code Holders Source: https://github.com/voucherifyio/voucherify-python-sdk/blob/master/docs/ReferralsApi.md Example demonstrating how to use the Voucherify Python SDK to list referral code holders. It shows how to configure the client, authenticate, and make the API call. ```Python import voucherify from voucherify.models.parameter_filters_list_referrals_redeemable_holders import ParameterFiltersListReferralsRedeemableHolders from voucherify.models.parameter_order_list_redeemables import ParameterOrderListRedeemables from voucherify.models.referrals_members_holders_list_response_body import ReferralsMembersHoldersListResponseBody from voucherify.rest import ApiException from pprint import pprint import os # Defining the host is optional and defaults to https://api.voucherify.io # See configuration.py for a list of all supported configuration parameters. configuration = voucherify.Configuration( host = "https://api.voucherify.io" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure API key authorization: X-App-Id configuration.api_key['X-App-Id'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['X-App-Id'] = 'Bearer' # Configure API key authorization: X-App-Token configuration.api_key['X-App-Token'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['X-App-Token'] = 'Bearer' # Enter a context with an instance of the API client with voucherify.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = voucherify.ReferralsApi(api_client) campaign_id = 'campaign_id_example' # str | Unique identifier of a referral program campaign. member_id = 'member_id_example' # str | Unique referral code or its identifier. limit = 56 # int | Limits the number of objects to be returned. The limit can range between 1 and 100 items. If no limit is set, it returns 10 items. (optional) order = voucherify.ParameterOrderListRedeemables() # ParameterOrderListRedeemables | Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. (optional) starting_after_id = 'starting_after_id_example' # str | A cursor for pagination. It retrieves the events starting after an event with the given ID. (optional) filters = voucherify.ParameterFiltersListReferralsRedeemableHolders() # ParameterFiltersListReferralsRedeemableHolders | Filters for listing customer redeemables. (optional) try: # List Referral Code Holders api_response = api_instance.referrals_code_holders(campaign_id, member_id, limit=limit, order=order, starting_after_id=starting_after_id, filters=filters) print("The response of ReferralsApi->referrals_code_holders:\n") pprint(api_response) except Exception as e: print("Exception when calling ReferralsApi->referrals_code_holders: %s\n" % e) ``` -------------------------------- ### Initialize Voucherify Client and List Customers Source: https://github.com/voucherifyio/voucherify-python-sdk/blob/master/README.md Demonstrates how to initialize the Voucherify Python SDK client with API keys loaded from environment variables. It then shows how to call the `list_customers` method and print the results. Error handling for API exceptions is included. ```python import os import voucherify from dotenv import load_dotenv load_dotenv() HOST = os.getenv('VOUCHERIFY_HOST', 'https://api.voucherify.io') X_APP_ID = os.getenv('X_APP_ID') X_APP_TOKEN = os.getenv('X_APP_TOKEN') if not X_APP_ID or not X_APP_TOKEN: raise ValueError("X_APP_ID and X_APP_TOKEN must be set in the .env file.") configuration = voucherify.Configuration( host=HOST, api_key={ "X-App-Id": X_APP_ID, "X-App-Token": X_APP_TOKEN } ) # Debugging line api_key_id = configuration.get_api_key_with_prefix('X-App-Id') api_key_token = configuration.get_api_key_with_prefix('X-App-Token') # Print whether both API keys are present and valid are_keys_present = bool(api_key_id) and bool(api_key_token) print(f"Configuration loaded: {are_keys_present}") if(are_keys_present): with voucherify.ApiClient(configuration) as api_client: customers_api_instance = voucherify.CustomersApi(api_client) try: result = customers_api_instance.list_customers() print(result) except voucherifyClient.ApiException as e: self.fail(e) ``` -------------------------------- ### Get Customer - Python Source: https://github.com/voucherifyio/voucherify-python-sdk/blob/master/docs/CustomersApi.md Provides an example of how to retrieve customer details using the Voucherify Python SDK. It covers API key configuration, client setup, and calling the get_customer method, with output printing and error handling. ```Python import voucherify from voucherify.models.customers_get_response_body import CustomersGetResponseBody from voucherify.rest import ApiException from pprint import pprint import os # Defining the host is optional and defaults to https://api.voucherify.io configuration = voucherify.Configuration( host = "https://api.voucherify.io" ) # Configure API key authorization: X-App-Id configuration.api_key['X-App-Id'] = os.environ["API_KEY"] # Configure API key authorization: X-App-Token configuration.api_key['X-App-Token'] = os.environ["API_KEY"] # Enter a context with an instance of the API client with voucherify.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = voucherify.CustomersApi(api_client) customer_id = 'customer_id_example' # str | A Voucherify customers id or source_id. try: # Get Customer api_response = api_instance.get_customer(customer_id) print("The response of CustomersApi->get_customer:\n") pprint(api_response) except Exception as e: print("Exception when calling CustomersApi->get_customer: %s\n" % e) ``` -------------------------------- ### Run Local Tests with Docker Source: https://github.com/voucherifyio/voucherify-python-sdk/blob/master/README.md Provides instructions for setting up and running local tests for the Voucherify Python SDK using Docker. This involves copying an example environment file, building a Docker image, and running the container. ```sh # 1. Copy .env.example to .env and fill in the values. # 2. Run `docker build -t python .` to build the image. # 3. Run `docker run --rm python` to run the tests and delete container immediately after. ``` -------------------------------- ### Create Project Source: https://github.com/voucherifyio/voucherify-python-sdk/blob/master/docs/ManagementApi.md Shows how to create a new project using the Voucherify Python SDK. This includes setting up the API client, authentication, and making the call to the create_project endpoint. ```Python import voucherify from voucherify.models.management_projects_create_request_body import ManagementProjectsCreateRequestBody from voucherify.models.management_projects_create_response_body import ManagementProjectsCreateResponseBody from voucherify.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to https://api.voucherify.io # See configuration.py for a list of all supported configuration parameters. configuration = voucherify.Configuration( host = "https://api.voucherify.io" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure API key authorization: X-Management-Token configuration.api_key['X-Management-Token'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['X-Management-Token'] = 'Bearer' # Configure API key authorization: X-Management-Id configuration.api_key['X-Management-Id'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['X-Management-Id'] = 'Bearer' ``` -------------------------------- ### Voucherify Python SDK Authorization Setup Source: https://github.com/voucherifyio/voucherify-python-sdk/blob/master/README.md This snippet demonstrates how to initialize the Voucherify Python SDK by loading API keys (X-App-Id, X-App-Token) from environment variables using dotenv. It includes error handling for missing keys and prints the configuration status. ```python import os import voucherify from dotenv import load_dotenv load_dotenv() HOST = os.getenv('VOUCHERIFY_HOST', 'https://api.voucherify.io') X_APP_ID = os.getenv('X_APP_ID') X_APP_TOKEN = os.getenv('X_APP_TOKEN') if not X_APP_ID or not X_APP_TOKEN: raise ValueError("X_APP_ID and X_APP_TOKEN must be set in the .env file.") configuration = voucherify.Configuration( host=HOST, api_key={ "X-App-Id": X_APP_ID, "X-App-Token": X_APP_TOKEN } ) # Debugging line api_key_id = configuration.get_api_key_with_prefix('X-App-Id') api_key_token = configuration.get_api_key_with_prefix('X-App-Token') # Print whether both API keys are present and valid are_keys_present = bool(api_key_id) and bool(api_key_token) print(f"Configuration loaded: {are_keys_present}") ``` ```python import voucherify with voucherify.ApiClient(configuration) as api_client: ``` -------------------------------- ### Get Earning Rule - Python Example Source: https://github.com/voucherifyio/voucherify-python-sdk/blob/master/docs/LoyaltiesApi.md Example of how to retrieve an earning rule using the Voucherify Python SDK. It demonstrates setting up the API client, authenticating, and calling the `get_earning_rule` method with necessary IDs. ```Python import voucherify from voucherify.models.loyalties_earning_rules_get_response_body import LoyaltiesEarningRulesGetResponseBody from voucherify.rest import ApiException from pprint import pprint import os # Defining the host is optional and defaults to https://api.voucherify.io # See configuration.py for a list of all supported configuration parameters. configuration = voucherify.Configuration( host = "https://api.voucherify.io" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure API key authorization: X-App-Id configuration.api_key['X-App-Id'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['X-App-Id'] = 'Bearer' # Configure API key authorization: X-App-Token configuration.api_key['X-App-Token'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['X-App-Token'] = 'Bearer' # Enter a context with an instance of the API client with voucherify.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = voucherify.LoyaltiesApi(api_client) campaign_id = 'campaign_id_example' # str | The campaign ID or name of the loyalty campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty%20Campaign. earning_rule_id = 'earning_rule_id_example' # str | A unique earning rule ID. try: # Get Earning Rule api_response = api_instance.get_earning_rule(campaign_id, earning_rule_id) print("The response of LoyaltiesApi->get_earning_rule:\n") pprint(api_response) except Exception as e: print("Exception when calling LoyaltiesApi->get_earning_rule: %s\n" % e) ``` -------------------------------- ### List Categories Source: https://github.com/voucherifyio/voucherify-python-sdk/blob/master/docs/CategoriesApi.md Lists all available categories. This API endpoint requires authentication and returns a list of category objects. The example shows basic setup for API key authentication. ```python import voucherify import os from voucherify.models.categories_list_response_body import CategoriesListResponseBody from pprint import pprint # Defining the host is optional and defaults to https://api.voucherify.io configuration = voucherify.Configuration( host = "https://api.voucherify.io" ) # Configure API key authorization: X-App-Id configuration.api_key['X-App-Id'] = os.environ["API_KEY"] # Configure API key authorization: X-App-Token configuration.api_key['X-App-Token'] = os.environ["API_KEY"] # Enter a context with an instance of the API client with voucherify.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = voucherify.CategoriesApi(api_client) try: # List Categories api_response = api_instance.list_categories() print("The response of CategoriesApi->list_categories:\n") pprint(api_response) except Exception as e: print("Exception when calling CategoriesApi->list_categories: %s\n" % e) ``` -------------------------------- ### Get Voucherify Location Source: https://github.com/voucherifyio/voucherify-python-sdk/blob/master/docs/LocationsApi.md Python code example for retrieving a specific location from Voucherify using the Python SDK. It demonstrates how to configure the API client, authenticate, and call the get_location method. ```Python import voucherify from voucherify.models.locations_get_response_body import LocationsGetResponseBody from voucherify.rest import ApiException from pprint import pprint import os configuration = voucherify.Configuration( host = "https://api.voucherify.io" ) configuration.api_key['X-App-Id'] = os.environ["API_KEY"] configuration.api_key['X-App-Token'] = os.environ["API_KEY"] with voucherify.ApiClient(configuration) as api_client: api_instance = voucherify.LocationsApi(api_client) location_id = 'location_id_example' try: api_response = api_instance.get_location(location_id) print("The response of LocationsApi->get_location:\n") pprint(api_response) except Exception as e: print("Exception when calling LocationsApi->get_location: %s\n" % e) ``` -------------------------------- ### Voucherify Python SDK Initialization and Usage Source: https://github.com/voucherifyio/voucherify-python-sdk/blob/master/docs/VouchersApi.md Demonstrates how to initialize the Voucherify Python SDK client with API keys and make a request to list vouchers. Includes setup for authentication and handling potential API exceptions. ```python import voucherify from voucherify.models.parameter_created_before_after import ParameterCreatedBeforeAfter from voucherify.models.parameter_order_vouchers import ParameterOrderVouchers from voucherify.models.parameter_updated_before_after import ParameterUpdatedBeforeAfter from voucherify.models.vouchers_list_response_body import VouchersListResponseBody from voucherify.rest import ApiException from pprint import pprint import os # Defining the host is optional and defaults to https://api.voucherify.io # See configuration.py for a list of all supported configuration parameters. configuration = voucherify.Configuration( host = "https://api.voucherify.io" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure API key authorization: X-App-Id configuration.api_key['X-App-Id'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['X-App-Id'] = 'Bearer' # Configure API key authorization: X-App-Token configuration.api_key['X-App-Token'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['X-App-Token'] = 'Bearer' # Example usage: # try: # # Create an instance of the API class # api_instance = voucherify.VouchersApi(voucherify.ApiClient(configuration)) # opts = { # 'limit': 10, # 'order': 'created_at' # } # api_response = api_instance.list_vouchers(**opts) # pprint(api_response) # except ApiException as e: # print("Exception when calling VouchersApi->list_vouchers: %s\n" % e) ``` -------------------------------- ### Get Brand Configuration Source: https://github.com/voucherifyio/voucherify-python-sdk/blob/master/docs/ManagementApi.md Retrieves a specific brand configuration within a project. Requires project ID and branding ID. Includes example Python code for authentication and making the API request. ```Python import voucherify from voucherify.models.management_projects_branding_get_response_body import ManagementProjectsBrandingGetResponseBody from voucherify.rest import ApiException from pprint import pprint configuration = voucherify.Configuration( host = "https://api.voucherify.io" ) configuration.api_key['X-Management-Token'] = os.environ["API_KEY"] configuration.api_key['X-Management-Id'] = os.environ["API_KEY"] with voucherify.ApiClient(configuration) as api_client: api_instance = voucherify.ManagementApi(api_client) project_id = 'project_id_example' branding_id = 'branding_id_example' try: api_response = api_instance.get_brand(project_id, branding_id) print("The response of ManagementApi->get_brand:\n") pprint(api_response) except Exception as e: print("Exception when calling ManagementApi->get_brand: %s\n" % e) ``` -------------------------------- ### Get Member API Source: https://github.com/voucherifyio/voucherify-python-sdk/blob/master/docs/LoyaltiesApi.md Demonstrates how to retrieve loyalty card details for a given member ID using the Voucherify Python SDK. It covers API client setup, method calls, and exception handling. ```APIDOC LoyaltiesApi->get_member(member_id) Get Member Retrieve loyalty card with the given member ID (i.e. voucher code). 📘 Alternative endpoint This endpoint is an alternative to this endpoint. The URL was re-designed to allow you to retrieve loyalty card details without having to provide the campaignId as a path parameter. Parameters: member_id (str): Unique loyalty card code assigned to a particular customer. Return type: LoyaltiesMembersGetResponseBody: Returns loyalty card details. Authorization: [X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) HTTP request headers: - Content-Type: Not defined - Accept: application/json ``` ```Python import voucherify from voucherify.models.loyalties_members_get_response_body import LoyaltiesMembersGetResponseBody from voucherify.rest import ApiException from pprint import pprint import os configuration = voucherify.Configuration( host = "https://api.voucherify.io" ) configuration.api_key['X-App-Id'] = os.environ["API_KEY"] configuration.api_key['X-App-Token'] = os.environ["API_KEY"] with voucherify.ApiClient(configuration) as api_client: api_instance = voucherify.LoyaltiesApi(api_client) member_id = 'member_id_example' try: api_response = api_instance.get_member(member_id) print("The response of LoyaltiesApi->get_member:\n") pprint(api_response) except Exception as e: print("Exception when calling LoyaltiesApi->get_member: %s\n" % e) ``` -------------------------------- ### Python SDK: Delete Custom Event Schema Example Source: https://github.com/voucherifyio/voucherify-python-sdk/blob/master/docs/ManagementApi.md Demonstrates using the Voucherify Python SDK to delete a custom event schema. Includes API key authentication setup and the method call for deletion. ```Python import voucherify from voucherify.rest import ApiException from pprint import pprint import os configuration = voucherify.Configuration( host = "https://api.voucherify.io" ) configuration.api_key['X-Management-Token'] = os.environ["API_KEY"] configuration.api_key['X-Management-Id'] = os.environ["API_KEY"] # The following code is a placeholder as the example was cut off in the input. # A full example would involve instantiating the API client and calling the delete_custom_event_schema method. ``` -------------------------------- ### Voucherify Python SDK: Get Reward Assignment Source: https://github.com/voucherifyio/voucherify-python-sdk/blob/master/docs/RewardsApi.md Shows how to retrieve a specific reward assignment using both the reward ID and the assignment ID with the Voucherify Python SDK. Covers API key setup, client initialization, and exception handling. ```python import voucherify from voucherify.models.rewards_assignments_get_response_body import RewardsAssignmentsGetResponseBody from voucherify.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to https://api.voucherify.io configuration = voucherify.Configuration( host = "https://api.voucherify.io" ) # Configure API key authorization: X-App-Id configuration.api_key['X-App-Id'] = os.environ["API_KEY"] # Configure API key authorization: X-App-Token configuration.api_key['X-App-Token'] = os.environ["API_KEY"] # Enter a context with an instance of the API client with voucherify.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = voucherify.RewardsApi(api_client) reward_id = 'reward_id_example' # str | A unique reward ID. assignment_id = 'assignment_id_example' # str | A unique reward assignment ID. try: # Get Reward Assignment api_response = api_instance.get_reward_assignment(reward_id, assignment_id) print("The response of RewardsApi->get_reward_assignment:\n") pprint(api_response) except Exception as e: print("Exception when calling RewardsApi->get_reward_assignment: %s\n" % e) ``` -------------------------------- ### List Bin Entries Source: https://github.com/voucherifyio/voucherify-python-sdk/blob/master/docs/BinApi.md Demonstrates how to list bin entries using the Voucherify Python SDK. It shows how to instantiate the API client, set parameters such as limit, order, starting_after_id, and filters, and handle the API response or exceptions. ```Python # configuration.api_key_prefix['X-App-Token'] = 'Bearer' # Enter a context with an instance of the API client with voucherify.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = voucherify.BinApi(api_client) limit = 56 # int | Limits the number of objects to be returned. The limit can range between 1 and 100 items. If no limit is set, it returns 10 items. (optional) order = voucherify.ParameterOrderListBin() # ParameterOrderListBin | Orders the bin entries according to the bin entry ID. The dash - preceding a sorting option means sorting in a descending order. (optional) starting_after_id = 'starting_after_id_example' # str | A cursor for pagination. It retrieves the results starting after a result with the given ID. (optional) filters = voucherify.ParameterFiltersListBin() # ParameterFiltersListBin | Filters for listing bin entries. (optional) try: # List Bin Entries api_response = api_instance.list_bin_entries(limit=limit, order=order, starting_after_id=starting_after_id, filters=filters) print("The response of BinApi->list_bin_entries:\n") pprint(api_response) except Exception as e: print("Exception when calling BinApi->list_bin_entries: %s\n" % e) ``` -------------------------------- ### Python SDK: List Campaign Templates Source: https://github.com/voucherifyio/voucherify-python-sdk/blob/master/docs/ManagementApi.md Example of using the Voucherify Python SDK to list campaign templates. Demonstrates API client configuration, authentication, and making the API call. ```Python import voucherify from voucherify.models.management_projects_templates_campaigns_list_response_body import ManagementProjectsTemplatesCampaignsListResponseBody from voucherify.models.parameter_filters_list_templates import ParameterFiltersListTemplates from voucherify.models.parameter_templates_list import ParameterTemplatesList from voucherify.rest import ApiException from pprint import pprint import os # Configuration configuration = voucherify.Configuration( host = "https://api.voucherify.io" ) # Authentication configuration.api_key['X-Management-Token'] = os.environ.get("API_KEY") configuration.api_key['X-Management-Id'] = os.environ.get("API_KEY") # API Client Initialization with voucherify.ApiClient(configuration) as api_client: api_instance = voucherify.ManagementApi(api_client) project_id = 'project_id_example' limit = 56 starting_after_id = 'starting_after_id_example' order = ParameterTemplatesList() include_total = True filters = ParameterFiltersListTemplates() # API Call try: api_response = api_instance.management_list_campaign_templates(project_id, limit=limit, starting_after_id=starting_after_id, order=order, include_total=include_total, filters=filters) print("The response of ManagementApi->management_list_campaign_templates:\n") pprint(api_response) except ApiException as e: print("Exception when calling ManagementApi->management_list_campaign_templates: %s\n" % e) ``` -------------------------------- ### Get Voucher by Code Source: https://github.com/voucherifyio/voucherify-python-sdk/blob/master/docs/VouchersApi.md Shows how to retrieve a specific voucher using its code or Voucherify ID with the Python SDK. It covers API key configuration for both 'X-App-Id' and 'X-App-Token', instantiating the API client, and calling the `get_voucher` method with the voucher code. Includes example usage and error handling. ```Python import voucherify import os from voucherify.models.vouchers_get_response_body import VouchersGetResponseBody from voucherify.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to https://api.voucherify.io # See configuration.py for a list of all supported configuration parameters. configuration = voucherify.Configuration( host = "https://api.voucherify.io" ) # The client must configure the authentication and authorization parameters # in accordance with the API server security policy. # Examples for each auth method are provided below, use the example that # satisfies your auth use case. # Configure API key authorization: X-App-Id configuration.api_key['X-App-Id'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['X-App-Id'] = 'Bearer' # Configure API key authorization: X-App-Token configuration.api_key['X-App-Token'] = os.environ["API_KEY"] # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['X-App-Token'] = 'Bearer' # Enter a context with an instance of the API client with voucherify.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = voucherify.VouchersApi(api_client) code = 'code_example' # str | A unique **code** that identifies the voucher. try: # Get Voucher api_response = api_instance.get_voucher(code) print("The response of VouchersApi->get_voucher:\n") pprint(api_response) except Exception as e: print("Exception when calling VouchersApi->get_voucher: %s\n" % e) ```