npm install contaazul --save
ContaAzul, unofficial Node.js bindings to the ContaAzul API - Docs
Built with ❤︎ by FieldControl e contributors
Installation
This client is intended for server side use only.
npm install contaazul --save
Playground
You can run and watch everything working fine at bin/playground.js script
Note: You must enter your accessToken before running:
node bin/playground.js
Usage
const ContaAzul = const client = accessToken: 'Wx15BlcpBbQyl15y64I0vDfVPWbsTdNX<3'
Product
// Create a productconst response = await clientproducts// {// "status": 201,// "data": {// "id": "58a5471a-c121-4c0a-b2f4-1a22d9a34ef9",// "name": "Game Atari ET",// "value": 100,// "cost": 80,// "code": "Game-1",// "barcode": "501234567890",// "available_stock": 1000,// "ncm_code": "96140000",// "cest_code": "0100300",// "net_weight": 10,// "gross_weight": 15,// "category": {// "id": "c7288c09-829d-48b9-aee2-4f744e380587",// "name": "Kitchen utensils"// }// }// }
// Get a productconst response = await clientproducts// {// "status": 200,// "data": {// "id": "c7288c09-829d-48b9-aee2-4f744e380587",// "name": "Game Atari ET",// "value": 100,// "cost": 80,// "code": "Game-1",// "barcode": "501234567890",// "available_stock": 1000,// "ncm_code": "96140000",// "cest_code": "0100300",// "net_weight": 10,// "gross_weight": 15,// "category": {// "id": "c7288c09-829d-48b9-aee2-4f744e380587",// "name": "Kitchen utensils"// }// }// }
// Update a productconst response = await clientproducts// {// "status": 200,// "data": {// "id": "58a5471a-c121-4c0a-b2f4-1a22d9a34ef9",// "name": "Game Atari ET",// "value": 100,// "cost": 80,// "code": "Game-1",// "barcode": "501234567890",// "available_stock": 1000,// "ncm_code": "96140000",// "cest_code": "0100300",// "net_weight": 10,// "gross_weight": 15,// "category": {// "id": "c7288c09-829d-48b9-aee2-4f744e380587",// "name": "Kitchen utensils"// }// }// }
// List productsconst response = await clientproducts// {// "status": 200,// "data": [// {// "id": "c7288c09-829d-48b9-aee2-4f744e380587",// "name": "Game Atari ET",// "value": 100,// "cost": 80,// "code": "Game-1",// "barcode": "501234567890",// "available_stock": 1000,// "ncm_code": "96140000",// "cest_code": "0100300",// "net_weight": 10,// "gross_weight": 15,// "category": {// "id": "c7288c09-829d-48b9-aee2-4f744e380587",// "name": "Kitchen utensils"// }// }// ]// }
// Delete a productconst response = await clientproducts// {// "status": 204// }
// List product categoriesconst response = await clientproducts// {// "status": 200,// "data": [{// "id": "c7288c09-829d-48b9-aee2-4f744e380587",// "name": "Kitchen utensils"// }]// }
// Get product categoryconst response = await clientproducts// {// "status": 200,// "data": {// "id": "c7288c09-829d-48b9-aee2-4f744e380587",// "name": "Kitchen utensils"// }// }
Service
// Create a serviceconst response = await clientservices// {// "status": 201,// "data": {// "id": "5b25d45f-0364-49de-b626-e277752a082d",// "name": "Fix car engine",// "value": 100,// "cost": 80,// "code": "FIX-ENG-001"// }// }
// Get a serviceconst response = await clientservices// {// "status": 200,// "data": {// "id": "5b25d45f-0364-49de-b626-e277752a082d",// "name": "Fix car engine",// "value": 100,// "cost": 80,// "code": "FIX-ENG-001"// }// }
// Update a serviceconst response = await clientservices// {// "status": 200,// "data": {// "id": "5b25d45f-0364-49de-b626-e277752a082d",// "name": "Fix car engine",// "value": 100,// "cost": 80,// "code": "FIX-ENG-001"// }// }
// List servicesconst response = await clientservices// {// "status": 200,// "data": [// {// "id": "5b25d45f-0364-49de-b626-e277752a082d",// "name": "Fix car engine",// "value": 100,// "cost": 80,// "code": "FIX-ENG-001"// }// ]// }
// Delete a serviceconst response = await clientservices// {// "status": 204// }
Customer
// Create a customerconst response = await clientcustomers// {// "status": 201,// "data": {// "id": "45165503-45ac-4f58-8739-74f9a1049d66",// "name": "John C.",// "company_name": null,// "email": "john.company@johncompany.com",// "business_phone": "99 99999-9999",// "mobile_phone": "99 99999-9999",// "person_type": "NATURAL",// "document": "00011122233",// "identity_document": "00011122233",// "state_registration_number": "00011122233",// "state_registration_type": "NO_CONTRIBUTOR",// "city_registration_number": null,// "date_of_birth": "1988-12-23T13:32:10.118Z",// "notes": "Important customer, always wears a green hat",// "created_at": "2020-01-25T15:04:03.690Z",// "address": {// "street": "Rua Parma",// "number": "224",// "complement": "Apartamento 2058",// "zip_code": "79106-330",// "neighborhood": "Jardim Itália",// "city": {// "name": "Campo Grande"// },// "state": {// "name": "MS"// }// }// }// }
// List customersconst response = await clientcustomers// {// "status": 200,// "data": [{// "id": "45165503-45ac-4f58-8739-74f9a1049d66",// "name": "John C.",// "company_name": null,// "email": "john.company@johncompany.com",// "business_phone": "99 99999-9999",// "mobile_phone": "99 99999-9999",// "person_type": "NATURAL",// "document": "00011122233",// "identity_document": "00011122233",// "state_registration_number": "00011122233",// "state_registration_type": "NO_CONTRIBUTOR",// "city_registration_number": null,// "date_of_birth": "1988-12-23T13:32:10.118Z",// "notes": "Important customer, always wears a green hat",// "created_at": "2020-01-25T15:04:03.690Z",// "address": {// "street": "Rua Parma",// "number": "224",// "complement": "Apartamento 2058",// "zip_code": "79106-330",// "neighborhood": "Jardim Itália",// "city": {// "name": "Campo Grande"// },// "state": {// "name": "MS"// }// }// }]// }
// Get a customerconst response = await clientcustomers// {// "status": 200,// "data": {// "id": "45165503-45ac-4f58-8739-74f9a1049d66",// "name": "John C.",// "company_name": null,// "email": "john.company@johncompany.com",// "business_phone": "99 99999-9999",// "mobile_phone": "99 99999-9999",// "person_type": "NATURAL",// "document": "00011122233",// "identity_document": "00011122233",// "state_registration_number": "00011122233",// "state_registration_type": "NO_CONTRIBUTOR",// "city_registration_number": null,// "date_of_birth": "1988-12-23T03:00:00.000Z",// "notes": "Important customer, always wears a green hat",// "created_at": "2020-01-25T03:00:00.000Z",// "address": {// "street": "Rua Parma",// "number": "224",// "complement": "Apartamento 2058",// "zip_code": "79106-330",// "neighborhood": "Jardim Itália",// "city": {// "name": "Campo Grande"// },// "state": {// "name": "MS"// }// }// }// }
// List customer contactsconst response = await clientcustomers// {// "status": 200,// "data": [// {// "name": "John C.",// "business_phone": "99 9999-9999",// "email": "John.C@johncompany.com",// "job_title": "Developer"// }// ]// }
// Update a customerconst response = await clientcustomers// {// "status": 200,// "data": {// "id": "45165503-45ac-4f58-8739-74f9a1049d66",// "name": "John C.",// "company_name": null,// "email": "john.company@johncompany.com",// "business_phone": "99 99999-9999",// "mobile_phone": "99 99999-9999",// "person_type": "NATURAL",// "document": "00011122233",// "identity_document": "00011122233",// "state_registration_number": "00011122233",// "state_registration_type": "NO_CONTRIBUTOR",// "city_registration_number": null,// "date_of_birth": "1988-12-23T13:32:10.118Z",// "notes": "Important customer, always wears a green hat",// "created_at": "2020-01-25T03:00:00.000Z",// "address": {// "street": "Rua Parma",// "number": "224",// "complement": "Apartamento 2058",// "zip_code": "79106-330",// "neighborhood": "Jardim Itália",// "city": {// "name": "Campo Grande"// },// "state": {// "name": "MS"// }// }// }// }
// Inactivate a customerconst response = await clientcustomers// {// "status": 204// }
// Delete a customerconst response = await clientcustomers// {// "status": 204// }
Supplier (beta)
// Create a supplierconst response = await clientsuppliers// {// "status": 201,// "data": {// "id": "da6fc701-222b-4752-93b1-ad95c43d5034",// "name": "John C.",// "company_name": "John C. Company",// "email": "john.company@johncompany.com",// "business_phone": "99 99999-9999",// "mobile_phone": "99 99999-9999",// "person_type": "NATURAL",// "document": "00011122233",// "identity_document": "00011122233",// "state_registration_number": "00011122233",// "state_registration_type": "NO_CONTRIBUTOR",// "city_registration_number": "00011122233",// "date_of_birth": "1988-12-23T13:32:10.118Z",// "notes": "Supplier with two cnpj",// "foreign_id": null,// "contact_name": null,// "address": {// "street": "Rua Parma",// "number": "224",// "complement": "Apartamento 2058",// "zip_code": "79106-330",// "neighborhood": "Jardim Itália",// "city": {// "name": "Campo Grande"// },// "state": {// "name": "MS"// }// }// }// }
// List suppliersconst response = await clientsuppliers// {// "status": 200,// "data": [// {// "id": "da6fc701-222b-4752-93b1-ad95c43d5034",// "name": "John C.",// "company_name": "John C. Company",// "email": "john.company@johncompany.com",// "business_phone": "99 99999-9999",// "mobile_phone": "99 99999-9999",// "person_type": "NATURAL",// "document": "00011122233",// "identity_document": "00011122233",// "state_registration_number": "00011122233",// "state_registration_type": "NO_CONTRIBUTOR",// "city_registration_number": "00011122233",// "date_of_birth": "1988-12-23T03:00:00.000Z",// "notes": "Supplier with two cnpj",// "foreign_id": null,// "contact_name": null,// "address": {// "street": "Rua Parma",// "number": "224",// "complement": "Apartamento 2058",// "zip_code": "79106-330",// "neighborhood": "Jardim Itália",// "city": {// "name": "Campo Grande"// },// "state": {// "name": "MS"// }// }// }// ]// }
// Get a supplierconst response = await clientsuppliers// {// "status": 200,// "data": {// "id": "da6fc701-222b-4752-93b1-ad95c43d5034",// "name": "John C.",// "company_name": "John C. Company",// "email": "john.company@johncompany.com",// "business_phone": "99 99999-9999",// "mobile_phone": "99 99999-9999",// "person_type": "NATURAL",// "document": "00011122233",// "identity_document": "00011122233",// "state_registration_number": "00011122233",// "state_registration_type": "NO_CONTRIBUTOR",// "city_registration_number": "00011122233",// "date_of_birth": "1988-12-23T03:00:00.000Z",// "notes": "Supplier with two cnpj",// "foreign_id": null,// "contact_name": null,// "address": {// "street": "Rua Parma",// "number": "224",// "complement": "Apartamento 2058",// "zip_code": "79106-330",// "neighborhood": "Jardim Itália",// "city": {// "name": "Campo Grande"// },// "state": {// "name": "MS"// }// }// }// }
// Update a supplierconst response = await clientsuppliers// {// "status": 200,// "data": {// "id": "da6fc701-222b-4752-93b1-ad95c43d5034",// "name": "John C.",// "company_name": "John C. Company",// "email": "john.company@johncompany.com",// "business_phone": "99 99999-9999",// "mobile_phone": "99 99999-9999",// "person_type": "NATURAL",// "document": "00011122233",// "identity_document": "00011122233",// "state_registration_number": "00011122233",// "state_registration_type": "NO_CONTRIBUTOR",// "city_registration_number": "00011122233",// "date_of_birth": "1988-12-23T13:32:10.118Z",// "notes": "Supplier with two cnpj",// "foreign_id": null,// "contact_name": null,// "address": {// "street": "Rua Parma",// "number": "224",// "complement": "Apartamento 2058",// "zip_code": "79106-330",// "neighborhood": "Jardim Itália",// "city": {// "name": "Campo Grande"// },// "state": {// "name": "MS"// }// }// }// }
// Delete a supplierconst response = await clientsuppliers// {// "status": 204// }
Contract (beta)
// Create a contractconst response = await clientcontracts// {// "status": 201,// "data": {// "id": "a333a635-a026-44cf-9783-00d9b0c75a49",// "number": 1,// "emission": "2020-01-25T03:00:00.000Z",// "status": "COMMITTED",// "customer_id": "9cf6612f-7401-4944-8cff-986eaf99f3a5",// "discount": {// "measure_unit": "VALUE",// "rate": 5// },// "product_discount": {// "measure_unit": "VALUE",// "rate": 5// },// "service_discount": null,// "due_day": 5,// "duration": 10,// "payment_terms": null,// "notes": "Contract for house rent",// "shipping_cost": 10// }// }
// Get a contractconst response = await clientcontracts// {// "status": 200,// "data": {// "id": "a333a635-a026-44cf-9783-00d9b0c75a49",// "number": 1,// "emission": "2020-01-25T03:00:00.000Z",// "status": "COMMITTED",// "customer_id": "9cf6612f-7401-4944-8cff-986eaf99f3a5",// "discount": {// "measure_unit": "VALUE",// "rate": 5// },// "product_discount": {// "measure_unit": "VALUE",// "rate": 5// },// "service_discount": null,// "due_day": 5,// "duration": 10,// "payment_terms": null,// "notes": "Contract for house rent",// "shipping_cost": 10// }// }
Sale
// Create a saleconst response = await clientsales// {// "status": 201,// "data": {// "id": "968150ce-d57a-4a97-ab6c-4da83b255f79",// "number": 12,// "emission": "2020-01-25T03:00:00.000Z",// "status": "COMMITTED",// "scheduled": false,// "customer_id": "19b2b240-7740-4e6e-b1b6-d44d1b206e1d",// "customer": {// "id": "19b2b240-7740-4e6e-b1b6-d44d1b206e1d",// "name": null,// "company_name": null,// "email": null,// "person_type": null// },// "discount": {// "measure_unit": "VALUE",// "rate": 5// },// "product_discount": {// "measure_unit": "VALUE",// "rate": 5// },// "service_discount": null,// "payment": {// "type": "CASH",// "installments": [// {// "number": 1,// "value": 305,// "due_date": "2020-01-25T16:05:57.212Z",// "status": "PENDING"// }// ]// },// "payment_terms": null,// "notes": "Sale made by noon",// "shipping_cost": 10,// "total": 305,// "seller": {// "id": null,// "name": null// }// }// }
// List salesconst response = await clientsales// {// "status": 200,// "data": [// {// "id": "968150ce-d57a-4a97-ab6c-4da83b255f79",// "number": 12,// "emission": "2020-01-25T03:00:00.000Z",// "status": "COMMITTED",// "scheduled": false,// "customer_id": "19b2b240-7740-4e6e-b1b6-d44d1b206e1d",// "customer": {// "id": "19b2b240-7740-4e6e-b1b6-d44d1b206e1d",// "name": "John C.",// "company_name": null,// "email": null,// "person_type": "NATURAL"// },// "discount": {// "measure_unit": "VALUE",// "rate": 5// },// "product_discount": {// "measure_unit": "VALUE",// "rate": 5// },// "service_discount": null,// "payment": {// "type": "CASH",// "installments": [// {// "number": 1,// "value": 305,// "due_date": "2020-01-25T03:00:00.000Z",// "status": "PENDING"// }// ]// },// "payment_terms": null,// "notes": "Sale made by noon",// "shipping_cost": 10,// "total": 305,// "seller": {// "id": "f38da1e5-6151-45d0-b108-d7f22d0eaac7",// "name": "Luiz Freneda"// }// }// ]// }
// Get a saleconst response = await clientsales// {// "status": 200,// "data": {// "id": "968150ce-d57a-4a97-ab6c-4da83b255f79",// "number": 12,// "emission": "2020-01-25T03:00:00.000Z",// "status": "COMMITTED",// "scheduled": false,// "customer_id": "19b2b240-7740-4e6e-b1b6-d44d1b206e1d",// "customer": {// "id": "19b2b240-7740-4e6e-b1b6-d44d1b206e1d",// "name": "John C.",// "company_name": null,// "email": null,// "person_type": "NATURAL"// },// "discount": {// "measure_unit": "VALUE",// "rate": 5// },// "product_discount": {// "measure_unit": "VALUE",// "rate": 5// },// "service_discount": null,// "payment": {// "type": "CASH",// "installments": [// {// "number": 1,// "value": 305,// "due_date": "2020-01-25T03:00:00.000Z",// "status": "PENDING"// }// ]// },// "payment_terms": null,// "notes": "Sale made by noon",// "shipping_cost": 10,// "total": 305,// "seller": {// "id": null,// "name": "Luiz Freneda"// }// }// }
// Update a saleconst response = await clientsales// {// "status": 200,// "data": {// "id": "968150ce-d57a-4a97-ab6c-4da83b255f79",// "number": 12,// "emission": "2020-01-25T03:00:00.000Z",// "status": "COMMITTED",// "scheduled": false,// "customer_id": "19b2b240-7740-4e6e-b1b6-d44d1b206e1d",// "customer": {// "id": "19b2b240-7740-4e6e-b1b6-d44d1b206e1d",// "name": "John C.",// "company_name": null,// "email": null,// "person_type": "NATURAL"// },// "discount": {// "measure_unit": "VALUE",// "rate": 5// },// "product_discount": {// "measure_unit": "VALUE",// "rate": 5// },// "service_discount": null,// "payment": {// "type": "CASH",// "installments": [// {// "number": 1,// "value": 305,// "due_date": "2020-01-25T16:05:57.212Z",// "status": "PENDING"// }// ]// },// "payment_terms": null,// "notes": "Sale made by noon",// "shipping_cost": 10,// "total": 305,// "seller": {// "id": "f38da1e5-6151-45d0-b108-d7f22d0eaac7",// "name": "Luiz Perez"// }// }// }
// Get sale's itemsconst response = await clientsales// {// "status": 200,// "data": [// {// "description": "Fix car engine",// "quantity": 1,// "item": {// "id": "59b18bc4-b360-4bde-99ac-9da3183db14e",// "name": "Fix car engine",// "value": 100,// "cost": 80// },// "itemType": "SERVICE",// "value": 200// }// ]// }
// Get sale's installmentsconst response = await clientsales// {// "status": 200,// "data": {// "number": 1,// "value": 305,// "due_date": "2020-01-25T03:00:00.000Z",// "status": "PENDING"// }// }
// Update sale's installment statusconst response = await clientsales// {// "status": 200,// "data": {// "number": 1,// "value": 305,// "due_date": "2020-01-25T03:00:00.000Z",// "status": "ACQUITTED"// }// }
// Delete a saleconst response = await clientsales// {// "status": 204// }
Pull Requests
- Add tests! Your patch won't be accepted if it doesn't have tests.
- Document any change in behaviour. Make sure the README and any other relevant documentation are kept up-to-date.
- Create topic branches. Don't ask us to pull from your master branch.
- One pull request per feature. If you want to do more than one thing, send multiple pull requests.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Follow @FieldControlApp on instagram! ❤