Python SDK is a library that simplifies work with Connect APIs and could be found at
The library can be consumed in your project in order to automate the fulfillment of requests. Once imported into your project, it will allow you to:
Your code may use any scheduler to execute, from a simple cron to a cloud scheduler like the ones available in the major cloud providers, like:
Additionally you may use the webhooks functionality from Connect to instantiate your solution,
We recommend to install using pip:
# pip install connect-sdk
from connect import FulfillmentAutomation from connect.logger import logger from connect.models import ActivationTemplateResponse, ActivationTileResponse from connect.models.exception import FulfillmentFail, FulfillmentInquire, Skip class ExampleRequestProcessor(FulfillmentAutomation): def process_request(self, request): # custom logic if request.type == 'purchase': for item in request.asset.items: if item.quantity > 100000: raise FulfillmentFail( message='Is Not possible to purchase product') for param in request.asset.params: if param.name == 'email' and not param.value: param.value_error = 'Email address has not been provided, please provide one' raise FulfillmentInquire(params=[param]) # approve by ActivationTile return ActivationTileResponse(tile='\n # Welcome to Fallball!\n\nYes, ' 'you decided to have an account in our amazing service!') # or # return TemplateResource().render(pk='TEMPLATE_ID', request_id=request.id) # aprrove by Template return ActivationTemplateResponse(template_id="TL-497-535-242") # or # return TemplateResource().get(pk='TEMPLATE_ID') elif request.type == 'change': # fail raise FulfillmentFail() else: # skip request raise Skip() if __name__ == '__main__': request = ExampleRequestProcessor() request.process()
Additional documentation on how to use the Python SDK for Connect can be found at Read The Docs.