Skip to content

Commit d74be78

Browse files
committed
[Components] invoice_ninja #15154
Sources - New Client (Instant) - New Invoice (Instant) - New Payment (Instant) Actions - Create Client - Create Invoice - Create Payment
1 parent acb7b40 commit d74be78

File tree

14 files changed

+1092
-835
lines changed

14 files changed

+1092
-835
lines changed
Lines changed: 175 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,153 +1,246 @@
1-
import invoice_ninja from "../../invoice_ninja.app.mjs";
2-
import { axios } from "@pipedream/platform";
1+
import { CLASSIFICATION_OPTIONS } from "../../common/constants.mjs";
2+
import { parseObject } from "../../common/utils.mjs";
3+
import app from "../../invoice_ninja.app.mjs";
34

45
export default {
56
key: "invoice_ninja-create-client",
67
name: "Create Client",
7-
description: "Creates a new client in Invoice Ninja. [See the documentation]()",
8-
version: "0.0.{{ts}}",
8+
description: "Creates a new client in Invoice Ninja. [See the documentation](https://api-docs.invoicing.co/#tag/clients/POST/api/v1/clients)",
9+
version: "0.0.1",
910
type: "action",
1011
props: {
11-
invoice_ninja,
12+
app,
1213
contacts: {
13-
propDefinition: [
14-
invoice_ninja,
15-
"contacts",
16-
],
17-
},
18-
countryId: {
19-
propDefinition: [
20-
invoice_ninja,
21-
"countryId",
22-
],
14+
type: "string[]",
15+
label: "Contacts",
16+
description: "An array of contact objects in JSON format. **Example: { \"first_name\": \"John\", \"last_name\": \"Smith\", \"email\": \"[email protected]\", \"phone\": \"555-0123\" }**",
2317
},
2418
name: {
25-
propDefinition: [
26-
invoice_ninja,
27-
"name",
28-
],
19+
type: "string",
20+
label: "Client Name",
21+
description: "Name of the client",
2922
optional: true,
3023
},
3124
website: {
32-
propDefinition: [
33-
invoice_ninja,
34-
"website",
35-
],
25+
type: "string",
26+
label: "Website",
27+
description: "Website of the client",
3628
optional: true,
3729
},
3830
privateNotes: {
39-
propDefinition: [
40-
invoice_ninja,
41-
"privateNotes",
42-
],
31+
type: "string",
32+
label: "Private Notes",
33+
description: "Notes that are only visible to the user who created the client",
4334
optional: true,
4435
},
4536
industryId: {
4637
propDefinition: [
47-
invoice_ninja,
38+
app,
4839
"industryId",
4940
],
5041
optional: true,
5142
},
5243
sizeId: {
5344
propDefinition: [
54-
invoice_ninja,
45+
app,
5546
"sizeId",
5647
],
5748
optional: true,
5849
},
5950
address1: {
60-
propDefinition: [
61-
invoice_ninja,
62-
"address1",
63-
],
51+
type: "string",
52+
label: "Address 1",
53+
description: "Primary address line for the client",
6454
optional: true,
6555
},
6656
address2: {
67-
propDefinition: [
68-
invoice_ninja,
69-
"address2",
70-
],
57+
type: "string",
58+
label: "Address 2",
59+
description: "Secondary address line for the client",
7160
optional: true,
7261
},
7362
city: {
74-
propDefinition: [
75-
invoice_ninja,
76-
"city",
77-
],
63+
type: "string",
64+
label: "City",
65+
description: "City of the client",
7866
optional: true,
7967
},
8068
state: {
81-
propDefinition: [
82-
invoice_ninja,
83-
"state",
84-
],
69+
type: "string",
70+
label: "State",
71+
description: "State of the client",
8572
optional: true,
8673
},
8774
postalCode: {
88-
propDefinition: [
89-
invoice_ninja,
90-
"postalCode",
91-
],
75+
type: "string",
76+
label: "Postal Code",
77+
description: "Postal code of the client",
9278
optional: true,
9379
},
9480
phone: {
81+
type: "string",
82+
label: "Phone",
83+
description: "Phone number of the client",
84+
optional: true,
85+
},
86+
countryId: {
9587
propDefinition: [
96-
invoice_ninja,
97-
"phone",
88+
app,
89+
"countryId",
9890
],
91+
},
92+
customValue1: {
93+
type: "string",
94+
label: "Custom Value 1",
95+
description: "A custom field for storing additional information",
96+
optional: true,
97+
},
98+
customValue2: {
99+
type: "string",
100+
label: "Custom Value 2",
101+
description: "A custom field for storing additional information",
102+
optional: true,
103+
},
104+
customValue3: {
105+
type: "string",
106+
label: "Custom Value 3",
107+
description: "A custom field for storing additional information",
108+
optional: true,
109+
},
110+
customValue4: {
111+
type: "string",
112+
label: "Custom Value 4",
113+
description: "A custom field for storing additional information",
99114
optional: true,
100115
},
101116
vatNumber: {
102-
propDefinition: [
103-
invoice_ninja,
104-
"vatNumber",
105-
],
117+
type: "string",
118+
label: "VAT Number",
119+
description: "The client's VAT (Value Added Tax) number, if applicable",
106120
optional: true,
107121
},
108122
idNumber: {
123+
type: "string",
124+
label: "ID Number",
125+
description: "A unique identification number for the client, such as a tax ID or business registration number",
126+
optional: true,
127+
},
128+
number: {
129+
type: "string",
130+
label: "Number",
131+
description: "A system-assigned unique number for the client, typically used for invoicing purposes",
132+
optional: true,
133+
},
134+
shippingAddress1: {
135+
type: "string",
136+
label: "Shipping Address 1",
137+
description: "First line of the client's shipping address",
138+
optional: true,
139+
},
140+
shippingAddress2: {
141+
type: "string",
142+
label: "Shipping Address 2",
143+
description: "Second line of the client's shipping address, if needed",
144+
optional: true,
145+
},
146+
shippingCity: {
147+
type: "string",
148+
label: "Shipping City",
149+
description: "City of the client's shipping address",
150+
optional: true,
151+
},
152+
shippingState: {
153+
type: "string",
154+
label: "Shipping State",
155+
description: "State of the client's shipping address",
156+
optional: true,
157+
},
158+
shippingPostalCode: {
159+
type: "string",
160+
label: "Shipping Postal Code",
161+
description: "Postal code of the client's shipping address",
162+
optional: true,
163+
},
164+
shippingCountryId: {
109165
propDefinition: [
110-
invoice_ninja,
111-
"idNumber",
166+
app,
167+
"countryId",
112168
],
169+
label: "Shipping Country ID",
170+
description: "The ID of the country for the client's shipping address",
113171
optional: true,
114172
},
115173
groupSettingsId: {
116174
propDefinition: [
117-
invoice_ninja,
175+
app,
118176
"groupSettingsId",
119177
],
120178
optional: true,
121179
},
180+
isTaxExempt: {
181+
type: "boolean",
182+
label: "Is Tax Exempt",
183+
description: "Flag which defines if the client is exempt from taxes",
184+
optional: true,
185+
},
186+
hasValidVatNumber: {
187+
type: "boolean",
188+
label: "Has Valid VAT Number",
189+
description: "Flag which defines if the client has a valid VAT number",
190+
optional: true,
191+
},
122192
classification: {
123-
propDefinition: [
124-
invoice_ninja,
125-
"classification",
126-
],
193+
type: "string",
194+
label: "Classification",
195+
description: "Classification of the client",
196+
options: CLASSIFICATION_OPTIONS,
197+
optional: true,
198+
},
199+
settings: {
200+
type: "object",
201+
label: "Settings",
202+
description: "An array of settings objects in JSON format. **Example: {\"currency_id\": 1, \"timezone_id\": 5, \"date_format_id\": 1, \"language_id\": 1}** [See the documentation](https://api-docs.invoicing.co/#tag/clients/POST/api/v1/clients) for further details",
127203
optional: true,
128204
},
129205
},
130206
async run({ $ }) {
131-
const client = await this.invoice_ninja.createNewClient({
132-
contacts: this.contacts.map(JSON.parse),
133-
country_id: this.countryId,
134-
name: this.name,
135-
website: this.website,
136-
private_notes: this.privateNotes,
137-
industry_id: this.industryId,
138-
size_id: this.sizeId,
139-
address1: this.address1,
140-
address2: this.address2,
141-
city: this.city,
142-
state: this.state,
143-
postal_code: this.postalCode,
144-
phone: this.phone,
145-
vat_number: this.vatNumber,
146-
id_number: this.idNumber,
147-
group_settings_id: this.groupSettingsId,
148-
classification: this.classification,
207+
const { data } = await this.app.createNewClient({
208+
$,
209+
data: {
210+
contacts: parseObject(this.contacts),
211+
name: this.name,
212+
website: this.website,
213+
private_notes: this.privateNotes,
214+
industry_id: this.industryId,
215+
size_id: this.sizeId,
216+
address1: this.address1,
217+
address2: this.address2,
218+
city: this.city,
219+
state: this.state,
220+
postal_code: this.postalCode,
221+
phone: this.phone,
222+
country_id: this.countryId,
223+
custom_value1: this.customValue1,
224+
custom_value2: this.customValue2,
225+
custom_value3: this.customValue3,
226+
custom_value4: this.customValue4,
227+
vat_number: this.vatNumber,
228+
id_number: this.idNumber,
229+
number: this.number,
230+
shipping_address1: this.shippingAddress1,
231+
shipping_address2: this.shippingAddress2,
232+
shipping_city: this.shippingCity,
233+
shipping_state: this.shippingState,
234+
shipping_postal_code: this.shippingPostalCode,
235+
shipping_country_id: this.shipping_country_id,
236+
group_settings_id: this.groupSettingsId,
237+
is_tax_exempt: this.isTaxExempt,
238+
has_valid_vat_number: this.hasValidVatNumber,
239+
classification: this.classification,
240+
settings: parseObject(this.settings),
241+
},
149242
});
150-
$.export("$summary", `Created client ${client.name}`);
151-
return client;
243+
$.export("$summary", `Created client: ${data.id}`);
244+
return data;
152245
},
153246
};

0 commit comments

Comments
 (0)