shopify
Shopify is an e-commerce platform.
Usage
import { shopify } from 'netzo/apis/shopify.ts'
const api = shopify({
storeName: Deno.env.get('SHOPIFY_STORE_NAME'),
apiVersion: Deno.env.get('SHOPIFY_API_VERSION'),
apiKey: Deno.env.get('SHOPIFY_API_KEY'),
})
Configuration
The shopify
factory function expects an object with the following, and returns an object with an API client api
.
Param | Type | Default | Description |
---|---|---|---|
storeName | string | Deno.env.get('SHOPIFY_STORE_NAME') | the store name |
apiKey | string | Deno.env.get('SHOPIFY_API_KEY') | the api key to use for authentication |
apiVersion | string | Deno.env.get('SHOPIFY_API_VERSION') | the api version |
Examples
The following examples assume you have created an api client instance.
Find customers
Find all customers that match the query.
const query: QueryCustomers = {}
const result = await api['customers.json'].get<Customers>(query)
const resultData = result.customers
Get customer
Get a customer by id.
To limit the search to certain fields, specify a comma-separated list of field names.
const query: { fields: string } = {}
const result = await api.customers[`${CUSTOMER_ID}.json`].get<Customer>(fields)
const resultData = result.customer
Find customer's orders
Find all orders belonging to a specific customer.
const query: OrderStatus = 'any'
const result = await api.customers[CUSTOMER_ID]['orders.json'].get<OrdersByCustomer>(query)
const resultData = result.orders
Add customer
Add a new customer.
const data: DataAddOrUpdateCustomer = {
customer: {
first_name: 'John',
last_name: 'Doe',
email: '[email protected]'
}
}
const result = await api['customers.json'].post<AddOrUpdateCustomerResult>(data)
const resultData = result.customer
Update customer
Update a customer by id.
const data: DataAddOrUpdateCustomer = {
customer: {
email: '[email protected]'
}
}
const result = await api.customers[`${CUSTOMER_ID}.json`].put<AddOrUpdateCustomerResult>(data)
const resultData = result.customer
Find orders
Find all orders that match the query.
const query: QueryOrders = {}
const result = await api['orders.json'].get<Orders>(query)
const resultData = result.orders
Get order
Get an order by id.
To limit the search to certain fields, specify a comma-separated list of field names.
const query: { fields: string } = {}
const result = await api.orders[`${ORDER_ID}.json`].get<Order>(fields)
const resultData = result.order
Find products
Find all products that match the query.
const query: QueryProducts = {}
const result = await api['products.json'].get<Products>(query)
const resultData = result.products
Get product
Get a product by id.
To limit the search to certain fields, specify a comma-separated list of field names.
const query: { fields: string } = {}
const result = await api.products[`${PRODUCT_ID}.json`].get<Product>(fields)
const resultData = result.product
Find payouts
Find all payouts that match the query.
const query: QueryPayouts = {}
const result = await api.shopify_payments['payouts.json'].get<Payouts>(query)
const resultData = result.payouts