0.1.13 • Published 3 years ago

appollo v0.1.13

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

Appollo SDK

Build Status

The Appollo SDK helps developers build a single eCommerce app that will be published across many eCommerce platforms through the Appollo platform.

The SDK includes methods for working with a merchant's:

  • Products
  • Orders
  • Customers
  • Collections
  • Variants
  • Billing (Charging for your app)

Installation using npm (recommended):

Run this command to install the package and adding it to your package.json:

$ npm install appollo --save

Usage:

Initializing

Import the module to get a constructor function for an Appollo object, then call it with new to instantiate an Appollo object with your own API Key and API Secret.

const Appollo = require("appollo");
const appollo = new Appollo(apiKey, apiSecret);

Merchant ID (Important)

Almost all methods will require a merchant ID. The merchant ID is the unique identifier for a merchant's store.

With Appollo you no longer have to worry about writing a new installation server for each platform you decide to distribute your app to. When a merchant attempts to install your app. we securely handle OAuth authentication for you, then redirect the merchant to your sign-up URL.

This is the sign-up url you provide through our dashboard. This is the url of your sign-up page.

When we redirect we will append some useful information as query parameters so that you can identify the user. You should parse these query parameters and save them.

Here's how you might parse the params:

const urlParams = new URLSearchParams(window.location.search);
const email = urlParams.get('merchant_email')
console.log(email);
// john.doe@email.com

const name = urlParams.get('merchant_name')
console.log(name);
// John Doe

const siteDomain = urlParams.get('merchant_shop')
console.log(siteDomain);
// empty woolworths.myshopify.com

const merchantId = urlParams.get('appollo_merchant_id')
console.log(storeId);
// storeId

Once a user installs your app, they are redirected to your sign-up page. You should make sure to prefill the sign-up form with the merchant's email (and name where applicable).

Make sure to save the merchantId to the user, so you can use it later.

Products

If your app interacts with a merchant's products, you can use our various methods to create, read, update and delete products.

When creating a product, you should use the following structure: | Property | Type | Description | | ------ | ------ | ---- | | description | string | Description of the product. | title | string | The title of the product. | type | string | Categorisation of the product | variants | array | Array of product variants. | media | array | Array of media objects. | tags | array | Store tags of the product. | brand | string | The brand of the product. | price | float | The price of the product. | weight | float | The weight of the product

The methods you can use for products are the following:

const Appollo = require("appollo");
const appollo = new Apppollo(apiKey, apiSecret);

appollo.getProducts(merchantId, limit, page)
.then(res => console.log(res))
// Get a list of products from a merchants store

appollo.getProduct(merchantId, productId)
.then(res => console.log(res))
// Get a particular product from a merchant store

appollo.createProduct(merchantId, product)
.then(res => console.log(res))
// Create a product within a merchant store

appollo.updateProduct(merchantId, product, productID)
.then(res => console.log(res))
// Update a product within a merchant store

appollo.deleteProduct(merchantId, productID)
.then(res => console.log(res))
// Delete a product within a merchant store

Orders

If your app interacts with a merchant's orders, you can use our various methods to create, read, update and delete orders.

When creating an order, you should use the order object structure given in https://docs.tryappollo.com/reference#create-order

The methods you can use for products are the following:

const Appollo = require("appollo");
const appollo = new Appollo(apiKey, apiSecret);

appollo.getOrders(merchantId, limit, page)
.then(res => console.log(res))
// Get a list of orders from a merchants store

appollo.getOrder(merchantId, orderId)
.then(res => console.log(res))
// Get a particular order from a merchant store

appollo.createOrder(merchantId, order)
.then(res => console.log(res))
// Create an order within a merchant store

appollo.updateOrder(merchantId, order, orderID)
.then(res => console.log(res))
// Update an order within a merchant store

appollo.deleteProduct(merchantId, orderID)
.then(res => console.log(res))
// Delete an order within a merchant store

Customers

If your app interacts with a merchant's customers, you can use our various methods to create, read, update and delete customers.

When creating a customer, you should use the customer object structure given in https://docs.tryappollo.com/reference#create-customer

The methods you can use for products are the following:

const Appollo = require("appollo");
const appollo = new Appollo(apiKey, apiSecret);

appollo.getCustomers(merchantId, limit, page)
.then(res => console.log(res))
// Get a list of customers from a merchants store

appollo.getCustomer(merchantId, customerId)
.then(res => console.log(res))
// Get a particular customer from a merchant store

appollo.createCustomer(merchantId, customer)
.then(res => console.log(res))
// Create a customer within a merchant store

appollo.updateCustomer(merchantId, customer, customerID)
.then(res => console.log(res))
// Update a customer within a merchant store

appollo.deleteCustomer(merchantId, customerID)
.then(res => console.log(res))
// Delete a customer within a merchant store

Collections

A commonly used API is the Collections API. A collection is a group of products that are commonly displayed together. An example is "Summer clothing" or "Streetwear".

If your app interacts with a merchant's collections, you can use our various methods to create, read, update and delete collections.

When creating a collection, you should use the collection object structure given in https://docs.tryappollo.com/reference#create-collection

The methods you can use for collections are the following:

const Appollo = require("appollo");
const appollo = new Appollo(apiKey, apiSecret);

appollo.getCollections(merchantId, limit, page)
.then(res => console.log(res))
// Get a list of collections from a merchants store

appollo.getCollection(merchantId, collectionId)
.then(res => console.log(res))
// Get a particular collection from a merchant store

appollo.createCollection(merchantId, collection)
.then(res => console.log(res))
// Create a collection in a merchant store

appollo.updateCollection(merchantId, collection, collectionID)
.then(res => console.log(res))
// Update a collection within a merchant store

appollo.deleteCollection(merchantId, collectionID)
.then(res => console.log(res))
// Delete a collection within a merchant store

appollo.addProductsToCollection(merchantId, products, collectionID)
.then(res => console.log(res))
// Add a list of products to a collection

appollo.removeProductsFromCollection(merchantId, products, collectionID)
.then(res => console.log(res))
// Remove a list of products from a collection

Variants

A commonly used API is the Variants API. A variant is a particular version of a product within a store. For example the product could be "Summer dress" and a variant would be the "Red Summer Dress".

If your app interacts with a merchant's variants, you can use our various methods to create, read, update and delete variants.

When creating a variant, you should use the variant object structure given in https://docs.tryappollo.com/reference#create-variant

The methods you can use for variants are the following:

const Appollo = require("appollo");
const appollo = new Appollo(apiKey, apiSecret);

appollo.getVariants(merchantId, productId, limit, page)
.then(res => console.log(res))
// Get a list of variants from a merchants store

appollo.getVariant(merchantId, productId, variantId)
.then(res => console.log(res))
// Get a particular variant from a merchant store

appollo.createVariant(merchantId, variant, productId)
.then(res => console.log(res))
// Create a variant of a product in a merchant store

appollo.updateVariant(merchantId, variant, productId, variantId)
.then(res => console.log(res))
// Update a variant within a merchant store

appollo.deleteVariant(merchantId, productId, variantId)
.then(res => console.log(res))
// Delete a variant of a product within a merchant store

Charging for your app

A commonly used API is the Billing API.

If you plan to launch a paid app to either Wix or Shopify (or both), you will need to use the Appollo billing API.

The billing API returns a checkout url, you should redirect your users to this url where they will be asked to pay for your app at the platform.

There are two possible ways you can charge your app users, either through our recurringCharge or singleCharge method. You should make sure to set the pricing of your app within the Appollo dashboard.

You should also make sure to get the unique ChargeId for each price from the Appollo dashboard.

The methods you can use for billing are the following:

const Appollo = require("appollo");
const appollo = new Appollo(apiKey, apiSecret);

appollo.createSingleCharge(merchantId, chargeId)
.then(res => console.log(res))
// Get a checkoutUrl for a single charge

appollo.createRecurringCharge(merchantId, chargeId)
.then(res => console.log(res))
// Get a checkoutUrl for a recurring charge

Documentation

Reference documentation is available at: https://docs.tryappollo.com

Getting help

We love to hear from you so if you have questions, comments or find a bug in the project, let us know at support@tryappollo.com

0.1.13

3 years ago

0.1.12

3 years ago

0.1.11

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago

0.0.99

3 years ago

0.0.98

3 years ago

0.0.97

3 years ago

0.0.96

3 years ago

0.0.95

3 years ago

0.0.94

3 years ago

0.0.93

3 years ago

0.0.92

3 years ago

0.0.91

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago