Salesforce Commerce Cloud connector
This package enables users to leverage a client offering resources to perform API calls against Salesforce Commerce Cloud (SFCC) via the standard Open Commerce API (OCAPI).
Features
- Business Manager user grant authentication
- Retry policy on each call:
- Applies to every request responding with 5xx status code
- Max of 5 minutes with exponential backoff strategy with a max wait time of 30s
- Stop after 5 mins of attempts
- Limited amount of APIs offered but highly scalable and flexible model to integrate more at need
Getting Started
Installation
To install the tool via pip from PyPI:
pip install sfcc-connector
Usage
Simple Example
#!/usr/bin/env python3
from __future__ import absolute_import
from datetime import datetime, timedelta
from sfcc_connector import SFCCClient
from apiclient.exceptions import APIRequestError
if __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 client
client = SFCCClient(default_config)
# Perform calls against SFCC
try:
# Authentication is required to perform other calls
resp = client.authenticate()
print("Authentication response: {}".format(resp))
# Fetching order details for order with ID = 1
resp = client.get_order(1)
print("Get Order (1) response: {}".format(resp))
# Fetching all orders from yesterday up to now
end = 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 now
resp = client.get_jobs(begin, end)
print("Get Jobs response: {}".format(resp))
except APIRequestError as e:
print("Error {}".format(e))
The SFCCClient exposes a number of predefined methods that can be called to access equivalent resources on Salesforce Commerce Cloud.
authenticate
No arguments to be provided. Returns a valid token according to specs when successful.
get_orders
The query used by default will retrieve all orders having creation_date or last_modified within the time interval defined by given begin_date and end_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 a custom_select as for example: custom_select="(hits.(data.(creation_date,confirmation_status,total)))"
| Arguments | Format | Description |
|---|---|---|
begin_date |
datetime |
Used to filter orders based on time interval |
end_date |
datetime |
Used to filter orders based on time interval |
(optional) custom_query |
dict |
To be built according to specs |
(optional) custom_select |
str |
To limit the amount of returned fields |
get_order
| Arguments | Format | Description |
|---|---|---|
order |
int |
Order ID to identify the order to be fetched |
get_jobs
The query used by default will retrieve all jobs having start_time or end_time within the time interval defined by given begin_date and end_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 opportune custom_select
| Arguments | Format | Description |
|---|---|---|
begin_date |
datetime |
Used to filter jobs based on time interval |
end_date |
datetime |
Used to filter jobs based on time interval |
(optional) custom_query |
dict |
To be built according to specs |
(optional) custom_select |
str |
To limit the amount of returned fields |
Contributing
Do you want to use this library for your own projects? Great!
- Want to contribute? Even better! Feel free to create a PR
- Found a bug? Open an issue
License
MIT Licensed. See LICENSE for full details.
Metadata
Release files for sfcc-connector 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sfcc connector-1.0.3.tar.gz | 11.2 kB | Without provenance | Details for sfcc connector-1.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sfcc_connector-1.0.3-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for sfcc_connector-1.0.3-py2.py3-none-any.whl |
Total release size: 21.6 kB
Release files / sfcc connector-1.0.3.tar.gz
| Download URL | sfcc connector-1.0.3.tar.gz |
|---|---|
| Size | 11.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3f3b12029ce6fb6ca82f70e7b24ac17f83575adacd1d4633380d02a8c9fbd82d
|
|
BLAKE2b-256 checksum How to use checksums |
76a2ddd38b1c1cc2b68ea96b51164c20c91d833233c3a720cae98aba9cbdae79
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0
|
Release files / sfcc_connector-1.0.3-py2.py3-none-any.whl
| Download URL | sfcc_connector-1.0.3-py2.py3-none-any.whl |
|---|---|
| Size | 10.4 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
98ac1447729086d30dff4bdeb9c8b9de836812b7c443a032ebc1bd127408dfb5
|
|
BLAKE2b-256 checksum How to use checksums |
edbe07fe677c9fe75504f6f0e842a4bc5a3c406e12f7b148918fe539b0b44acd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0
|
Security for sfcc-connector 1.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.