8.8.0 • Published 4 years ago

inspira-shopify v8.8.0

Weekly downloads
2
License
ISC
Repository
-
Last release
4 years ago

inspira-shopify

Shopify Rest API calls utility

HOW TO USE

npm install --save inspira-shopify

Use shopify rest calls

import ShopifyRest from 'inspira-shopify';


const inspiraShopify = new ShopifyRest('<your shop>.myshopify.com','<shopify token>');

//Override default options
const inspiraShopify = new ShopifyRest('<your shop>.myshopify.com','<shopify token>', {timeout:4000, retries: 3, debug: true, logger: mylogger});

//Create a customer example
inspiraShopify.customer.create(
    {email:'wakeeekm@gmail.com', verified_email: true, first_name:'hweweji', last_name:'eqwewwert', phone:'07470874486'})
    .catch((err) => { console.log( err)} )
    .then((result) => { console.log(result)});

Use shopify express Router

Set shopify endpoints for installing your app.

import { Router } from 'inspira-shopify';

...

const app = express();

...

function callback(token, shop, response, err) {
    //manage your shopify token and send response to the client
    if(err) { console.error(err)}
    response.sendFile( ... );
}

app.use('/shopify', new Router( 'secret', 'key', 'scopes', 'app base url', callback).buildRoutes());

Use Hmac utilities.

import { HmacUtils } from 'inspira-shopify';

...

router.post('/<someendpoint>', HmacUtils.jsonWebhookParser, async (req, res) => {
    const isHmacOk = await HmacUtils.checkHmac(req, 'SHOPIFY_SECRET');
    if(!isHmacOk) throw 'Hmac not correct';
    ...
});

...

Cache Shopify Calls

import { RestCacheWrapper } from 'inspira-shopify';

...
private static methodCached = new RestCacheWrapper<Response Type>(<Items to holds in cache>, <Shopify rest method to be cached>);

await methodCached.execute(...args);
...

SHOPIFY REST OPTIONS

  • timeout(ms): timeout while perfoming rest call. Default is 3000.
  • retries: How many times will the call tried. It will retry when it is a network error or a 5xx error.
  • debug: When debug is set to true it will log debug data. You must specify a logger.
  • logger: Logger object used for logging data.

And example of a logger can be:

//using console for building my logger 
const mylogger = {error: console.error, info: console.log};

new ShopifyRest('<your shop>.myshopify.com','<shopify token>', {timeout:4000, retries: 3, debug: true, logger: mylogger})

HOW TO PUBLISH

Push a change with a new version set in package.json and bitbucket pipeline will automatically publish a new npm package.

NOTE: To understand when the version number needs to change refer to npm documentation

Functionalities

  • Customers
    • getById
    • getByEmail
    • getByTag
    • getByLastNameContains
    • addAddress
    • removeAddress
    • updateAddress
    • addressAsDefault
    • replacesAddressAsDefault
    • addAddressAsDefault
    • create
    • update
    • get(numOfCustomers)
    • getMetafields
    • getMetafield
    • postMetafield
    • deleteMetafield
    • sendInvite
  • Inventory
    • setItemToTrackable
    • setQuantity
    • getLevel
    • getInventoryItemsOfProduct
    • adjustQuantityOfInventoryItem
    • adjustQuantity
    • setItemCostAndSkuToBe
    • setItemCostToBe
  • Draft Order
    • create
    • createAndSendInvoice
    • updateShippingAddress
  • Order
    • getFulfillments
    • createFulfillments
    • completeFulfillment
    • openFulfillment
    • cancelFulfillment
    • getById
    • addAdditionalAttribute
    • setTags
    • getAll
    • create
    • applyWeightAndCountryBasedShippingToOrder
    • getShippingByWeight
    • updateShippingAddress
  • OrderRisks
    • getFromOrderById
  • Product
    • getAll
    • getByTitle
    • getByHandle
    • getByProductType
    • getById
    • update
    • create
    • delete
    • get(numOfProducts)
    • getMetafields
    • getMetafield
    • saveOrUpdateMetafield
    • deleteMetafield
    • deleteMetafieldsByNamespace
  • Webhook
    • deleteAll
    • delete (By ID)
    • create
    • getAll
    • deleteByTopic
    • updateWebhooksAPI
  • Fulfillment Service
    • create
    • getAll
  • Shop
    • Shop details
    • getShippingRates
  • Collections
    • create
    • createCollect
    • getAll (limit 250)
    • delete
    • removeCollects (With TimerQueue)
  • Themes
    • getAll (limit 250)
    • getMainTheme (returns null if no theme has been found)
  • Template
    • get
    • put
  • Assets
    • put
  • Locations
    • getAll
  • Pages
    • post
    • put
    • postMetafields
  • Shopify express route needed for installing the App.
  • Shopify Hmac validation utilities.
  • Shopify Rest Utils.
  • Cache functionality.
8.8.0

4 years ago

8.7.0

4 years ago

8.6.6

4 years ago

8.6.5

4 years ago

8.6.3

4 years ago

8.6.2

4 years ago

8.6.4

4 years ago

8.6.1

4 years ago

8.6.0

4 years ago

8.5.0

4 years ago

8.4.1

4 years ago

8.4.0

4 years ago

8.3.2

4 years ago

8.3.1

4 years ago

8.1.1

4 years ago

8.2.0

4 years ago

8.3.0

4 years ago

8.1.0

4 years ago

8.0.0

4 years ago

7.5.0

4 years ago

7.3.1

4 years ago

7.4.0

4 years ago

7.3.0

4 years ago

7.2.0

4 years ago

7.1.6

4 years ago

7.1.5

4 years ago

7.1.4

4 years ago

7.1.3

4 years ago

7.1.2

4 years ago

7.1.1

4 years ago

7.1.0

4 years ago

6.13.0

4 years ago

7.0.0

4 years ago

7.0.2

4 years ago

7.0.1

4 years ago

6.12.0

4 years ago

6.10.2

4 years ago

6.10.1

4 years ago

6.10.0

4 years ago

6.10.3

4 years ago

6.9.0

4 years ago

6.8.0

4 years ago

6.8.3

4 years ago

6.8.2

4 years ago

6.8.4

4 years ago

6.7.0

4 years ago

6.6.0

4 years ago

6.5.0

4 years ago

6.4.0

4 years ago

6.3.0

4 years ago

6.2.0

4 years ago

6.1.0

4 years ago

6.0.0

4 years ago

5.7.3

4 years ago

5.7.2

4 years ago

5.7.1

4 years ago

5.7.0

4 years ago

5.6.1

4 years ago

5.6.0

4 years ago

5.5.0

4 years ago

5.4.0

4 years ago

5.3.2

4 years ago

5.3.1

4 years ago

5.3.0

4 years ago

5.2.0

4 years ago

5.0.2

5 years ago

5.0.1

5 years ago

4.5.1

5 years ago

4.5.0

5 years ago

4.4.2

5 years ago

4.4.1

5 years ago

4.4.0

5 years ago

4.3.0

5 years ago

4.2.0

5 years ago

4.1.2

5 years ago

4.1.1

5 years ago

4.1.0

5 years ago

4.0.5

5 years ago

4.0.4

5 years ago

4.0.3

5 years ago

4.0.2

5 years ago

4.0.1

5 years ago

4.0.0

5 years ago

3.8.9

5 years ago

3.8.8

5 years ago

3.8.7

5 years ago

3.8.6

5 years ago

3.8.5

5 years ago

3.8.4

5 years ago

3.8.3

5 years ago

3.8.2

5 years ago

3.8.1

5 years ago

3.8.0

5 years ago

3.7.0

5 years ago

3.6.1

5 years ago

3.6.0

5 years ago

3.5.0

5 years ago

3.4.9

5 years ago

3.4.8

5 years ago

3.4.7

5 years ago

3.4.6

5 years ago

3.4.5

5 years ago

3.4.4

5 years ago

3.4.3

5 years ago

3.4.2

5 years ago

3.4.1

5 years ago

3.4.0

5 years ago

3.3.2

5 years ago

3.3.1

5 years ago

3.3.0

5 years ago

3.2.0

5 years ago

3.1.0

5 years ago

3.0.9

5 years ago

3.0.8

5 years ago

3.0.7

5 years ago

3.0.6

5 years ago

3.0.5

6 years ago

3.0.4

6 years ago

3.0.3

6 years ago

3.0.2

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.0.7

6 years ago

2.0.6

6 years ago

2.0.5

6 years ago

2.0.4

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.9.2

6 years ago

1.9.1

6 years ago

1.9.0

6 years ago

1.8.8

6 years ago

1.8.7

6 years ago

1.8.6

6 years ago

1.8.5

6 years ago

1.8.4

6 years ago

1.8.3

6 years ago

1.8.2

6 years ago

1.8.1

6 years ago

1.8.0

6 years ago

1.7.9

6 years ago

1.7.8

6 years ago

1.7.6

6 years ago

1.7.5

6 years ago

1.7.4

6 years ago

1.7.3

6 years ago

1.7.2

6 years ago

1.7.1

6 years ago

1.7.0

6 years ago

1.6.7

6 years ago

1.6.6

6 years ago

1.6.5

6 years ago

1.6.4

6 years ago

1.6.3

6 years ago

1.6.2

6 years ago

1.6.1

6 years ago

1.6.0

6 years ago

1.5.0

6 years ago

1.4.2

6 years ago

1.4.1

6 years ago

1.4.0

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago