Package: sfcc-connector
Salesforce Commerce Cloud connectorThis package enables users to leverage a client offering resources to perform API calls against Salesforce Commerce Cloud (SFCC) via the standardOpen Commerce API (OCAPI).FeaturesBusiness Manager user grant authenticationRetry policy on each call:Applies to every request responding with 5xx status codeMax of 5 minutes with exponential backoff strategy with a max wait time of 30sStop after 5 mins of attemptsLimited amount of APIs offered but highly scalable and flexible model to integrate more at needGetting StartedInstallationTo install the tool viapipfromPyPI:pipinstallsfcc-connectorUsageSimple Example#!/usr/bin/env python3from__future__importabsolute_importfromdatetimeimportdatetime,timedeltafromsfcc_connectorimportSFCCClientfromapiclient.exceptionsimportAPIRequestErrorif__name__=="__main__":# !! Please replace values opportunely in your configuration !!default_config={"domain":"<YOUR-DOMAIN:YOUR-PORT>","ocapi_version":"<YOUR-OCAPI-VERSION>","site_id":"<YOUR-SITE-ID>","use_ssl":False,"is_production":False,"username":"<YOUR_USERNAME>","password":"<YOUR_PASSWORD>","client_id":"<YOUR-CLIENT-ID>","client_password":"<YOUR-CLIENT-PWD>"}# Initialize clientclient=SFCCClient(default_config)# Perform calls against SFCCtry:# Authentication is required to perform other callsresp=client.authenticate()print("Authentication response:{}".format(resp))# Fetching order details for order with ID = 1resp=client.get_order(1)print("Get Order (1) response:{}".format(resp))# Fetching all orders from yesterday up to nowend=datetime.now()begin=end-timedelta(days=1)resp=client.get_orders(begin,end)print("Get Orders response:{}".format(resp))# Fetching all jobs from yesterday up to nowresp=client.get_jobs(begin,end)print("Get Jobs response:{}".format(resp))exceptAPIRequestErrorase:print("Error{}".format(e))TheSFCCClientexposes a number of predefined methods that can be called to access equivalent resources on Salesforce Commerce Cloud.authenticateget_ordersget_orderget_jobsauthenticateNo arguments to be provided. Returns a valid token according tospecswhen successful.get_ordersThe query used by default will retrieve all orders havingcreation_dateorlast_modifiedwithin the time interval defined by givenbegin_dateandend_date.
Provide another query (custom_query) if you want to filter orders based on other criteria.By default all order fields will be returned. If you need to retrieve only a selection of them, please provide acustom_selectas for example:custom_select="(hits.(data.(creation_date,confirmation_status,total)))"ArgumentsFormatDescriptionbegin_datedatetimeUsed to filter orders based on time intervalend_datedatetimeUsed to filter orders based on time interval(optional)custom_querydictTo be built according tospecs(optional)custom_selectstrTo limit the amount of returned fieldsget_orderArgumentsFormatDescriptionorderintOrder ID to identify the order to be fetchedget_jobsThe query used by default will retrieve all jobs havingstart_timeorend_timewithin the time interval defined by givenbegin_dateandend_date. Provide another query (custom_query) if you want to filter orders based on other criteria.By default all order fields will be returned. If you need to retrieve only a selection of them, please provide an opportunecustom_selectArgumentsFormatDescriptionbegin_datedatetimeUsed to filter jobs based on time intervalend_datedatetimeUsed to filter jobs based on time interval(optional)custom_querydictTo be built according tospecs(optional)custom_selectstrTo limit the amount of returned fieldsContributingDo you want to use this library for your own projects? Great!Want to contribute? Even better! Feel free to create aPRFound a bug?Open an issueLicenseMIT Licensed. SeeLICENSEfor full details.