mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 14:44:05 -08:00
⚡ Minor improvements to Shopify-Node
This commit is contained in:
parent
520a456105
commit
f9970f7157
|
@ -1,6 +1,6 @@
|
|||
import {
|
||||
OptionsWithUri,
|
||||
} from 'request';
|
||||
} from 'request';
|
||||
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
|
@ -35,15 +35,13 @@ export async function shopifyApiRequest(this: IHookFunctions | IExecuteFunctions
|
|||
json: true
|
||||
};
|
||||
|
||||
console.log(options);
|
||||
|
||||
if (Object.keys(option).length !== 0) {
|
||||
Object.assign(options, option);
|
||||
}
|
||||
if (Object.keys(body).length === 0) {
|
||||
if (Object.keys(body).length === 0) {
|
||||
delete options.body;
|
||||
}
|
||||
if (Object.keys(query).length === 0) {
|
||||
if (Object.keys(query).length === 0) {
|
||||
delete options.qs;
|
||||
}
|
||||
try {
|
||||
|
@ -53,7 +51,7 @@ export async function shopifyApiRequest(this: IHookFunctions | IExecuteFunctions
|
|||
let message = '';
|
||||
if (typeof error.response.body.errors === 'object') {
|
||||
for (const key of Object.keys(error.response.body.errors)) {
|
||||
message+= error.response.body.errors[key];
|
||||
message += error.response.body.errors[key];
|
||||
}
|
||||
} else {
|
||||
message = `${error.response.body.errors} |`;
|
||||
|
@ -67,7 +65,7 @@ export async function shopifyApiRequest(this: IHookFunctions | IExecuteFunctions
|
|||
}
|
||||
|
||||
|
||||
export async function shopifyApiRequestAllItems(this: IHookFunctions | IExecuteFunctions| ILoadOptionsFunctions, propertyName: string, method: string, resource: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
export async function shopifyApiRequestAllItems(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, resource: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
|
@ -78,7 +76,7 @@ export async function shopifyApiRequestAllItems(this: IHookFunctions | IExecuteF
|
|||
do {
|
||||
responseData = await shopifyApiRequest.call(this, method, resource, body, query, uri, { resolveWithFullResponse: true });
|
||||
if (responseData.headers.link) {
|
||||
uri = responseData.headers['link'].split(';')[0].replace('<', '').replace('>','');
|
||||
uri = responseData.headers['link'].split(';')[0].replace('<', '').replace('>', '');
|
||||
}
|
||||
returnData.push.apply(returnData, responseData.body[propertyName]);
|
||||
} while (
|
||||
|
@ -88,7 +86,7 @@ export async function shopifyApiRequestAllItems(this: IHookFunctions | IExecuteF
|
|||
return returnData;
|
||||
}
|
||||
|
||||
export function keysToSnakeCase(elements: IDataObject[] | IDataObject) : IDataObject[] {
|
||||
export function keysToSnakeCase(elements: IDataObject[] | IDataObject): IDataObject[] {
|
||||
if (elements === undefined) {
|
||||
return [];
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export const orderOperations = [
|
||||
{
|
||||
|
@ -48,9 +48,9 @@ export const orderOperations = [
|
|||
|
||||
export const orderFields = [
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* order:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* order:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
|
@ -474,9 +474,9 @@ export const orderFields = [
|
|||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* order:delete */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* order:delete */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Order ID',
|
||||
name: 'orderId',
|
||||
|
@ -494,9 +494,9 @@ export const orderFields = [
|
|||
},
|
||||
required: true,
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* order:get */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* order:get */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Order ID',
|
||||
name: 'orderId',
|
||||
|
@ -540,9 +540,9 @@ export const orderFields = [
|
|||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* order:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* order:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
|
@ -790,9 +790,9 @@ export const orderFields = [
|
|||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* order:update */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* order:update */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Order ID',
|
||||
name: 'orderId',
|
||||
|
|
|
@ -4,14 +4,14 @@ import {
|
|||
|
||||
export interface IImage {
|
||||
id?: string;
|
||||
product_id?: string;
|
||||
position?: number;
|
||||
created_at?: string,
|
||||
updated_at?: string,
|
||||
width?: number;
|
||||
height?: number;
|
||||
src?: string;
|
||||
variant_ids?: number[];
|
||||
product_id?: string;
|
||||
position?: number;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
width?: number;
|
||||
height?: number;
|
||||
src?: string;
|
||||
variant_ids?: number[];
|
||||
}
|
||||
|
||||
export interface IPrice {
|
||||
|
@ -54,7 +54,7 @@ export interface IProduct {
|
|||
body_html?: string;
|
||||
handle?: string;
|
||||
images?: IImage[];
|
||||
options?: IDataObject[],
|
||||
options?: IDataObject[];
|
||||
product_type?: string;
|
||||
published_at?: string;
|
||||
published_scope?: string;
|
||||
|
|
|
@ -56,240 +56,240 @@ export class ShopifyTrigger implements INodeType {
|
|||
[
|
||||
{
|
||||
name: 'App uninstalled',
|
||||
value: 'app/uninstalled'
|
||||
value: 'app/uninstalled',
|
||||
},
|
||||
{
|
||||
name: 'Carts create',
|
||||
value: 'carts/create'
|
||||
value: 'carts/create',
|
||||
},
|
||||
{
|
||||
name: 'Carts update',
|
||||
value: 'carts/update'
|
||||
value: 'carts/update',
|
||||
},
|
||||
{
|
||||
name: 'Checkouts create',
|
||||
value: 'checkouts/create'
|
||||
value: 'checkouts/create',
|
||||
},
|
||||
{
|
||||
name: 'Checkouts delete',
|
||||
value: 'checkouts/delete'
|
||||
value: 'checkouts/delete',
|
||||
},
|
||||
{
|
||||
name: 'Checkouts update',
|
||||
value: 'checkouts/update'
|
||||
value: 'checkouts/update',
|
||||
},
|
||||
{
|
||||
name: 'Collection listings add',
|
||||
value: 'collection_listings/add'
|
||||
value: 'collection_listings/add',
|
||||
},
|
||||
{
|
||||
name: 'Collection listings remove',
|
||||
value: 'collection_listings/remove'
|
||||
value: 'collection_listings/remove',
|
||||
},
|
||||
{
|
||||
name: 'Collection listings update',
|
||||
value: 'collection_listings/update'
|
||||
value: 'collection_listings/update',
|
||||
},
|
||||
{
|
||||
name: 'Collections create',
|
||||
value: 'collections/create'
|
||||
value: 'collections/create',
|
||||
},
|
||||
{
|
||||
name: 'Collections delete',
|
||||
value: 'collections/delete'
|
||||
value: 'collections/delete',
|
||||
},
|
||||
{
|
||||
name: 'Collections update',
|
||||
value: 'collections/update'
|
||||
value: 'collections/update',
|
||||
},
|
||||
{
|
||||
name: 'Customer groups create',
|
||||
value: 'customer_groups/create'
|
||||
value: 'customer_groups/create',
|
||||
},
|
||||
{
|
||||
name: 'Customer groups delete',
|
||||
value: 'customer_groups/delete'
|
||||
value: 'customer_groups/delete',
|
||||
},
|
||||
{
|
||||
name: 'Customer groups update',
|
||||
value: 'customer_groups/update'
|
||||
value: 'customer_groups/update',
|
||||
},
|
||||
{
|
||||
name: 'Customers create',
|
||||
value: 'customers/create'
|
||||
value: 'customers/create',
|
||||
},
|
||||
{
|
||||
name: 'Customers delete',
|
||||
value: 'customers/delete'
|
||||
value: 'customers/delete',
|
||||
},
|
||||
{
|
||||
name: 'Customers disable',
|
||||
value: 'customers/disable'
|
||||
value: 'customers/disable',
|
||||
},
|
||||
{
|
||||
name: 'Customers enable',
|
||||
value: 'customers/enable'
|
||||
value: 'customers/enable',
|
||||
},
|
||||
{
|
||||
name: 'Customers update',
|
||||
value: 'customers/update'
|
||||
value: 'customers/update',
|
||||
},
|
||||
{
|
||||
name: 'Draft orders create',
|
||||
value: 'draft_orders/create'
|
||||
value: 'draft_orders/create',
|
||||
},
|
||||
{
|
||||
name: 'Draft orders delete',
|
||||
value: 'draft_orders/delete'
|
||||
value: 'draft_orders/delete',
|
||||
},
|
||||
{
|
||||
name: 'Draft orders update',
|
||||
value: 'draft_orders/update'
|
||||
value: 'draft_orders/update',
|
||||
},
|
||||
{
|
||||
name: 'Fulfillment events create',
|
||||
value: 'fulfillment_events/create'
|
||||
value: 'fulfillment_events/create',
|
||||
},
|
||||
{
|
||||
name: 'Fulfillment events delete',
|
||||
value: 'fulfillment_events/delete'
|
||||
value: 'fulfillment_events/delete',
|
||||
},
|
||||
{
|
||||
name: 'Fulfillments create',
|
||||
value: 'fulfillments/create'
|
||||
value: 'fulfillments/create',
|
||||
},
|
||||
{
|
||||
name: 'Fulfillments update',
|
||||
value: 'fulfillments/update'
|
||||
value: 'fulfillments/update',
|
||||
},
|
||||
{
|
||||
name: 'Inventory_items create',
|
||||
value: 'inventory_items/create'
|
||||
value: 'inventory_items/create',
|
||||
},
|
||||
{
|
||||
name: 'Inventory_items delete',
|
||||
value: 'inventory_items/delete'
|
||||
value: 'inventory_items/delete',
|
||||
},
|
||||
{
|
||||
name: 'Inventory_items update',
|
||||
value: 'inventory_items/update'
|
||||
value: 'inventory_items/update',
|
||||
},
|
||||
{
|
||||
name: 'Inventory_levels connect',
|
||||
value: 'inventory_levels/connect'
|
||||
value: 'inventory_levels/connect',
|
||||
},
|
||||
{
|
||||
name: 'Inventory_levels disconnect',
|
||||
value: 'inventory_levels/disconnect'
|
||||
value: 'inventory_levels/disconnect',
|
||||
},
|
||||
{
|
||||
name: 'Inventory_levels update',
|
||||
value: 'inventory_levels/update'
|
||||
value: 'inventory_levels/update',
|
||||
},
|
||||
{
|
||||
name: 'Locales create',
|
||||
value: 'locales/create'
|
||||
value: 'locales/create',
|
||||
},
|
||||
{
|
||||
name: 'Locales update',
|
||||
value: 'locales/update'
|
||||
value: 'locales/update',
|
||||
},
|
||||
{
|
||||
name: 'Locations create',
|
||||
value: 'locations/create'
|
||||
value: 'locations/create',
|
||||
},
|
||||
{
|
||||
name: 'Locations delete',
|
||||
value: 'locations/delete'
|
||||
value: 'locations/delete',
|
||||
},
|
||||
{
|
||||
name: 'Locations update',
|
||||
value: 'locations/update'
|
||||
value: 'locations/update',
|
||||
},
|
||||
{
|
||||
name: 'Order transactions create',
|
||||
value: 'order_transactions/create'
|
||||
value: 'order_transactions/create',
|
||||
},
|
||||
{
|
||||
name: 'Orders cancelled',
|
||||
value: 'orders/cancelled'
|
||||
value: 'orders/cancelled',
|
||||
},
|
||||
{
|
||||
name: 'Orders create',
|
||||
value: 'orders/create'
|
||||
value: 'orders/create',
|
||||
},
|
||||
{
|
||||
name: 'Orders delete',
|
||||
value: 'orders/delete'
|
||||
value: 'orders/delete',
|
||||
},
|
||||
{
|
||||
name: 'Orders fulfilled',
|
||||
value: 'orders/fulfilled'
|
||||
value: 'orders/fulfilled',
|
||||
},
|
||||
{
|
||||
name: 'Orders paid',
|
||||
value: 'orders/paid'
|
||||
value: 'orders/paid',
|
||||
},
|
||||
{
|
||||
name: 'Orders partially fulfilled',
|
||||
value: 'orders/partially_fulfilled'
|
||||
value: 'orders/partially_fulfilled',
|
||||
},
|
||||
{
|
||||
name: 'Orders updated',
|
||||
value: 'orders/updated'
|
||||
value: 'orders/updated',
|
||||
},
|
||||
{
|
||||
name: 'Product listings add',
|
||||
value: 'product_listings/add'
|
||||
value: 'product_listings/add',
|
||||
},
|
||||
{
|
||||
name: 'Product listings remove',
|
||||
value: 'product_listings/remove'
|
||||
value: 'product_listings/remove',
|
||||
},
|
||||
{
|
||||
name: 'Product listings update',
|
||||
value: 'product_listings/update'
|
||||
value: 'product_listings/update',
|
||||
},
|
||||
{
|
||||
name: 'Products create',
|
||||
value: 'products/create'
|
||||
value: 'products/create',
|
||||
},
|
||||
{
|
||||
name: 'Products delete',
|
||||
value: 'products/delete'
|
||||
value: 'products/delete',
|
||||
},
|
||||
{
|
||||
name: 'Products update',
|
||||
value: 'products/update'
|
||||
value: 'products/update',
|
||||
},
|
||||
{
|
||||
name: 'Refunds create',
|
||||
value: 'refunds/create'
|
||||
value: 'refunds/create',
|
||||
},
|
||||
{
|
||||
name: 'Shop update',
|
||||
value: 'shop/update'
|
||||
value: 'shop/update',
|
||||
},
|
||||
{
|
||||
name: 'Tender transactions create',
|
||||
value: 'tender_transactions/create'
|
||||
value: 'tender_transactions/create',
|
||||
},
|
||||
{
|
||||
name: 'Themes create',
|
||||
value: 'themes/create'
|
||||
value: 'themes/create',
|
||||
},
|
||||
{
|
||||
name: 'Themes delete',
|
||||
value: 'themes/delete'
|
||||
value: 'themes/delete',
|
||||
},
|
||||
{
|
||||
name: 'Themes publish',
|
||||
value: 'themes/publish'
|
||||
value: 'themes/publish',
|
||||
},
|
||||
{
|
||||
name: 'Themes update',
|
||||
value: 'themes/update'
|
||||
}
|
||||
value: 'themes/update',
|
||||
},
|
||||
],
|
||||
description: 'Event that triggers the webhook',
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue