Difference between revisions of "Create Customer Sites"
(→JSON As Body) |
m (Paul moved page Create Customer Contacts to Create Customer Sites) |
||
| (7 intermediate revisions by 4 users not shown) | |||
| Line 1: | Line 1: | ||
| + | In the portal, a Customer Contact is now referred to as a Customer Site. | ||
| + | |||
== Summary == | == Summary == | ||
| Line 84: | Line 86: | ||
| varchar(45) || ✓ | | varchar(45) || ✓ | ||
|- | |- | ||
| + | ! contact_email | ||
| + | | varchar(255) || | ||
| + | |- | ||
| + | ! sic_code | ||
| + | | int(11) || | ||
| + | |- | ||
|} | |} | ||
| Line 123: | Line 131: | ||
"address_4":"address 5", | "address_4":"address 5", | ||
"postcode":"WA12 0JQ", | "postcode":"WA12 0JQ", | ||
| − | "contact_number":"01234567891" | + | "contact_number":"01234567891", |
| + | "sic_code":074313, | ||
| + | "contact_email":"stephen@mymobileworkers.com" | ||
} | } | ||
] | ] | ||
| Line 147: | Line 157: | ||
"address_4":"address 5", | "address_4":"address 5", | ||
"postcode":"WA12 0JQ", | "postcode":"WA12 0JQ", | ||
| − | "contact_number":"01234567891" | + | "contact_number":"01234567891", |
| + | "sic_code":074313, | ||
| + | "contact_email":"stephen@mymobileworkers.com" | ||
} | } | ||
] | ] | ||
| Line 157: | Line 169: | ||
==== Multi Part Form Data ==== | ==== Multi Part Form Data ==== | ||
| − | curl -F validate_only=false -F update_existing=true -F api_key=testkey -F file=@/Users/testuser/Desktop/webAPICurling/create_customer_contacts.txt http:// | + | curl -F validate_only=false -F update_existing=true -F api_key=testkey -F file=@/Users/testuser/Desktop/webAPICurling/create_customer_contacts.txt http://api.mymobileworkers.com:8080/api/1/companies/company/customers/contacts |
==== JSON As Body ==== | ==== JSON As Body ==== | ||
| − | curl -X POST -H "Content-Type: application/json" -d '{"key":"x4IOX6J3RcESDsN0kBAd","validate_only":"false","update_existing":"true","customer_contacts":[{"external_id":"ExtIdTest","contact_name":"Steve G","customer_id":{"name":"Above Average Construction Ltd."},"address_1":"Unit 5","address_2":"Random Industrial Estate","address_3":"Little Lane,"address_4":"Somewhere","postcode":" | + | curl -X POST -H "Content-Type: application/json" -d '{"key":"x4IOX6J3RcESDsN0kBAd","validate_only":"false","update_existing":"true","customer_contacts":[{"external_id":"ExtIdTest","contact_name":"Steve G","customer_id":{"name":"Above Average Construction Ltd."},"address_1":"Unit 5","address_2":"Random Industrial Estate","address_3":"Little Lane","address_4":"Somewhere","postcode":"WA12JQ","contact_number":"01512143108","sic_code":2323525,"contact_email":"stephen@mymobileworkers.com"}]}' http://api.mymobileworkers.com:8080/api/1/companies/company/customers/contacts |
== Responses == | == Responses == | ||
Latest revision as of 14:04, 31 January 2017
In the portal, a Customer Contact is now referred to as a Customer Site.
Contents |
[edit] Summary
The create customer contacts action allows users to attach a contacts to a customer. This method accepts an array of contacts to be added to the system. A contact 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.
[edit] Multi Part Form Data
| Create Customer Contact | ||
|---|---|---|
| URL | http://base_url/api_path/version/companies/company/customers/contacts | |
| Type | POST | |
| Params: | api_key | required |
| file | required | |
| Response | JSON | |
[edit] JSON As Body
| Create Customer Contact - JSON | ||
|---|---|---|
| URL | http://base_url/api_path/version/companies/company/customers/contacts | |
| Type | POST | |
| JSON {key, validate_only(optional), update_existing(optional), customers[]} |
required | |
| Response | JSON | |
[edit] JSON Contents
| Standard Fields | ||
|---|---|---|
| Field | Expected Data | Required |
| customer | {"name":"<customer name>"} *nested JSON object |
✓ |
| contact_name | varchar(45) | ✓ |
| external_id | varchar(45) | |
| address_1 | varchar(45) | ✓ |
| address_2 | varchar(45) | |
| address_3 | varchar(45) | |
| address_4 | varchar(45) | |
| postcode | varchar(45) | ✓ |
| contact_number | varchar(45) | ✓ |
| contact_email | varchar(255) | |
| sic_code | int(11) | |
| Standard Fields | ||
|---|---|---|
| Field | Expected Data | Required |
| key | string - company api key | ✓ |
| update_existing | boolean | |
| validate_only | boolean | |
[edit] Example Input
[edit] Multi Part Form Data
{ "customer_contacts":[ { "external_id":"Contact1", "contact_name":"test_contact", "customer_id":{ "name":"test" }, "address_1":"8 The Parks", "address_2":"address 3", "address_3":"address 4", "address_4":"address 5", "postcode":"WA12 0JQ", "contact_number":"01234567891", "sic_code":074313, "contact_email":"stephen@mymobileworkers.com" } ] }
[edit] JSON As Body
{ "key":"testkey", "validate_only":"false", "update_existing":"true", "customer_contacts":[ { "external_id":"Contact1", "contact_name":"test_contact", "customer_id":{ "name":"test" }, "address_1":"8 The Parks", "address_2":"address 3", "address_3":"address 4", "address_4":"address 5", "postcode":"WA12 0JQ", "contact_number":"01234567891", "sic_code":074313, "contact_email":"stephen@mymobileworkers.com" } ] }
[edit] Example Curl Requests
[edit] Multi Part Form Data
curl -F validate_only=false -F update_existing=true -F api_key=testkey -F file=@/Users/testuser/Desktop/webAPICurling/create_customer_contacts.txt http://api.mymobileworkers.com:8080/api/1/companies/company/customers/contacts
[edit] JSON As Body
curl -X POST -H "Content-Type: application/json" -d '{"key":"x4IOX6J3RcESDsN0kBAd","validate_only":"false","update_existing":"true","customer_contacts":[{"external_id":"ExtIdTest","contact_name":"Steve G","customer_id":{"name":"Above Average Construction Ltd."},"address_1":"Unit 5","address_2":"Random Industrial Estate","address_3":"Little Lane","address_4":"Somewhere","postcode":"WA12JQ","contact_number":"01512143108","sic_code":2323525,"contact_email":"stephen@mymobileworkers.com"}]}' http://api.mymobileworkers.com:8080/api/1/companies/company/customers/contacts
[edit] Responses
[edit] Example JSON
{ "successful":[ { "contact_name":"test_contact" } ], "failed":[ { "contact_name":"test_contact", "errors":[ { "error_code":"CCV002", "error_message":"Address 1 cannot be null." } ] } ] }