menu
Menu
Mobify DevCenter
search_icon_focus

Hybris

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

The hybris module contains the HybrisConnector class, an implementation of the CommerceConnector interface using the Omni Channel Connect API (OCC API) for connecting to SAP Hybris Commerce.

class

HybrisConnector

A Commerce Integrations connector for SAP Hybris Commerce backends.

Import
import { HybrisConnector } from '@mobify/commerce-integrations/dist/connectors/hybris

Implements:

CommerceConnector, ParserHooks

Methods

registerCustomer(data)

Register a new customer account and login.

Returns:

Promise.<Customer>

ParameterType
dataHybrisCustomerRegistration

getAuthentications()

Get the current authentications object, which can be used to save and restore auth state.

Returns:

Object


setAuthentications(authentications)

Set the current authentications object, as returned from getAuthentications. Use to save and restore auth state.

ParameterType
authenticationsObject

parseCategory(categories)

Takes an OCC API Category objects and parses it into an commerce-integrations Category type.

Returns:

Promise.<Category>

ParameterTypeDescription
categoriesArray.<Object>An OCC API Category document

parseOpeningHours(hours)

Takes an OCC API WeekdayOpeningDay object and parses it into a commerce-integrations Store.hours type.

Returns:

Promise.<Store>

ParameterTypeDescription
hoursObjectAn OCC API WeekdayOpneningDay document

parseGetStore(data)

Takes an OCC API PointOfService object and parses it into a commerce-integrations Store type.

Returns:

Promise.<Store>

ParameterTypeDescription
dataObjectAn OCC API PointOfService document

parseCouponEntry()

Parse a coupon item


transformOrderAddress()

Transform an orderAddress into hybris’ models: billingAddress or shippingAddress


transformShippingMethod()

Transform a shippingMethod into hybris’ model deliveryMethod.


transformCartItem()

Transform a cartItem into hybris’ model OrderEntryOCC.


transformPayment()

Transform a payment into hybris’ model paymentDetail.


setPayment(cart, payment, opts)

Add a supported payment type to the cart

Returns:

Promise.<Cart> - Need to set a billing address before setting a payment. Must call setCustomerInformation() to add an email before setting payment for an anonymous cart.user. cart.paymentDetails.number will be returned as undefined and set as a masked number in cart.paymentDetails.maskedNumber.

ParameterTypeDescription
cartCartThe cart to add the payment to
paymentPaymentThe payment to add
optsObject

setCustomerInformation(cart, customerInformation, opts)

Set the customer information.

Returns:

Promise.<Cart> - Email can be set for a guest user but not a registered user.

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

setBillingAddress(cart, billingAddress, opts)

Set the billing address on the cart.

Billing Address model : this order address needs to have a titleCode defined. The default titleCodes are: [‘mr’, ‘ms’, ‘miss’, ‘mrs’, ‘dr’, ‘rev’] But these may change depending on your backend, please refer to your backend instance to confirm valid titleCodes.

If the billing address is set before adding a payment, the billing address will not yet be saved in the hybris instance. Instead, the billing address will be saved in the hybris instance upon setting a payment.

Returns:

Promise.<Cart>

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

setShippingAddress(cart, shippingMethod, opts)

Set the shipping method for the cart.

Returns:

Promise.<Cart> - Must call setCustomerInformation() to add an email before setting payment for a guest user.

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

getPaymentMethods(cart, opts)

Get the available payment methods for the cart

Returns:

Promise.<Array.PaymentMethod> - Hybris only supports payments by credit card attained from their cardtypes endpoint so this command will return only one payment method with the id ‘CREDIT_CARD’, name ‘Credit Card’ and all of it’s valid credit card types.

ParameterTypeDescription
cartCartThe customer’s cart
optsObject

parseCategories()

Parse categories.


parseSearchProducts()

Parse a product search result.


parseProduct()

Parse a product.


parseSearchStores()

Parse a StoreSearchResult


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

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

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.

parseCustomer()

Parse a customer.


parseCart()

Parse a cart


parseCartItem()

Parse a cart item


parseOrderAddress()

Parse an order address


parseShippingMethod()

Parse a shipping method


parsePayment()

Parse a payment.


parsePaymentMethod()

Parse a payment method.


parseOrder()

Parse an order.