mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-09 22:24:05 -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) {
|
||||
for(let fields in fieldsToSet) {
|
||||
body[snakeCase(fields.toString())] = fieldsToSet[fields]
|
||||
export function setFields(fieldsToSet: IDataObject, body: IDataObject) {
|
||||
for(const fields in fieldsToSet) {
|
||||
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 {
|
||||
[index: string]: any
|
||||
[index: string]: any; // tslint:disable-line:no-any
|
||||
billing?: IAddress;
|
||||
coupon_lines?: ICouponLine[];
|
||||
currency?: string;
|
||||
|
|
|
@ -13,5 +13,5 @@ export interface IImage {
|
|||
}
|
||||
|
||||
export interface IProduct {
|
||||
[index: string]: any
|
||||
[index: string]: string | number | string[] | number[] | IDataObject | IDataObject[] | IImage[] | IDimension;
|
||||
}
|
||||
|
|
|
@ -11,11 +11,11 @@ import {
|
|||
} from 'n8n-workflow';
|
||||
import {
|
||||
adjustMetadata,
|
||||
setFields,
|
||||
setMetadata,
|
||||
toSnakeCase,
|
||||
woocommerceApiRequest,
|
||||
woocommerceApiRequestAllItems,
|
||||
setFields,
|
||||
} from './GenericFunctions';
|
||||
import {
|
||||
productFields,
|
||||
|
@ -250,11 +250,11 @@ export class WooCommerce implements INodeType {
|
|||
if (operation === 'create') {
|
||||
const name = this.getNodeParameter('name', i) as string;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
let body: IProduct = {
|
||||
const body: IProduct = {
|
||||
name,
|
||||
};
|
||||
|
||||
setFields(additionalFields, body)
|
||||
setFields(additionalFields, body);
|
||||
|
||||
if (additionalFields.categories) {
|
||||
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 body: IProduct = {};
|
||||
|
||||
setFields(updateFields, body)
|
||||
setFields(updateFields, body);
|
||||
|
||||
const images = (this.getNodeParameter('imagesUi', i) as IDataObject).imagesValues as IImage[];
|
||||
if (images) {
|
||||
|
@ -375,7 +375,7 @@ export class WooCommerce implements INodeType {
|
|||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
const body: IOrder = {};
|
||||
|
||||
setFields(additionalFields, body)
|
||||
setFields(additionalFields, body);
|
||||
|
||||
const billing = (this.getNodeParameter('billingUi', i) as IDataObject).billingValues as IAddress;
|
||||
if (billing !== undefined) {
|
||||
|
|
Loading…
Reference in a new issue