How to use the @moltin/sdk.gateway function in @moltin/sdk

To help you get started, we’ve selected a few @moltin/sdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pveller / ecommerce-chatbot / indexes / populate.js View on Github external
'use strict';

const fs = require('fs');
const path = require('path');
const _ = require('lodash');
const request = require('request-promise-native');

const MoltinGateway = require('@moltin/sdk').gateway;
const Moltin = MoltinGateway({
  client_id: process.env.MOLTIN_CLIENT_ID,
  client_secret: process.env.MOLTIN_CLIENT_SECRET
});

if (!Moltin.Files) {
  // Moltin JS SDK does not support files operation in 3.3.0
  Moltin.Files = Object.setPrototypeOf(
    Object.assign({}, Moltin.Products),
    Moltin.Products
  );
  Moltin.Files.endpoint = 'files';
}

(async function() {
  // There are only 42 images in the AW catalog and the default pagination limit in Moltin API is 100
  const images = (await Moltin.Files.All()).data;
github moltin / vue-demo-store / src / services / moltin.js View on Github external
import { gateway as MoltinGateway } from '@moltin/sdk'

const Moltin = MoltinGateway({
  client_id: 'EdP3Gi1agyUF3yFS7Ngm8iyodLgbSR3wY4ceoJl0d2'
})

export default {

  getHomepageProducts () {
    return Moltin.Products.Filter({}).With('main_image').Limit(8).All()
  },

  findBySlug (slug) {
    return Moltin.Products.Filter({
      eq: {
        slug: slug
      }
    }).With(['main_image', 'brands']).Limit(1).All()
  },
github moltin / react-demo-store / src / moltin.js View on Github external
const MoltinGateway = require('@moltin/sdk').gateway;

let client_id = 'j6hSilXRQfxKohTndUuVrErLcSJWP15P347L6Im0M4';

if (process.env.REACT_APP_MOLTIN_CLIENT_ID) {
  client_id = process.env.REACT_APP_MOLTIN_CLIENT_ID;
}

const Moltin = MoltinGateway({
  client_id,
  application: 'react-demo-store'
});

export const GetProducts = () =>
  Moltin.Products.With('files, main_images, collections').All();

export const GetProduct = ID => Moltin.Products.Get(ID);

export const GetCategories = () => Moltin.Categories.With('products').All();

export const GetCategory = ID => Moltin.Categories.Get(ID);

export const GetCollections = () => Moltin.Collections.With('products').All();

export const GetBrands = () => Moltin.Brands.All();
github moltin / react-demo-store / src / utils / moltin.js View on Github external
const MoltinGateway = require('@moltin/sdk').gateway;

let client_id = 'j6hSilXRQfxKohTndUuVrErLcSJWP15P347L6Im0M4';

if (process.env.REACT_APP_MOLTIN_CLIENT_ID) {
  client_id = process.env.REACT_APP_MOLTIN_CLIENT_ID;
}

var exports = module.exports = {};

const Moltin = MoltinGateway({
  client_id,
  application: 'react-demo-store'
});

exports.GetProducts = function() {
  return Moltin.Products.With('files, main_images, collections').All()
};

exports.GetProduct = function(ID) {
  return Moltin.Products.Get(ID)
}

exports.GetCategories = function() {
  return Moltin.Categories.With('products').All()
}
github moltin / nextjs-demo-store / lib / moltin.js View on Github external
import { gateway as MoltinGateway } from '@moltin/sdk'

const Moltin = MoltinGateway({
  client_id:
    process.env.MOLTIN_CLIENT_ID || 'EdP3Gi1agyUF3yFS7Ngm8iyodLgbSR3wY4ceoJl0d2'
})

export const getProducts = () => Moltin.Products.With('main_image').All()

export const getProductById = id => Moltin.Products.With('main_image').Get(id)

export const addToCart = (cartId, productId, quantity) =>
  Moltin.Cart(cartId).AddProduct(productId, quantity)

export const getCartItems = id => Moltin.Cart(id).Items()

export const removeFromCart = (productId, cartId) =>
  Moltin.Cart(cartId).RemoveItem(productId)
github moltin / react-redux-moltin-boilerplate / src / utils / moltin.js View on Github external
const MoltinGateway = require('@moltin/sdk').gateway;

let client_id = 'j6hSilXRQfxKohTndUuVrErLcSJWP15P347L6Im0M4';

if (process.env.REACT_APP_MOLTIN_CLIENT_ID) {
  client_id = process.env.REACT_APP_MOLTIN_CLIENT_ID;
}

var exports = (module.exports = {});

const Moltin = MoltinGateway({
  client_id,
  application: 'react-demo-store'
});

exports.GetProducts = function(resources) {
  return Moltin.Products.With(resources).All();
};

exports.GetProduct = function(ID) {
  return Moltin.Products.Get(ID);
};

exports.GetCategories = function(resources) {
  return Moltin.Categories.With(resources).All();
};

@moltin/sdk

SDK for the Moltin eCommerce API

MIT
Latest version published 4 months ago

Package Health Score

48 / 100
Full package analysis

Popular @moltin/sdk functions

Similar packages