Difference between revisions of "Add Customer"
(→Example JSON) |
|||
| Line 29: | Line 29: | ||
|} | |} | ||
| − | ==== JSON As Body ==== | + | ==== JSON As Body (13.6) ==== |
{| border="1" class="wikitable" | {| border="1" class="wikitable" | ||
! Add Customer - JSON | ! Add Customer - JSON | ||
| Line 84: | Line 84: | ||
{| border="1" class="wikitable" | {| border="1" class="wikitable" | ||
| − | |+ Fields exclusive to JSON body format: | + | |+ Fields exclusive to JSON body format (13.6): |
! colspan="3" | Standard Fields | ! colspan="3" | Standard Fields | ||
|- | |- | ||
| Line 118: | Line 118: | ||
</source> | </source> | ||
| − | ==== JSON As Body ==== | + | ==== JSON As Body (13.6) ==== |
<source lang="java"> | <source lang="java"> | ||
{"key":"test", "validate_only":"true", "update_existing":"true", "customers":[ | {"key":"test", "validate_only":"true", "update_existing":"true", "customers":[ | ||
| Line 138: | Line 138: | ||
curl -F validate_only=false -F update_existing=true -F api_key=YOURKEY -F file=@/Users/lee_orritt/Desktop/webAPICurling/create_customer.txt http://test.mymobileworkers.com:8080/api/1/companies/company/customers/customer | curl -F validate_only=false -F update_existing=true -F api_key=YOURKEY -F file=@/Users/lee_orritt/Desktop/webAPICurling/create_customer.txt http://test.mymobileworkers.com:8080/api/1/companies/company/customers/customer | ||
| − | ==== JSON As Body ==== | + | ==== JSON As Body (13.6) ==== |
curl -X POST -H "Content-Type: application/json" -d '{"key":"darrenwebapi", "validate_only":"false", "update_existing":true,"customers":[{"name":"LeeLand","contact_name":"testName","address_1":"1 the street","postcode":"WA12 0JQ","contact_number":"01942295900"}]}' http://live.mymobileworkers.com:8080/api/1/companies/company/customers/customer | curl -X POST -H "Content-Type: application/json" -d '{"key":"darrenwebapi", "validate_only":"false", "update_existing":true,"customers":[{"name":"LeeLand","contact_name":"testName","address_1":"1 the street","postcode":"WA12 0JQ","contact_number":"01942295900"}]}' http://live.mymobileworkers.com:8080/api/1/companies/company/customers/customer | ||
Revision as of 12:18, 28 August 2013
Contents |
Summary
The add customer action allows users to attach a customer to their company. This method accepts an array of customers to be added to the system. A customer can be created via two different methods - either as multi-part form data with a JSON file attached and the API key as a parameter, or as JSON content on it's own, with the API key supplied within the JSON.
Multi Part Form Data
| Add Customer | ||
|---|---|---|
| URL | http://base_url/api_path/version/companies/company/customers/customer | |
| Type | POST | |
| Params: | api_key | required |
| file | required | |
| Response | JSON | |
JSON As Body (13.6)
| Add Customer - JSON | ||
|---|---|---|
| URL | http://base_url/api_path/version/companies/company/customers/customer | |
| Type | POST | |
| JSON {key, validate_only(optional), update_existing(optional), customers[]} |
required | |
| Response | JSON | |
JSON Contents
| Standard Fields | ||
|---|---|---|
| Field | Expected Data | Required |
| contact_name | varchar(45) * must be unique |
✓ |
| name | varchar(255) | |
| address_1 | varchar(45) | |
| address_2 | varchar(45) | |
| address_3 | varchar(45) | |
| address_4 | varchar(45) | |
| postcode | varchar(45) | |
| contact_number | varchar(45) | |
| Standard Fields | ||
|---|---|---|
| Field | Expected Data | Required |
| key | string - company api key | ✓ |
| updating_existing | boolean | |
| validate_only | boolean | |
Example Input
Multi Part Form Data
"customers":[ { "name":"LeeLand", "contact_name":"Mark Moose", "address_1":"1 the street", "postcode":"WA12 0JQ", "contact_number":"01942295900" } ]
JSON As Body (13.6)
{"key":"test", "validate_only":"true", "update_existing":"true", "customers":[ { "name":"LeeLand", "contact_name":"Mark Moose", "address_1":"1 the street", "postcode":"WA12 0JQ", "contact_number":"01942295900" } ] }
Example Curl Requests
Multi Part Form Data
curl -F validate_only=false -F update_existing=true -F api_key=YOURKEY -F file=@/Users/lee_orritt/Desktop/webAPICurling/create_customer.txt http://test.mymobileworkers.com:8080/api/1/companies/company/customers/customer
JSON As Body (13.6)
curl -X POST -H "Content-Type: application/json" -d '{"key":"darrenwebapi", "validate_only":"false", "update_existing":true,"customers":[{"name":"LeeLand","contact_name":"testName","address_1":"1 the street","postcode":"WA12 0JQ","contact_number":"01942295900"}]}' http://live.mymobileworkers.com:8080/api/1/companies/company/customers/customer
Responses
Example JSON
{ "file":"tick.png", "comment":"Transferred from API", "created_at":"2013-05-20T14:42:37+00:00" }