Skip to content
This repository has been archived by the owner on Oct 16, 2019. It is now read-only.

JavaScript SDK Core for Zalando Checkout, Guest Checkout, and Catalog APIs

License

Notifications You must be signed in to change notification settings

zalando-incubator/atlas-js-core

Repository files navigation

npm downloads MIT licensed Build Status David codecov Commitizen friendly semantic-release

Atlas JavaScript SDK Core

This SDK covers the functionality provided by team Atlas' (aka Distributed Commerce) APIs, namely, Checkout, Guest Checkout, and Catalog APIs.

Those APIs, and in turn this SDK, provide our partners a more streamlined access the Zalando shopping platform to enable our customers to purchase wherever they are.

The purpose of this project is to provide low-level calls to API backend and response models for Zalando Checkout, Guest Checkout, and Catalog APIs in order to allow easily integrate and run Zalando Сheckout in minutes using your own UI solution.

If you want to access the APIs directly we recommend that you take a look at their documentation.

We use Promises a lot :)

Installation

npm install --save atlas-sdk-core es6-promise

On install we're transpiling the code for your convenience. You have access to two files under a lib/ folder, one for using in node and another for browser usages.

Warning

Because we are using Promises you must bring your own ES6 Promise compatible polyfill, e.g. es6-promise.

Local Development

If you want to contribute, please, read our Contributing guidelines first.

In order to start SDK development simply run

npm run tdd

Check existing codebase tests for test examples.

Configuration and Usage

You need to configure Atlas JavaScript SDK Core first and use configured instance variable to interact with AtlasSDK.

In order to configure AtlasSDK manually provide an object with 2 mandatory parameters client_id and sales_channel:

import AtlasSDK from 'atlas-sdk-core';

AtlasSDK.configure({
  client_id: 'CLIENT_ID',
  sales_channel: 'SALES_CHANNEL',
  is_sandbox: true
}).then((sdk) => {
  // sdk instance is ready to use

  sdk.getArticle('AD112B0F6-A11').then((article) => {
    console.log(`Article name: ${article.name}`);
  });
}).catch((error) => {
  console.error(`${error}`);
});

Since we are using Promises you can benefit from await/async:

import AtlasSDK from 'atlas-sdk-core';

const sdk = await AtlasSDK.configure({
  client_id: 'CLIENT_ID',
  sales_channel: 'SALES_CHANNEL'
});
const article = await sdk.getArticle('AD112B0F6-A11');
console.log(`Article name: ${article.name}`);

API Reference

Modules

AtlasSDK

AtlasSDK is a global namespace.

Classes

AtlasSDKClient

AtlasSDK instance returned from AtlasSDK configure method.

PickupPoint
AddressSchema

Baseclass for Address model

CheckoutAddressSchema

Baseclass for CheckoutAddress model

NormalizedAddress

Baseclass for NormalizedAddress model

CheckedAddress

Baseclass for CheckedAddress model

Brand

Class for Brand model.

Partner

Class for Partner model.

PriceSchema

Class for Article Unit Price model.

Unit

Class for Article Unit model.

Attribute

Class for Article Unit Attribute model.

EnrichmentAttribute

Class for Article Unit EnrichmentAttribute model.

TargetGroups

Class for TargetGroups model.

ArticleImage

Class for ArticleImage model.

Media

Class for Media model.

Item

Class for CartItem model

ItemWithPrice

Class for CartItem model

Payment

Class for Payment model

Delivery

Class for Delivery model'

ReviewRatingDistribution

Class for ReviewRatingDistribution.

ReviewRating

Class for ReviewRating.

ReviewRecommendations

Class for ReviewRecommendations.

ReviewSummary

Class for ReviewSummary.

ReviewEntry

Class for ReviewEntry.

Reviews

Class for Article Reviews.

Image

Class for Image model.

Video

Class for Video model.

Article

Class for Article model

ArticleFamily

Class for ArticleFamily model

DiscountSchema

Class for Discount model

CheckoutCouponDiscount

Class for Checkout Discount model

DeliveryRequest

Class for Delivery Request model

CreateCartRequest

Class for Cart Request model

SelectedPayment

Class for Selected Payment model

Payment

Class for Payment model

CheckoutCouponDetails

Class for Checkout Coupon Details model

CartResponse

Class for Cart Response model

CartsResponse

Class for Carts Response model

CreateCheckoutRequest

Class for Checkout Request model

CheckoutResponse

Class for Checkout Response model

PutCheckoutRequest

Class for Put Checkout Request model

CheckoutOrderRequest

Class for Checkout Order Request model

SalesChannel

SalesChannel class struct

Recommendations

Recommendations class struct

Config

Config class struct

GuestCustomer

Class for Guest Customer model

CheckoutCustomer

Class for Guest Customer model

Cart

Cart

CreateOrderRequest

Class for CreateOrderRequest model

CreateOrderResponse

Class for CreateOrderResponse model

CreateOrderRedirectResponse

Class for CreateOrderRedirectResponse model

GetCheckoutResponse

Class for GetCheckoutResponse model

OrderResponse

Class for Order Response model

CheckoutApiOrderResponseSchema

Class for Checkout Order Response model

CheckoutOrder

Class for Guest Customer model

RecommendedArticle

Class for Recommended Article model

Constants

configCache

A temporary fix to handle the current high load capacity

Functions

fetchEndpoint(endpoint)Promise

Calls the given endpoint using fetch and intercepts the response via various operations

AtlasSDK

AtlasSDK is a global namespace.

Access: public

AtlasSDK.configure(options) ⇒ Promise.<AtlasSDKClient>

Configure AtlasSDK. This is the main entry point to use the AtlasSDK.

Kind: static method of AtlasSDK
Returns: Promise.<AtlasSDKClient> - a promise resolving with an AtlasSDKClient object
Access: public

Param Type Description
options Object An object containing configiration data:
  • {String} client_id Client Id of a partner
  • {String} sales_channel Sales Channel assigned for a partner
  • {boolean} is_sandbox Indicates sandbox mode (default false)

Example

const sdk = await AtlasSDK.configure({
  client_id: 'CLIENT_ID',
  sales_channel: 'SALES_CHANNEL',
  is_sandBox: true
});

AtlasSDKClient

AtlasSDK instance returned from AtlasSDK configure method.

Kind: global class

new AtlasSDKClient(config)

Creates an AtlasSDK instance from config provided by config-api

Param Type Description
config Object config from config-api

atlasSDKClient.getLocale() ⇒ String

Returns locale based on sales channel, e.g. 'de_DE'

Kind: instance method of AtlasSDKClient
Returns: String - locale

atlasSDKClient.getLanguage() ⇒ String

Returns language based on sales channel, e.g. 'de'

Kind: instance method of AtlasSDKClient
Returns: String - language

atlasSDKClient.getCountryCode() ⇒ String

Returns country code based on sales channel, e.g. 'DE'

Kind: instance method of AtlasSDKClient
Returns: String - country code

atlasSDKClient.getConfig() ⇒ Object

Returns configuration from config-api

Kind: instance method of AtlasSDKClient
Returns: Object - config

atlasSDKClient.getArticle(sku, [options]) ⇒ Article

Fetches an article based on a SKU.

Kind: instance method of AtlasSDKClient
Returns: Article - return Article object
Access: public

Param Type Description
sku String SKU of an article
[options] Object Configuration options:
  • media:
    • {String} cdn: 'mosaic01' or 'mosaic02' (default is 'mosaic01')
    • {Array} image_resolutions: request media image with the different resolutions (default ['thumbnail', 'medium', 'large']):
      • 'thumbnail' – width: 78px
      • 'thumbnail_hd' – width: 76px
      • 'small' – width: 135px
      • 'small_hd' – width: 270px
      • 'medium' – width: 300px, height: 400px
      • 'medium_sd' – width: 480px
      • 'medium_hd' – width: 600px, height: 800px
      • 'large' – width: 1100px, height: 1100px
      • 'large_hd' – height: 1650px
For example
 {  media: {    cdn: 'mosaic02',    image_resolutions: ['thumbnail', 'medium']  } } 

Example

const sdk = await AtlasSDK.configure({
  client_id: 'CLIENT_ID',
  sales_channel: 'SALES_CHANNEL',
  is_sandBox: true,
  lang: 'en'
});
const article = await sdk.getArticle('AD112B0F6-A11', {
   media: {
     image_resolutions: ['thumbnail', 'medium']
   }
});

atlasSDKClient.getArticles(skus, [options]) ⇒ Array.<Article>

Fetches multiple articles based on SKUs.

Kind: instance method of AtlasSDKClient
Returns: Array.<Article> - return Article[] object
Access: public

Param Type Description
skus String comma separated SKUs of multiple articles
[options] Object Configuration options:
  • media:
    • {String} cdn: 'mosaic01' or 'mosaic02' (default is 'mosaic01')
    • {Array} image_resolutions: request media image with the different resolutions (default ['thumbnail', 'medium', 'large']):
      • 'thumbnail' – width: 78px
      • 'thumbnail_hd' – width: 76px
      • 'small' – width: 135px
      • 'small_hd' – width: 270px
      • 'medium' – width: 300px, height: 400px
      • 'medium_sd' – width: 480px
      • 'medium_hd' – width: 600px, height: 800px
      • 'large' – width: 1100px, height: 1100px
      • 'large_hd' – height: 1650px
For example
 {  media: {    cdn: 'mosaic02',    image_resolutions: ['thumbnail', 'medium']  } } 

Example

const sdk = await AtlasSDK.configure({
  client_id: 'CLIENT_ID',
  sales_channel: 'SALES_CHANNEL',
  is_sandBox: true,
  lang: 'en'
});
const articles = await sdk.getArticles('AD112B0F6-A11,SO254C009-K12', {
   media: {
     image_resolutions: ['thumbnail', 'medium']
   }
});

atlasSDKClient.getArticleFamilies(sku, [options]) ⇒ Array.<ArticleFamily>

Fetches article families based on SKU.

Kind: instance method of AtlasSDKClient
Returns: Array.<ArticleFamily> - return ArticleFamily[] object
Access: public

Param Type Description
sku String SKU of an article
[options] Object Configuration options:
  • media:
    • {String} cdn: 'mosaic01' or 'mosaic02' (default is 'mosaic01')
    • {Array} image_resolutions: request media image with the different resolutions (default ['thumbnail', 'medium', 'large']):
      • 'thumbnail' – width: 78px
      • 'thumbnail_hd' – width: 76px
      • 'small' – width: 135px
      • 'small_hd' – width: 270px
      • 'medium' – width: 300px, height: 400px
      • 'medium_sd' – width: 480px
      • 'medium_hd' – width: 600px, height: 800px
      • 'large' – width: 1100px, height: 1100px
      • 'large_hd' – height: 1650px
For example
 {  media: {    cdn: 'mosaic02',    image_resolutions: ['thumbnail', 'medium']  } } 

Example

const sdk = await AtlasSDK.configure({
  client_id: 'CLIENT_ID',
  sales_channel: 'SALES_CHANNEL',
  is_sandBox: true,
  lang: 'en'
});
const article = await sdk.getArticleFamilies('AD112B0F6-A11');

atlasSDKClient.getGuestCheckout(checkoutId, token) ⇒ GetCheckoutResponse

Returns the complete details of the checkout: guest checkout object GetCheckoutResponse created using createGuestCheckout. Parameters checkoutId, token should be fetched from redirect URL after payment.

Kind: instance method of AtlasSDKClient
Returns: GetCheckoutResponse - guest checkout object
Access: public

Param Type Description
checkoutId String Id of guest checkout object
token String Token for checkout completion.

atlasSDKClient.createGuestOrder(checkoutId, token) ⇒ CreateOrderResponse

Creates an order for the guest chekout object based on checkoutId, token.

Kind: instance method of AtlasSDKClient
Returns: CreateOrderResponse - object with order information
Access: public

Param Type Description
checkoutId String Id of guest checkout object
token String

atlasSDKClient.getRecommendations(sku, [options]) ⇒ Array.<RecommendedArticle>

Fetches recommendations for an article based on a SKU.

Kind: instance method of AtlasSDKClient
Returns: Array.<RecommendedArticle> - return array of RecommendedArticle[] objects
Access: public

Param Type Description
sku String SKU of an article
[options] Object Configuration options:
  • {String} reco_id: UUID for recommendations API
  • {String} tracking_string: (Optional) The first time you call recommendations it's empty. The response will have it then and then you use it for every further call.
  • {String} type: Defines what type of recommendations should be returned. Multiple reco_types can be requested at the same time. In the result there will be no duplicate recommendations. Available values : similar, cross_sell, add_on, more_of_the_same_brand, personalized, most_popular, tag_enabled
  • {String} reco_location: (Optional) Defines which reco location should be used. If not specified, it falls back to the one defined in the config
  • media:
    • {String} cdn: 'mosaic01' or 'mosaic02' (default is 'mosaic01')
    • {Array} image_resolutions: request media image with the different resolutions (default ['thumbnail', 'medium', 'large']):
      • 'thumbnail' – width: 78px
      • 'thumbnail_hd' – width: 76px
      • 'small' – width: 135px
      • 'small_hd' – width: 270px
      • 'medium' – width: 300px, height: 400px
      • 'medium_sd' – width: 480px
      • 'medium_hd' – width: 600px, height: 800px
      • 'large' – width: 1100px, height: 1100px
      • 'large_hd' – height: 1650px
  • {Object} filters: (Optional) receives filter type as key and its value can be {Array} or {String} (default is {}) For example
        {      '-filter_gender': 'FEMALE',      'brand_code': ['AN1', 'N12', 'PU1'],    }    
For example
 {  reco_id: 'UUUID',  tracking_string: 'SOME_TRACKING_STRING',  reco_location: 'some_reco_location',  media: {    cdn: 'mosaic02',    image_resolutions: ['thumbnail', 'medium']  },  filters: {    '-filter_gender': 'FEMALE'    'brand_code': ['AN1', 'N12', 'PU1'],  } } 

Example

const sdk = await AtlasSDK.configure({
  client_id: 'CLIENT_ID',
  sales_channel: 'SALES_CHANNEL',
  is_sandBox: true
});
const recos = await sdk.getRecommendations('AD112B0F6-A11', {
   reco_id: 'UUID',
   tracking_string: 'TRACK',
   media: {
     cdn: 'mosaic02',
     image_resolutions: ['thumbnail', 'medium']
   },
   filters: {
     '-filter_gender': 'FEMALE'
     'brand_code': ['AN1', 'N12', 'PU1'],
   }
});

atlasSDKClient.createGuestCheckout(json) ⇒ CreateOrderRedirectResponse

Creates guest checkout object with payload.

Kind: instance method of AtlasSDKClient
Returns: CreateOrderRedirectResponse - response containing redirectURL that should be used to go to the payment.
Access: public

Param Type Description
json Object JSON payload

atlasSDKClient.getCheckoutCustomer(token) ⇒ CheckoutCustomer

Returns customer object CheckoutCustomer. Parameters customer token needed to fetch customer object.

Kind: instance method of AtlasSDKClient
Returns: CheckoutCustomer - customer object
Access: public

Param Type Description
token String customer OAuth2 token

atlasSDKClient.getCheckoutAddresses(token) ⇒ CheckoutAddress

Returns customer addresses CheckoutAddress. Parameters customer token needed to fetch customer object.

Kind: instance method of AtlasSDKClient
Returns: CheckoutAddress - CheckoutAddress array
Access: public

Param Type Description
token String customer OAuth2 token

atlasSDKClient.getCheckoutCarts(token, headers) ⇒ CartsResponse

Returns a customer's cart(s)

Kind: instance method of AtlasSDKClient
Returns: CartsResponse - - carts

Param Type Description
token String
headers Object additional headers that will override the default ones

atlasSDKClient.createCheckoutCart(json, token, options) ⇒ CartResponse

Creates Zalando customer cart

Kind: instance method of AtlasSDKClient
Returns: CartResponse - - customer cart

Param Type Description
json CreateCartRequest cart to create
token String customer OAuth2 token
options Object additional headers, rawResponse that will override the default ones

atlasSDKClient.getCheckoutCart(cartId, token) ⇒ CartResponse

Returns a cart by id

Kind: instance method of AtlasSDKClient
Returns: CartResponse - - cart

Param Type Description
cartId String cart ID to get
token String

atlasSDKClient.putCheckoutcart(json, cartId, token, headers) ⇒ CartResponse

Updates existing cart by id

Kind: instance method of AtlasSDKClient
Returns: CartResponse - - updated cart

Param Type Description
json CreateCartRequest cart object to update a cart with
cartId String id of the cart to be updated
token String
headers Object additional headers that will override the default ones

PickupPoint

Kind: global class

new PickupPoint(name, id, memberId)

Param Type Description
name String name of the pick up point
id String id of the pickup point
memberId String member id of the pickpup point

AddressSchema

Baseclass for Address model

Kind: global class

new AddressSchema(email, gender, firstName, lastName, street, zip, city, countryCode, pickupPoint)

Param Type Description
email String email of a customer.
gender String gender of the customer (FEMALE / MALE)
firstName String first name of the customer
lastName String last name of the customer
street String street of the address
zip String zip code of the address
city String city of the address
countryCode String country of the address
pickupPoint PickupPoint pickup point of the address (Optional because only valid in shipping addresses)

CheckoutAddressSchema

Baseclass for CheckoutAddress model

Kind: global class

new CheckoutAddressSchema(customerNumber, email, gender, firstName, lastName, street, zip, city, countryCode, pickupPoint, defaultBilling, defaultShipping)

Param Type Description
customerNumber String customer number
email String email of a customer.
gender String gender of the customer (FEMALE / MALE)
firstName String first name of the customer
lastName String last name of the customer
street String street of the address
zip String zip code of the address
city String city of the address
countryCode String country of the address
pickupPoint PickupPoint pickup point of the address (Optional because only valid in shipping addresses)
defaultBilling Boolean is this address the default billing address
defaultShipping Boolean is this address the default shipping address

NormalizedAddress

Baseclass for NormalizedAddress model

Kind: global class

new NormalizedAddress(street, zip, city, countryCode)

Param Type Description
street String street of the address
zip String zip code of the address
city String city of the address
countryCode String country of the address

CheckedAddress

Baseclass for CheckedAddress model

Kind: global class

new CheckedAddress(status, normalizedAddress)

Param Type Description
status String status of the address check
normalizedAddress NormalizedAddress the normalized address

Brand

Class for Brand model.

Kind: global class

new Brand(name)

Param Type Description
name String name of brand.

Partner

Class for Partner model.

Kind: global class

new Partner(id, name, detailURL)

Param Type Description
id String id of partner.
name String name of partner.
detailURL String URL of partner.

PriceSchema

Class for Article Unit Price model.

Kind: global class

new PriceSchema(amount, currency)

Param Type Description
amount number amount of price.
currency String currency of price.

Unit

Class for Article Unit model.

Kind: global class

new Unit(id, size, price, originalPrice, available, stock, partner, media)

Param Type Description
id String id of article.
size String size of article.
price Price price of article.
originalPrice Price price of article.
available boolean whether the unit is available or not.
stock number
partner Partner
media Media

Attribute

Class for Article Unit Attribute model.

Kind: global class

new Attribute(name, category, subCategory, values)

Param Type Description
name String name of attribute.
category String category of attribute.
subCategory String sub-category of attribute.
values Array.<String> values of attribute.

EnrichmentAttribute

Class for Article Unit EnrichmentAttribute model.

Kind: global class

new EnrichmentAttribute(key, value)

Param Type Description
key String name of enrichment attribute.
value Array.<String> values of enrichment attribute.

TargetGroups

Class for TargetGroups model.

Kind: global class

new TargetGroups(gender, age, domain, ageRange)

Param Type Description
gender Array.<String> The targeted gender group. Can be FEMALE or MALE. Unisex articles will have both.
age Array.<String> The targeted age group. Current values are: ADULT, BABY, KID, TEEN
domain Array.<String> The target domain. Can be: DEFAULT, GREEN, LIFESTYLE, MATERNITY, PREMIUM, OVERSIZE, SPORTS
ageRange Array.<String> Current values: Under 20, 20-29, 30-39, 40-49, Over 50

ArticleImage

Class for ArticleImage model.

Kind: global class

new ArticleImage(order, catalog, catalogHD, detail, detailHD, large, largeHD)

Param Type Description
order Number order number of image used for sorting.
catalog String URL of catalog image.
catalogHD String URL of HD catalog image.
detail String URL of details image.
detailHD String URL of HD details image.
large String URL of large image.
largeHD String URL of HD large image.

Media

Class for Media model.

Kind: global class

new Media(images)

Param Type Description
images ArticleImage array of images.

Item

Class for CartItem model

Kind: global class

new Item(sku, quantity)

Param Type Description
sku String SKU of item.
quantity Number Quantity of item.

ItemWithPrice

Class for CartItem model

Kind: global class

new ItemWithPrice(sku, configSku, quantity, price)

Param Type Description
sku String SKU of item.
configSku String Config SKU of the item.
quantity Number Quantity of item.
price Price pirce of the item

Payment

Class for Payment model

Kind: global class

new Payment(method, selectionPageUrl, metadata)

Param Type Description
method String Payment Method type.
selectionPageUrl String URL of the payment selection page.
metadata Object Metadata for payment.

new Payment(selected, selectionPageUrl)

Param Type Description
selected SelectedPayment the selected payment.
selectionPageUrl String URL of the payment selection page.

Delivery

Class for Delivery model'

Kind: global class

new Delivery(service, cost, earliest, latest, options)

Param Type Description
service String the delivery service.
cost Price the delivery cost.
earliest String Delivery earliest date.
latest String Delivery latest date.
options Array.<String> the delivery options.

ReviewRatingDistribution

Class for ReviewRatingDistribution.

Kind: global class

new ReviewRatingDistribution(count)

Param Type Description
level. String
count Number count of reviews distribution.

ReviewRating

Class for ReviewRating.

Kind: global class

new ReviewRating(average, distribution)

Param Type Description
average Number average rating of Article reviews.
distribution ReviewRatingDistribution distribution of reviews.

ReviewRecommendations

Class for ReviewRecommendations.

Kind: global class

new ReviewRecommendations(total, positive)

Param Type Description
total Number total number of Article reviews.
positive Number number of positive reviews.

ReviewSummary

Class for ReviewSummary.

Kind: global class

new ReviewSummary(total, rating, recommendations)

Param Type Description
total Number total number of Article reviews.
rating ReviewRating average rating of Article review.
recommendations ReviewRecommendations recommendations of Article review.

ReviewEntry

Class for ReviewEntry.

Kind: global class

new ReviewEntry(name, title, description, rating, recommends, created)

Param Type Description
name String name of Article reviewer.
title String title of Article review.
description String description of Article review.
rating Number rating of Article review.
recommends Boolean boolean if the reviewer recommends or not.
created String created timestamp of Article review.

Reviews

Class for Article Reviews.

Kind: global class

new Reviews(summary, entries)

Param Type Description
summary ReviewSummary summary of Article review.
entries Array.<ReviewEntry> entries of Article review.

Image

Class for Image model.

Kind: global class

new Image(type, mediaCharacter, resolutions)

Param Type Description
type String Type of the media item, e.g. 'IMAGE', 'IMAGE_360'
mediaCharacter String Media Character descriptor with meta information about image, for example 'MODEL' image that indicates that this media item contains model image URL.
resolutions Object Requested resolutions of the media item.

Video

Class for Video model.

Kind: global class

new Video(type, mediaCharacter, url)

Param Type Description
type String Type of the media item, e.g. 'VIDEO', 'VIDEO_HD', 'VIDEO_THUMBNAIL', 'VIDEO_SMALL'
mediaCharacter String Media Character descriptor with meta information about video, for example 'MODEL' image that indicates that this media item contains model image URL.
url String An absolute URL to the image

Article

Class for Article model

Kind: global class

new Article(id, name, color, silhouetteCode, supplierColor, productGroup, detailUrl, brand, units, images, videos, attributes, enrichmentAttributes, targetGroups, infos, review)

Param Type Description
id String id of the article.
name String name of the article.
color String color of the article.
silhouetteCode String silhouette code of the article.
supplierColor String color of the article from supplier.
productGroup String product group of the article.
detailUrl String product detail url of the article.
brand Brand brand of the article.
units Array.<Unit> size, price and stock availability from the article.
images Array.<Image> Array of article images.
videos Array.<Video> Array of article videos.
attributes Array.<Attribute> characteristics of the article.
enrichmentAttributes Array.<EnrichmentAttributes> variable generic attributes.
targetGroups TargetGroups the targeted groups of the article.
infos Array.<String> generic article description.
review Array.<Reviews> article reviews.

ArticleFamily

Class for ArticleFamily model

Kind: global class

new ArticleFamily(id, color, supplierColor, lowestPrice, images)

Param Type Description
id String id of the article.
color String color of the article.
supplierColor String color of the article from supplier.
lowestPrice Price lowestPrice of article.
images Array.<Image> Array of article images.

DiscountSchema

Class for Discount model

Kind: global class

new DiscountSchema(grossTotal, taxTotal)

Param Type Description
grossTotal Price gross total of the discount.
taxTotal Price tax total of the discount.

CheckoutCouponDiscount

Class for Checkout Discount model

Kind: global class

new CheckoutCouponDiscount(remaining, gross, tax)

Param Type Description
remaining Price remaining amount.
gross Price gross total of the discount.
tax Price tax total of the discount.

DeliveryRequest

Class for Delivery Request model

Kind: global class

new DeliveryRequest(service)

Param Type Description
service String the delivery service.

CreateCartRequest

Class for Cart Request model

Kind: global class

new CreateCartRequest(items)

Param Type Description
items Items a list of items.

SelectedPayment

Class for Selected Payment model

Kind: global class

new SelectedPayment(method, metadata, externalPayment)

Param Type Description
method String Payment Method type.
metadata Object Metadata for payment.
externalPayment Boolean is an external payment provider used.

Payment

Class for Payment model

Kind: global class

new Payment(method, selectionPageUrl, metadata)

Param Type Description
method String Payment Method type.
selectionPageUrl String URL of the payment selection page.
metadata Object Metadata for payment.

new Payment(selected, selectionPageUrl)

Param Type Description
selected SelectedPayment the selected payment.
selectionPageUrl String URL of the payment selection page.

CheckoutCouponDetails

Class for Checkout Coupon Details model

Kind: global class

new CheckoutCouponDetails(coupon, warning, error, discount)

Param Type Description
coupon String the coupon.
warning String warnings regardings coupons.
error String errors regardings coupons.
discount CheckoutCouponDiscount the discount.

CartResponse

Class for Cart Response model

Kind: global class

new CartResponse(id, items, itemsOutOfStock, delivery, grossTotal, taxTotal, totalDiscount)

Param Type Description
id String the response id.
items ItemWithPrice the items with price.
itemsOutOfStock String a list of items that are out of stock.
delivery Delivery the delivery information.
grossTotal Price the gross total.
taxTotal Price the tax total.
totalDiscount DiscountSchema the total discount.

CartsResponse

Class for Carts Response model

Kind: global class

new CartsResponse(id, carts)

Param Type Description
id String the response id.
carts Array.<CartResponse> the requested carts.

CreateCheckoutRequest

Class for Checkout Request model

Kind: global class

new CreateCheckoutRequest(id, billingAddressId, billingAddress, shippingAddressId, shippingAddress, delivery, coupons)

Param Type Description
id String the cart id.
billingAddressId String the id of the billing address.
billingAddress Address the billing address.
shippingAddressId String the id of the shipping address.
shippingAddress Address the shipping address.
delivery DeliveryRequest the desired delivery type.
coupons String a coupon.

CheckoutResponse

Class for Checkout Response model

Kind: global class

new CheckoutResponse(id, customerNumber, cartId, billingAddress, shippingAddress, delivery, couponDetails, payment)

Param Type Description
id String the response id.
customerNumber String the customer number.
cartId String the id of the cart id.
billingAddress Address the billing address.
shippingAddress Address the shipping address.
delivery Delivery the delivery information.
couponDetails CheckoutCouponDetails the coupon details.
payment Payment the payment selection.

PutCheckoutRequest

Class for Put Checkout Request model

Kind: global class

new PutCheckoutRequest(billingAddressId, billingAddress, shippingAddressId, shippingAddress, delivery, coupons)

Param Type Description
billingAddressId String the id of the billing address.
billingAddress Address the billing address.
shippingAddressId String the id of the shipping address.
shippingAddress Address the shipping address.
delivery DeliveryRequest the desired delivery type.
coupons String a coupon.

CheckoutOrderRequest

Class for Checkout Order Request model

Kind: global class

new CheckoutOrderRequest(checkoutId)

Param Type Description
checkoutId String the id of the checkout.

SalesChannel

SalesChannel class struct

Kind: global class

new SalesChannel(source)

Param Type Description
source Object Initialisation object for SalesChannel

Recommendations

Recommendations class struct

Kind: global class

new Recommendations(source)

Param Type Description
source Object Initialisation object for Recommendations

Config

Config class struct

Kind: global class

new Config(source)

Param Type Description
source Object Initialisation object for Config

Example

const source = {
  catalog_api_url: 'https://catalog_api.com/api',
  checkout_api_url: 'https://checkout_api.com/api',
  oauth2_provider_url: 'https://oauth2_provider.com/api',
  sales_channel: {
    locale: 'de_DE',
    channel: '11111111-1111-1111-1111-111111111111',
    toc_url: 'https://m.zalando.de/agb/'
  },
  recommendations: {
    location: 'my_app_pdp',
    type: 'similar',
    channel: 'myapp'
  }
};

const config = new Config(source);

GuestCustomer

Class for Guest Customer model

Kind: global class

new GuestCustomer(email, subscribeNewsletter)

Param Type Description
email String the id of the billing address.
subscribeNewsletter Boolean subscribe to the newsletter.

CheckoutCustomer

Class for Guest Customer model

Kind: global class

new CheckoutCustomer(customerNumber, customerHash, gender, firstName, lastName, email)

Param Type Description
customerNumber String the customer number.
customerHash String the customer hash.
gender String the gender.
firstName String the first name.
lastName String the last name.
email String the email address.

Cart

Cart

Kind: global class

new Cart(items, itemsOutOfStock, grossTotal, taxTotal)

Class for Cart model

Param Type Description
items Array.<Item> Array of CartItem.
itemsOutOfStock Array.<String> Array of simple SKUs for CartItems which are out of stock.
grossTotal Price Gross Total Price.
taxTotal Price Tax Total Price.

CreateOrderRequest

Class for CreateOrderRequest model

Kind: global class

new CreateOrderRequest(customer, billingAddress, shippingAddress, cart, payment)

Param Type Description
customer Customer Customer object.
billingAddress Address Billing GuestAddress of Order.
shippingAddress Address Shipping GuestAddress of Order.
cart Cart Cart of Order.
payment Payment Payment of Order.

CreateOrderResponse

Class for CreateOrderResponse model

Kind: global class

new CreateOrderResponse(orderNumber, customerNumber, billingAddress, shippingAddress, grossTotal, taxTotal, created, externalPaymentURL)

Param Type Description
orderNumber String Order Number.
customerNumber String Customer Number.
billingAddress Address Billing GuestAddress of Order.
shippingAddress Address Shipping GuestAddress of Order.
grossTotal Price Gross Total Price.
taxTotal Price Tax Total Price.
created String Date/Time when the order was created.
externalPaymentURL String URL of Payment.

CreateOrderRedirectResponse

Class for CreateOrderRedirectResponse model

Kind: global class

new CreateOrderRedirectResponse(url)

Param Type Description
url String Redirect URL.

GetCheckoutResponse

Class for GetCheckoutResponse model

Kind: global class

new GetCheckoutResponse(cart, billingAddress, shippingAddress, payment, delivery)

Param Type Description
cart Cart Cart of Order.
billingAddress Address Billing GuestAddress of Order.
shippingAddress Address Shipping GuestAddress of Order.
payment Payment Payment of Order.
delivery Delivery the delivery information.

OrderResponse

Class for Order Response model

Kind: global class

new OrderResponse(orderNumber, billingAddress, shippingAddress, grossTotal, taxTotal, created, externalPaymentURL)

Param Type Description
orderNumber String the order number.
billingAddress Address the billing address.
shippingAddress Address the shipping address.
grossTotal Price gross total of the discount.
taxTotal Price tax total of the discount.
created String creation date.
externalPaymentURL String the payment URL.

CheckoutApiOrderResponseSchema

Class for Checkout Order Response model

Kind: global class

new CheckoutApiOrderResponseSchema(customerNumber, orderNumber, billingAddress, shippingAddress, grossTotal, taxTotal, created, externalPaymentURL)

Param Type Description
customerNumber String the customer number.
orderNumber String the order number.
billingAddress Address the billing address.
shippingAddress Address the shipping address.
grossTotal Price gross total of the discount.
taxTotal Price tax total of the discount.
created String creation date.
externalPaymentURL String the payment URL.

CheckoutOrder

Class for Guest Customer model

Kind: global class

new CheckoutOrder(orderNumber, customerNumber, grossTotal, created, detailUrl)

Param Type Description
orderNumber String the order number.
customerNumber String the customer number.
grossTotal Price gross total of the discount.
created String creation date.
detailUrl String the details URL.

RecommendedArticle

Class for Recommended Article model

Kind: global class

new RecommendedArticle(id, tracking_string, name, lowestPrice, brand, images, videos, units)

Param Type Description
id String id of article.
tracking_string String the tracking string to help with recommendations
name String name of article.
lowestPrice Price lowestPrice of article.
brand Brand brand of article.
images Array.<Image> Array of article images.
videos Array.<Video> Array of article videos.
units Array.<Unit> Array of article units.

configCache

A temporary fix to handle the current high load capacity

Kind: global constant

fetchEndpoint(endpoint) ⇒ Promise

Calls the given endpoint using fetch and intercepts the response via various operations

Kind: global function
Returns: Promise - Promise after resolving or rejecting the request.

Param Type Description
endpoint Object endpoint object.

Contact

For any inquiry, please contact Team Atlas via team-atlas@zalando.de

LICENSE

The MIT License (MIT) Copyright © 2016 Zalando SE, https://tech.zalando.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.