@rye-api/rye-sdk
TypeScript icon, indicating that this package has built-in type declarations

1.3.0 • Public • Published

Rye SDK

The Rye SDK provides convenient access to the Rye API via the Rye client from which users can make queries and mutations easily.

Installation

Install the package with:

npm install @rye-api/rye-sdk
# or
yarn add @rye-api/rye-sdk

Usage

Client creation

The client needs to be created with your account's API authorization header and Shopper IP, which is available in the Rye Console.

// Production
const ryeClient = new RyeClient('<AUTH_HEADER>', '<SHOPPER_IP>');

// Staging
const ryeClient = new RyeClient('<AUTH_HEADER>', '<SHOPPER_IP>', ENVIRONMENT.STAGING);

Mutations

  1. requestProductByURL
const result = await ryeClient.requestProductByUrl({
  input: {
    url: 'https://www.amazon.com/dp/B00A2KD8NY',
    marketplace: Marketplace.Amazon,
  },
});
  1. requestStoreByURL
const result = await ryeClient.requestStoreByURL({
  input: {
    url: 'https://rye-test-store.myshopify.com',
  },
});
  1. createCart
// Create cart without buyer identity
const result = await ryeClient.createCart({
  input: {
    items: {
      amazonCartItemsInput: [
        {
          quantity: 1,
          productId: 'B007W3DDUW',
        },
      ],
    },
    buyerIdentity: {
      firstName: '<FIRST_NAME>',
      lastName: '<LAST_NAME>',
      email: '<EMAIL>',
      phone: '<PHONE>',
      address1: '<ADDRESS_1>',
      address2: '<ADDRESS_2>',
      city: '<CITY>',
      provinceCode: '<PROVINCE_CODE>',
      countryCode: '<COUNTRY_CODE>',
      postalCode: '<POSTAL_CODE>',
    },
  },
});

// Create cart with buyer identity
const result = await ryeClient.createCart({
  input: {
    items: {
      amazonCartItemsInput: [
        {
          quantity: 1,
          productId: 'B007W3DDUW',
        },
      ],
    },
  },
  fetchBuyerIdentity: false, // Set to true to fetch buyer identity
  fetchOffer: false, // Set to true to fetch offers for each store
  fetchCartLines: false, // Set to true to fetch cart lines
  fetchShippingMethods: false, // Set to true to fetch shipping methods
});
  1. addCartItems
const result = await ryeClient.addCartItems({
  input: {
    id: '<CART_ID>',
    items: {
      shopifyCartItemsInput: [
        {
          quantity: 1,
          variantId: '44346795295022',
        },
      ],
    },
  },
});
  1. deleteCartItems
const result = await ryeClient.deleteCartItems({
  input: {
    id: '<CART_ID>',
    items: {
      shopifyProducts: [
        {
          variantId: '44346795295022',
        },
      ],
    },
  },
});
  1. updateCartItems
const result = await ryeClient.updateCartItems({
  input: {
    id: '<CART_ID>',
    items: {
      amazonCartItemsInput: [
        {
          productId: 'B007W3DDUW',
          quantity: 2,
        },
      ],
    },
  },
});
  1. updateCartBuyerIdentity
const result = await ryeClient.updateCartBuyerIdentity({
  input: {
    id: '<CART_ID>',
    buyerIdentity: {
      firstName: '<FIRST_NAME>',
      lastName: '<LAST_NAME>',
      email: '<EMAIL>',
      phone: '<PHONE>',
      address1: '<ADDRESS_1>',
      address2: '<ADDRESS_2>',
      city: '<CITY>',
      provinceCode: '<PROVINCE_CODE>',
      countryCode: '<COUNTRY_CODE>',
      postalCode: '<POSTAL_CODE>',
    },
  },
  fetchOffer: false, // Set to true to fetch offers for each store
  fetchCartLines: false, // Set to true to fetch cart lines
  fetchShippingMethods: false, // Set to true to fetch shipping methods
});
  1. updateCartSelectedShippingOptions
const result = await ryeClient.updateCartSelectedShippingOptions({
  input: {
    id: '<CART_ID>',
    shippingOptions: [
      {
        shippingId: '55cfdaa8c7702fb7f57be90',
        store: 'rye-dev-store.myshopify.com',
      },
    ],
  },
  fetchBuyerIdentity: false, // Set to true to fetch buyer identity
  fetchOffer: false, // Set to true to fetch offers for each store
  fetchCartLines: false, // Set to true to fetch cart lines
  fetchShippingMethods: false, // Set to true to fetch shipping methods
});
  1. submitCart
const result = await ryeClient.submitCart({
  input: {
    id: '<CART_ID>',
    token: '<PAYMENT_TOKEN>',
    billingAddress: {
      firstName: '<FIRST_NAME>',
      lastName: '<LAST_NAME>',
      email: '<EMAIL>',
      phone: '<PHONE>',
      address1: '<ADDRESS_1>',
      address2: '<ADDRESS_2>',
      city: '<CITY>',
      provinceCode: '<PROVINCE_CODE>',
      countryCode: '<COUNTRY_CODE>',
      postalCode: '<POSTAL_CODE>',
    },
  },
});
  1. removeCart
const result = await ryeClient.removeCart({
  input: {
    id: '<CART_ID>',
  },
});

Queries

  1. productByID
const result = await ryeClient.getProductById({
  input: {
    id: 'B007W3DDUW',
    marketplace: 'AMAZON',
  },
});
  1. productsByDomainV2
const result = await ryeClient.getProductsByDomainV2({
  input: {
    domain: 'hiutdenim.co.uk',
  },
  pagination: { limit: 3, offset: 2 },
});
  1. getCart
const result = await ryeClient.getCart({
  id: '<CART_ID>',
  fetchBuyerIdentity: false, // Set to true to fetch buyer identity
  fetchOffer: false, // Set to true to fetch offers for each store
  fetchCartLines: false, // Set to true to fetch cart lines
  fetchShippingMethods: false, // Set to true to fetch shipping methods
});
  1. orderByID
const result = await ryeClient.orderById({
  id: '<ORDER_ID>',
});
  1. checkoutByCartID
const result = await ryeClient.checkoutByCartId({
  id: '<CART_ID>',
  fetchBuyerIdentity: false, // Set to true to fetch buyer identity
  fetchOffer: false, // Set to true to fetch offers for each store
  fetchCartLines: false, // Set to true to fetch cart lines
  fetchShippingMethods: false, // Set to true to fetch shipping methods
});
  1. shopifyApp
const result = await ryeClient.getShopifyAppInformation({
  storeCanonicalDomain: 'dear-media-shop.myshopify.com',
});
  1. environmentToken
const result = await ryeClient.getEnvironmentToken();

Additional resources

Readme

Keywords

none

Package Sidebar

Install

npm i @rye-api/rye-sdk

Weekly Downloads

10

Version

1.3.0

License

MIT

Unpacked Size

1.08 MB

Total Files

119

Last publish

Collaborators

  • rye-api