Skip to content

Commit ae991ca

Browse files
Add customer methods (#2)
* Add customer interfaces and methods for creating and updating customers
1 parent d354bee commit ae991ca

File tree

5 files changed

+370
-22
lines changed

5 files changed

+370
-22
lines changed

README.md

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,72 @@ The following api methods have been implemented:
4848

4949
- `customers` Customers
5050
- `sales` Sales invoices
51+
- `purchases` Purchase invoices
5152

5253
### Getter examples
5354

5455
Each resource type has `getAll()` and `getById(1234)` getters (below examples with customers):
5556

5657
```javascript
5758
const customers = await fennoa.customers.getAll(); // array of customers
58-
const customer = await fennoa.customers.getById(1234); // single customer
59+
const customer = await fennoa.customers.getById(1234); // single customer by id
5960
```
6061

62+
### Customer examples
63+
64+
Get customer by customer number:
65+
66+
```javascript
67+
const customer = await fennoa.customers.getByCustomerNo('1234'); // single customer by customer number
68+
```
69+
70+
<br>
71+
Create a new customer
72+
73+
```javascript
74+
const newCustomer: INewCustomer = {
75+
customer_no: '1234',
76+
name: 'Test Customer 2 Oy',
77+
name2: 'Nimi 2',
78+
address: 'Test Address 1',
79+
postalcode: '00100',
80+
city: 'Helsinki',
81+
country_id: 'FI',
82+
description: 'Test Description',
83+
email: 'test@example.com',
84+
phone: '0123456789',
85+
fax: '0123456789',
86+
website: 'https://www.example.com',
87+
business_id: '1837795-7',
88+
vat_number: 'FI18377957',
89+
identity_number: '123456-7890',
90+
account_type_id: 1,
91+
contact_person: 'John Doe',
92+
einvoice_address: 'einvoice@example.com',
93+
einvoice_operator_id: 'OKOYFIHH',
94+
sales_invoice_delivery_method: 'email',
95+
customer_group_ids: [1, 2],
96+
locale_id: 1,
97+
locale_code: 'FI'
98+
};
99+
100+
const createdCustomer = await fennoa.customers.createCustomer(newCustomer);
101+
```
102+
103+
<br>
104+
Update a customer
105+
106+
```javascript
107+
const updateCustomer: IUpdateCustomer = {
108+
name: 'Updated Customer Oy'
109+
customer_group_ids: [3],
110+
};
111+
112+
const updatedCustomer = await fennoa.customers.updateCustomer('1234', updateCustomer);
113+
```
114+
115+
<br>
116+
61117
### Sales examples
62118

63119
Here is an example of creating, approving and sending a new sales invoice to a customer:

package-lock.json

Lines changed: 201 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rantalainen/fennoa-api-client",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"description": "",
55
"main": "dist/index.js",
66
"scripts": {
@@ -22,11 +22,11 @@
2222
},
2323
"homepage": "https://github.com/rantalainen/fennoa-api-client#readme",
2424
"devDependencies": {
25-
"typescript": "^4.4.4"
25+
"typescript": "^4.9.5"
2626
},
2727
"dependencies": {
28-
"form-data": "^4.0.0",
29-
"got": "^11.8.2"
28+
"form-data": "^4.0.4",
29+
"got": "^11.8.6"
3030
},
3131
"publishConfig": {
3232
"access": "public"

0 commit comments

Comments
 (0)