menu
Menu
Mobify DevCenter
search_icon_focus

Interfaces

@mobify/commerce-integrations/dist/connectors/interfaces

The interfaces module contains the CommerceConnector interface that is used to implement a connector for an ecommerce backend system. It also contains the ParserHooks interface used in a connector.

interface

CommerceConnector

getDefaultHeaders()

Get the default headers that are sent with every request.

Returns:

Object.<String, String>


setDefaultHeaders(headers)

Set the default headers that are sent with every request.

ParameterType
headersObject.<String, String>

login(username, password)

Log a customer in and return their details.

On backends which support “guest login”, credentials can be omitted to give you a guest session.

Returns:

Promise.<Customer>

Throws:

InvalidArgumentError Will throw an error if the username or password aren’t provided for type registered.

ForbiddenError Will throw an error if the customer credentials are incorrect.

ParameterType
usernameString
passwordString

logout()

Log a customer out.

Returns:

Promise.<undefined>

Throws:

ServerError Will throw an error if there was a server-side error.


refreshSession()

Refresh a session token, on backends that support refresh.

Returns:

Promise.<Customer>

Throws:

ForbiddenError Will throw an error if authorization credentials are incorrect


getCustomer(id, [opts])

Return a customer’s details by id.

Returns:

Promise.<Customer>

Throws:

ServerError Throw generic error if server has error.

ParameterTypeDescription
idStringCustomer Id
[opts]ObjectOptions object

searchProducts(productSearchRequest, [opts])

Search for products, given a productSearchRequest object.

Returns:

Promise.<ProductSearch>

ParameterTypeDescription
productSearchRequestProductSearchRequestSearch query
[opts]ObjectOptions object

getProduct(id, [opts])

Get a single product by id.

Returns:

Promise.<Product>

ParameterTypeDescription
idStringThe product id.
[opts]ObjectOptions object

getProducts(ids, [opts])

Get multiple products by their ids.

On supported backends this method will retrieve products in a single network call. Others may make a call per id to emulate the same behaviour.

Invalid ids are ignored and results are not guaranteed to be returned in the order requested.

Returns:

Promise.<ProductList>

ParameterTypeDescription
idsArray.<String>The product ids.
[opts]ObjectOptions object

getStore(id, [opts])

Get a Store (ie. a physical retail-outlet) by id. Includes addresses, opening hours, etc.

Returns:

Promise.<Store>

ParameterTypeDescription
idStringThe id of the store
[opts]ObjectOptions object

getCategory(id, [opts])

Get a product Category by id.

Returns:

Promise.<Category>

ParameterTypeDescription
idString
[opts]Objectobject

getCategories(ids, [opts])

Returns multiple product Categories by their ids.

On supported backends this method will retrieve Categories in a single network call. Others may make a call per id to emulate the same behaviour.

Invalid ids are ignored and results are not guaranteed to be returned in the order requested.

Returns:

Promise.<CategoryList>

ParameterTypeDescription
idsArray.<string>
[opts]Objectobject

searchStores(storeSearchRequest, [opts])

Searches for Stores (ie. physical retail-outlets).

Returns:

Promise.<StoreSearchResult>

ParameterTypeDescription
storeSearchRequestStoreSearchRequest
[opts]ObjectOptions object

createCart(oldCcart, [opts])

Creates a new cart with an optional cart object.

Returns:

Promise.<Cart>

Throws:

Could not create cart.

ParameterTypeDescription
oldCcartCartThe cart you’d like to migrate to the new cart
[opts]Objectobject

getCart(cartId, [opts])

Retrieve cart by id.

Returns:

Promise.<Cart>

ParameterTypeDescription
cartIdStringThe id of the cart you want to retrieve
[opts]Objectobject

deleteCart(cartId, [opts])

Deletes the given cart

Throws:

Could not delete cart.

ParameterTypeDescription
cartIdStringThe id of the cart you want to delete.
[opts]Objectobject

addCartItem(cart, cartItem, opts)

Adds a cart item to cart.

Returns:

Promise.<Cart>

ParameterTypeDescription
cartCartThe cart to add the cart item to.
cartItemCartItemThe cart item to add.
optsObject

removeCartItem(cart, cartItemId, opts)

Remove a cart item from the cart.

Returns:

Promise.<Cart>

ParameterTypeDescription
cartCartThe cart to remove the cart item from.
cartItemIdStringThe id of the cart item to remove.
optsObject

updateCartItem(cart, cartItem, opts)

Update an existing cart item in the cart.

Returns:

Promise.<Cart>

ParameterTypeDescription
cartCartThe cart to containing the cart item to update.
cartItemCartItemThe cart item to update.
optsObject

setShippingAddress(cart, shippingAddress, opts)

Set the shipping address on the cart.

Returns:

Promise.<Cart>

ParameterTypeDescription
cartCartThe cart to update the shipping address for.
shippingAddressOrderAddressThe new or modified address.
optsObject

setBillingAddress(cart, billingAddress, opts)

Set the billing address on the cart.

Returns:

Promise.<Cart>

ParameterTypeDescription
cartCartThe cart to update the billing address for.
billingAddressOrderAddressThe new or modified address.
optsObject

setPayment(cart, payment, opts)

Add a supported payment type to the cart

Returns:

Promise.<Cart>

ParameterTypeDescription
cartCartThe cart to remove the payment from.
paymentPaymentThe payment to add.
optsObject

getShippingMethods(cart, opts)

Get all the available shipping methods given the cart details.

Returns:

Promise.<Array.<ShippingMethod>>

ParameterTypeDescription
cartCartThe cart to determinen avaialble shipping methods for.
optsObject

setShippingMethod(cart, shippingMethod, opts)

Set the shipping method for the cart.

Returns:

Promise.<Cart>

ParameterTypeDescription
cartCartThe cart to set the shipping method for.
shippingMethodShippingMethodThe shipping method to set.
optsObject

setCustomerInformation(cart, customerInformation, opts)

Set the customer information.

Returns:

Promise.<Cart>

ParameterTypeDescription
cartCartThe customer’s cart.
customerInformationCustomerInformationThe new or modified customer information.
optsObject

getPaymentMethods(cart, opts)

Get the available payment methods for the cart.

Returns:

Promise.<Array.<PaymentMethod>>

ParameterTypeDescription
cartCartThe customer’s cart.
optsObject

createOrder(cart, opts)

Create a new order using a given cart.

Returns:

Promise.<Order>

ParameterTypeDescription
cartCartThe customer’s cart.
optsObject

getOrder(id, [opts])

Get a single order by id.

Returns:

Promise.<Order>

ParameterTypeDescription
idStringThe order id.
[opts]ObjectOptions object

getOrders(ids, [opts])

Get multiple orders by their ids.

On supported backends this method will retrieve orders in a single network call. Others may make a call per id to emulate the same behaviour.

Invalid ids are ignored and results are not guaranteed to be returned in the order requested.

Returns:

Promise.<OrderList>

ParameterTypeDescription
idsArray.<String>The order ids.
[opts]ObjectOptions object

addCouponEntry(cart, couponEntry, opts)

Add a coupon to the cart by it’s code.

Returns:

Promise.<Cart>

ParameterTypeDescription
cartCartThe customer’s cart.
couponEntryObjectThe coupon.
optsObjectOptions object.

removeCouponEntry(cart, couponEntryId, opts)

Removes a coupon from the cart by its coupon entry id.

Returns:

Promise.<Cart>

ParameterTypeDescription
cartCartThe customer’s cart.
couponEntryIdObjectThe coupon entry id.
optsObjectOptions object.

interface

ParserHooks

parseCustomer()

Parse a customer.


parseCategory()

Parse a category.


parseCategories()

Parse categories.


parseSearchProducts()

Parse a product search result.


parseProduct()

Parse a product.


parseProducts()

Parse products.


parseStore()

Parse a store.


parseSearchStores()

Parse a StoreSearchResult


parseCart()

Parse a cart


parseCartItem()

Parse a cart item


parseOrderAddress()

Parse an order address


parseCustomerInformation()

Parse customer information


parseShippingMethod()

Parse a shipping method


parsePayment()

Parse a payment.


parsePaymentMethod()

Parse a payment method.


parseOrder()

Parse an order.


parseCouponEntry()

Parse an coupon entry.