Skip to content

Latest commit

 

History

History
151 lines (131 loc) · 4.18 KB

customer.md

File metadata and controls

151 lines (131 loc) · 4.18 KB

Customer

Create customer

client.customer.create({
  "name": "Gaurav Kumar",
  "contact": 9123456780,
  "email": "gaurav.kumar@example.com",
  "fail_existing": 0,
  "gstin": "29XAbbA4369J1PA",
  "notes": {
    "notes_key_1": "Tea, Earl Grey, Hot",
    "notes_key_2": "Tea, Earl Grey… decaf."
  }
})

Parameters:

Name Type Description
name* string Name of the customer
email string Email of the customer
contact string Contact number of the customer
fail_existing string If a customer with the same details already exists, the request throws an exception by default. Possible value is 0 or 1
gstin string Customer's GST number, if available. For example, 29XAbbA4369J1PA
notes object A key-value pair

Response:

{
  "id" : "cust_1Aa00000000004",
  "entity": "customer",
  "name" : "Gaurav Kumar",
  "email" : "gaurav.kumar@example.com",
  "contact" : "9123456780",
  "gstin": "29XAbbA4369J1PA",
  "notes":{
    "notes_key_1":"Tea, Earl Grey, Hot",
    "notes_key_2":"Tea, Earl Grey… decaf."
  },
  "created_at ": 1234567890
}

Edit customer

client.customer.edit(customerId,{
  "name": "Gaurav Kumar",
  "email": "Gaurav.Kumar@example.com",
  "contact": 9000000000
})

Parameters:

Name Type Description
customerId* string The id of the customer to be updated
email string Email of the customer
name string Name of the customer
contact string Contact number of the customer

Response:

{
  "id": "cust_1Aa00000000003",
  "entity": "customer",
  "name": "Gaurav Kumar",
  "email": "Gaurav.Kumar@example.com",
  "contact": "9000000000",
  "gstin": null,
  "notes": {
    "notes_key_1": "Tea, Earl Grey, Hot",
    "notes_key_2": "Tea, Earl Grey… decaf."
  },
  "created_at": 1582033731
}

Fetch all customer

client.customer.all(options)

Parameters:

Name Type Description
count integer number of customers to fetch (default: 10)
skip integer number of customers to be skipped (default: 0)

Response:

{
  "entity":"collection",
  "count":1,
  "items":[
    {
      "id":"cust_1Aa00000000001",
      "entity":"customer",
      "name":"Gaurav Kumar",
      "email":"gaurav.kumar@example.com",
      "contact":"9876543210",
      "gstin":"29XAbbA4369J1PA",
      "notes":{
        "note_key_1":"September",
        "note_key_2":"Make it so."
      },
      "created_at ":1234567890
    }
  ]
}

Fetch a customer

client.customer.fetch(customerId)

Parameters:

Name Type Description
customerId* string The id of the customer to be fetched

Response:

{
  "id" : "cust_1Aa00000000001",
  "entity": "customer",
  "name" : "Saurav Kumar",
  "email" : "Saurav.kumar@example.com",
  "contact" : "+919000000000",
  "gstin":"29XAbbA4369J1PA",
  "notes" : [],
  "created_at ": 1234567890
}

PN: * indicates mandatory fields

For reference click here