mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 04:34:06 -08:00
Merge pull request #2052 from n8n-io/woocommerce-lint-and-tags-fix
Fixed linting and tags information
This commit is contained in:
commit
b8524bbfb7
|
@ -149,9 +149,14 @@ export function toSnakeCase(data:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setFields(fieldsToSet: IDataObject, body: any) {
|
export function setFields(fieldsToSet: IDataObject, body: IDataObject) {
|
||||||
for(let fields in fieldsToSet) {
|
for(const fields in fieldsToSet) {
|
||||||
body[snakeCase(fields.toString())] = fieldsToSet[fields]
|
if (fields === 'tags') {
|
||||||
|
body['tags'] = (fieldsToSet[fields] as string[]).map(tag => ({id: parseInt(tag, 10)}));
|
||||||
|
} else {
|
||||||
|
body[snakeCase(fields.toString())] = fieldsToSet[fields];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ export interface ICouponLine {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IOrder {
|
export interface IOrder {
|
||||||
[index: string]: any
|
[index: string]: any; // tslint:disable-line:no-any
|
||||||
billing?: IAddress;
|
billing?: IAddress;
|
||||||
coupon_lines?: ICouponLine[];
|
coupon_lines?: ICouponLine[];
|
||||||
currency?: string;
|
currency?: string;
|
||||||
|
|
|
@ -13,5 +13,5 @@ export interface IImage {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IProduct {
|
export interface IProduct {
|
||||||
[index: string]: any
|
[index: string]: string | number | string[] | number[] | IDataObject | IDataObject[] | IImage[] | IDimension;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,11 +11,11 @@ import {
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
import {
|
import {
|
||||||
adjustMetadata,
|
adjustMetadata,
|
||||||
|
setFields,
|
||||||
setMetadata,
|
setMetadata,
|
||||||
toSnakeCase,
|
toSnakeCase,
|
||||||
woocommerceApiRequest,
|
woocommerceApiRequest,
|
||||||
woocommerceApiRequestAllItems,
|
woocommerceApiRequestAllItems,
|
||||||
setFields,
|
|
||||||
} from './GenericFunctions';
|
} from './GenericFunctions';
|
||||||
import {
|
import {
|
||||||
productFields,
|
productFields,
|
||||||
|
@ -250,11 +250,11 @@ export class WooCommerce implements INodeType {
|
||||||
if (operation === 'create') {
|
if (operation === 'create') {
|
||||||
const name = this.getNodeParameter('name', i) as string;
|
const name = this.getNodeParameter('name', i) as string;
|
||||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||||
let body: IProduct = {
|
const body: IProduct = {
|
||||||
name,
|
name,
|
||||||
};
|
};
|
||||||
|
|
||||||
setFields(additionalFields, body)
|
setFields(additionalFields, body);
|
||||||
|
|
||||||
if (additionalFields.categories) {
|
if (additionalFields.categories) {
|
||||||
body.categories = (additionalFields.categories as string[]).map(category => ({ id: parseInt(category, 10) })) as unknown as IDataObject[];
|
body.categories = (additionalFields.categories as string[]).map(category => ({ id: parseInt(category, 10) })) as unknown as IDataObject[];
|
||||||
|
@ -280,7 +280,7 @@ export class WooCommerce implements INodeType {
|
||||||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||||
const body: IProduct = {};
|
const body: IProduct = {};
|
||||||
|
|
||||||
setFields(updateFields, body)
|
setFields(updateFields, body);
|
||||||
|
|
||||||
const images = (this.getNodeParameter('imagesUi', i) as IDataObject).imagesValues as IImage[];
|
const images = (this.getNodeParameter('imagesUi', i) as IDataObject).imagesValues as IImage[];
|
||||||
if (images) {
|
if (images) {
|
||||||
|
@ -375,7 +375,7 @@ export class WooCommerce implements INodeType {
|
||||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||||
const body: IOrder = {};
|
const body: IOrder = {};
|
||||||
|
|
||||||
setFields(additionalFields, body)
|
setFields(additionalFields, body);
|
||||||
|
|
||||||
const billing = (this.getNodeParameter('billingUi', i) as IDataObject).billingValues as IAddress;
|
const billing = (this.getNodeParameter('billingUi', i) as IDataObject).billingValues as IAddress;
|
||||||
if (billing !== undefined) {
|
if (billing !== undefined) {
|
||||||
|
|
Loading…
Reference in a new issue