inspira-shopify v8.8.0
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.
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago