feat(invoice-ninja): add create product action
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
export const fields = [
|
||||
{
|
||||
label: 'Product Key',
|
||||
key: 'productKey',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Notes',
|
||||
key: 'notes',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Price',
|
||||
key: 'price',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Quantity',
|
||||
key: 'quantity',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Tax Rate 1',
|
||||
key: 'taxRate1',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Tax Name 1',
|
||||
key: 'taxName1',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Tax Rate 2',
|
||||
key: 'taxRate2',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Tax Name 2',
|
||||
key: 'taxName2',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Tax Rate 3',
|
||||
key: 'taxRate3',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Tax Name 3',
|
||||
key: 'taxName3',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Custom Value 1',
|
||||
key: 'customValue1',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Custom Value 2',
|
||||
key: 'customValue2',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Custom Value 3',
|
||||
key: 'customValue3',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Custom Value 4',
|
||||
key: 'customValue4',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
},
|
||||
];
|
@@ -0,0 +1,52 @@
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
import { filterProvidedFields } from '../../common/filter-provided-fields';
|
||||
import { fields } from './fields';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Create product',
|
||||
key: 'createProduct',
|
||||
description: 'Creates a new product.',
|
||||
arguments: fields,
|
||||
|
||||
async run($) {
|
||||
const {
|
||||
productKey,
|
||||
notes,
|
||||
price,
|
||||
quantity,
|
||||
taxRate1,
|
||||
taxName1,
|
||||
taxRate2,
|
||||
taxName2,
|
||||
taxRate3,
|
||||
taxName3,
|
||||
customValue1,
|
||||
customValue2,
|
||||
customValue3,
|
||||
customValue4,
|
||||
} = $.step.parameters;
|
||||
|
||||
const bodyFields = {
|
||||
product_key: productKey,
|
||||
notes: notes,
|
||||
price: price,
|
||||
quantity: quantity,
|
||||
tax_rate1: taxRate1,
|
||||
tax_name1: taxName1,
|
||||
tax_rate2: taxRate2,
|
||||
tax_name2: taxName2,
|
||||
tax_rate3: taxRate3,
|
||||
tax_name3: taxName3,
|
||||
custom_value1: customValue1,
|
||||
custom_value2: customValue2,
|
||||
custom_value3: customValue3,
|
||||
custom_value4: customValue4,
|
||||
};
|
||||
|
||||
const body = filterProvidedFields(bodyFields);
|
||||
|
||||
const response = await $.http.post('/v1/products', body);
|
||||
|
||||
$.setActionItem({ raw: response.data.data });
|
||||
},
|
||||
});
|
@@ -1,5 +1,6 @@
|
||||
import createClient from './create-client';
|
||||
import createInvoice from './create-invoice';
|
||||
import createPayment from './create-payment';
|
||||
import createProduct from './create-product';
|
||||
|
||||
export default [createClient, createInvoice, createPayment];
|
||||
export default [createClient, createInvoice, createPayment, createProduct];
|
||||
|
@@ -7,6 +7,8 @@ items:
|
||||
desc: Creates a new invoice.
|
||||
- name: Create payment
|
||||
desc: Creates a new payment.
|
||||
- name: Create product
|
||||
desc: Creates a new product.
|
||||
---
|
||||
|
||||
<script setup>
|
||||
|
Reference in New Issue
Block a user