Class: SpiffCommerceClient
The Spiff Commerce Javascript Client. Required for creating workflow experiences.
Constructors
Constructor
new SpiffCommerceClient(
options):SpiffCommerceClient
Parameters
options
Returns
SpiffCommerceClient
Methods
canUseAddon()
canUseAddon(
addonHandle):Promise<boolean>
Parameters
addonHandle
Returns
Promise<boolean>
clearCustomer()
clearCustomer():
void
Returns
void
clearCustomerForTransaction()
clearCustomerForTransaction(
transactionId):void
Parameters
transactionId
string
Returns
void
configure()
configure(
configuration):void
Parameters
configuration
Returns
void
customerHasBundleTemplates()
customerHasBundleTemplates(
emailAddress):Promise<boolean>
Parameters
emailAddress
string
Returns
Promise<boolean>
duplicateBundle()
duplicateBundle(
bundleId,template?,duplicateTransactions?,options?):Promise<() =>Promise<Bundle>>
Parameters
bundleId
string
The id of the bundle to copy. The current context must have write access to the this bundle in order to duplicate it.
template?
boolean
Optional: Whether to mark the new bundle as a template. Default is false.
duplicateTransactions?
boolean
Optional: Whether to also duplicate the original bundle's transactions. Default is true.
options?
Optional: Options to configure the duplicate. Set test to mark the new bundle as a test bundle; defaults to the source bundle's value.
Returns
Promise<() => Promise<Bundle>>
A bundle to be used for grouping and operating on large amounts of workflow experiences.
generateVerificationCode()
generateVerificationCode(
emailAddress):Promise<void>
Generate an email code to allow logging in as a Spiff user.
Parameters
emailAddress
string
Returns
Promise<void>
getAssetManager()
getAssetManager():
AssetManager
Returns
AssetManager
The asset manager allows for common operations related to assets and the Spiff Commerce platform.
getBetaEnabled()
getBetaEnabled():
Promise<boolean>
Returns
Promise<boolean>
A promise that resolves with a boolean indicating whether to use beta features.
getBundlesForCustomer()
getBundlesForCustomer(
options):Promise<BundlesFeed>
Fetches information about the currently authenticated customer's bundles.
NOTE: This does not initialize a bundle for active use.
You must call either getExistingBundle or duplicateBundle to actually interact with a bundle.
Parameters
options
Options to configure the request.
includeMetadata?
boolean
Whether to include each bundle's metadata in the response.
limit
number
The maximum amount of bundles to return in the response.
offset
number
The amount of items to skip over in the server query.
ordered?
boolean
Undefined: Any bundle, ordered or not. True. Just the ordered ones. False: Just the unordered ones.
template?
boolean
Undefined: Any bundle, template or not. True: The bundle must be a template. False: The bundle must not be a template
templateStatus?
BundleTemplateStatus
The status of the bundle template; "Active" or "Draft".
Returns
Promise<BundlesFeed>
A promise that resolves with an object containing:
items - The bundles that matched the request.
total - The total number of bundles on the server that match this query.
getBundleStakeholders()
getBundleStakeholders():
Promise<BundleStakeholder[]>
Retrieves all existing bundle stakeholders from the API, for the currently authenticated customer.
Returns
Promise<BundleStakeholder[]>
An array of bundle stakeholders.
getCurrencyContext()
getCurrencyContext(
presentmentCurrency):Promise<CurrencyContext>
Parameters
presentmentCurrency
string
Returns
Promise<CurrencyContext>
getCustomer()
getCustomer():
Customer|undefined
Returns
Customer | undefined
getCustomerMetafields()
getCustomerMetafields():
Promise<Metafield[]>
Returns
Promise<Metafield[]>
getExistingBundle()
getExistingBundle(
bundleId,previewService?,graphqlOptions?,options?,transactionLoadProgressCallback?):Promise<Bundle>
Retrieves an existing bundle from the API, by id.
Parameters
bundleId
string
The id of the bundle to retrieve.
previewService?
ThreeDPreviewService
Optional: A reference to an existing preview service to use. This can be assigned manually later.
graphqlOptions?
Optional: Options to configure loading the bundle.
options?
Optional: Options to configure loading the bundle.
transactionLoadProgressCallback?
(loaded, total) => void
Returns
Promise<Bundle>
A bundle to be used for grouping and operating on large amounts of workflow experiences.
getFlowService()
getFlowService():
FlowService
Returns
getIntegration()
getIntegration():
Promise<Integration>
Returns
Promise<Integration>
getIntegrationProduct()
getIntegrationProduct(
options):Promise<IntegrationProduct>
Parameters
options
Extendable<{ integrationProductId: string; type: "integration"; }> | Extendable<{ externalIntegrationId: string; externalProductId: string; type: "external"; }>
Returns
Promise<IntegrationProduct>
getIntegrationProductById()
getIntegrationProductById(
integrationProductId,fetchIntegrationsOnProduct?):Promise<IntegrationProduct>
Parameters
integrationProductId
string
fetchIntegrationsOnProduct?
boolean
Returns
Promise<IntegrationProduct>
getIntegrationProductFromExternalIds()
getIntegrationProductFromExternalIds(
externalIntegrationId,externalProductId,fetchIntegrationsOnProduct?):Promise<IntegrationProduct>
Parameters
externalIntegrationId
string
externalProductId
string
fetchIntegrationsOnProduct?
boolean
Returns
Promise<IntegrationProduct>
getNewBundle()
getNewBundle(
collectionId?,initialMetadata?,options?,activationId?):Promise<Bundle>
Parameters
collectionId?
string
Optional: The id of the product collection that the bundle can use.
initialMetadata?
{[key: string]: string; }
options?
Optional: Options to configure creating the bundle. Set test to mark the new bundle as a test bundle.
activationId?
string
Returns
Promise<Bundle>
A bundle to be used for grouping and operating on large amounts of workflow experiences.
getOrCreateCustomer()
getOrCreateCustomer(
emailAddress):Promise<{customer:Customer;isAuthenticated:boolean; }>
Parameters
emailAddress
string
Returns
Promise<{ customer: Customer; isAuthenticated: boolean; }>
getShareActionsForTransaction()
getShareActionsForTransaction(
transactionId):Promise<ShareAction[] |undefined>
Parameters
transactionId
string
Returns
Promise<ShareAction[] | undefined>
getStakeholderTypeForTransaction()
getStakeholderTypeForTransaction(
transactionId):StakeholderType|undefined
Parameters
transactionId
string
Returns
StakeholderType | undefined
getTemplatesForCustomer()
getTemplatesForCustomer(
options):Promise<{items:GlobalPropertyTemplate[];total:number; }>
Fetches information about the currently authenticated customer's bundles.
Parameters
options
globalPropertyConfigurationId?
string
Filter the templates made for this specific configuration. Undefined returns all templates for this customer.
limit
number
The maximum amount of bundles to return in the response.
offset
number
The amount of items to skip over in the server query.
Returns
Promise<{ items: GlobalPropertyTemplate[]; total: number; }>
getVersion()
getVersion():
string
Returns
string
The version of the @spiffcommerce/core package that this client is running.
getWorkflowExperience()
getWorkflowExperience(
options,previewServiceConstructor?):Promise<WorkflowExperience>
Creates a new instance of WorkflowExperience. A high level wrapper for workflows.
Parameters
options
Options to configure loading the transaction and workflow.
previewServiceConstructor?
(workflow) => ThreeDPreviewService
A function called during initialization. Takes a class implementing ThreeDPreviewService in return.
Returns
Promise<WorkflowExperience>
A workflow experience configured as requested.
getWorkflowExperiences()
getWorkflowExperiences(
optionsArray,graphqlOptions?,transactionInitializedCallback?,transactionLoadProgressCallback?):Promise<WorkflowExperience[]>
Gets multiple workflow experiences at once.
Parameters
optionsArray
An array of options to configure loading the transactions and workflows.
NOTE: The previewService field on the option is currently unsupported in this function, as loading multiple models at once will likely cause performance issues.
graphqlOptions?
Options to configure loading the workflows.
transactionInitializedCallback?
() => void
transactionLoadProgressCallback?
(loaded, total) => void
Returns
Promise<WorkflowExperience[]>
An array of workflow experiences configured as requested.
loggedInBearerToken()
loggedInBearerToken():
Promise<string>
Returns
Promise<string>
logOut()
logOut():
Promise<void>
Log out the currently logged-in Spiff user.
Returns
Promise<void>
placeOrder()
placeOrder(
orderItems):Promise<Order>
Parameters
orderItems
Returns
Promise<Order>
reloadLoggedInCustomer()
reloadLoggedInCustomer():
Promise<boolean>
Check if a customer is logged in. If they are, set the customer object. This is how we resume sessions between loads.
Returns
Promise<boolean>
storeCustomer()
storeCustomer(
customer):void
Parameters
customer
Returns
void
verifyCode()
verifyCode(
emailAddress,code):Promise<boolean>
Verify an email code to log in as a Spiff user. Always returns true if it doesn't throw.
Parameters
emailAddress
string
code
string
Returns
Promise<boolean>