Difference between revisions of "Offerit REST API Set Customer Details"
From Offerit
Offeritnick (talk | contribs) (Created page with "{{Offerit Manual | show_rest_api_section = true }} == '''PATCH /customer/set_customer_details''' == '''Description''' *The api/customer/set_customer_details action is a feat...") |
Offeritnick (talk | contribs) (→Parameters) |
||
Line 24: | Line 24: | ||
'''If you want to remove a field you can pass in the string REMOVE and the field will be removed. All additional parameters have this option other then 'password'. At least one optional parameter must be passed in.''' | '''If you want to remove a field you can pass in the string REMOVE and the field will be removed. All additional parameters have this option other then 'password'. At least one optional parameter must be passed in.''' | ||
− | '''You need to pass | + | '''You need to pass either customer_id or subscription for customer lookup otherwise the call will fail''' |
*customer_id is used to pass in the customer_id of the customer to modify | *customer_id is used to pass in the customer_id of the customer to modify |
Revision as of 17:28, 27 July 2017
PATCH /customer/set_customer_details
Description
- The api/customer/set_customer_details action is a feature in Offerit that allows you to set the customer details for an Offerit customer record.
Resource URL
- http://domain/api/customer/set_customer_details
- Replace domain with the offerit domain
- PATCH
Response Format
- JSON
- HTTP headers
Parameters
Paremeters must be sent with the request body. The examples below show the parameters sent as x-www-form-urlencoded
If you want to remove a field you can pass in the string REMOVE and the field will be removed. All additional parameters have this option other then 'password'. At least one optional parameter must be passed in.
You need to pass either customer_id or subscription for customer lookup otherwise the call will fail
- customer_id is used to pass in the customer_id of the customer to modify
- type: string
- optional
- subscription is used to pass in the subscription of the customer to modify
- type: string
- optional
- firstname is used to pass in the first name of the customer
- type: string
- optional
- lastname is used to pass in the last name of the customer
- type: string
- optional
- email is used to pass in the email address of the customer
- type: string
- optional
- address1 is used to pass in the address of the customer
- type: string
- optional
- address2 is used to pass in the address of the customer
- type: string
- optional
- city is used to pass in the city of the customer
- type: string
- optional
- state is used to pass in the state of the customer
- type: string
- optional
- country is used to pass in the country of the customer
- type: string
- optional
- zip is used to pass in the zip code of the customer
- type: string
- optional
- custom1 is used to pass in the custom1 field of the customer
- type: string
- optional
- custom2 is used to pass in the custom2 field of the customer
- type: string
- optional
- custom3 is used to pass in the custom3 field of the customer
- type: string
- optional
- custom4 is used to pass in the custom4 field of the customer
- type: string
- optional
- custom5 is used to pass in the custom5 field of the customer
- type: string
- optional
- password is used to pass in the new password of the customer
- type: string
- optional
- username is used to pass in the new username of the customer
- type: string
- optional
Example Request
PATCH
http://domain/api/customer/set_customer_details
- Response:
true
Example Code
PHP
<?php $curl = curl_init(); $data = array( 'customer_id' => 191, 'firstname' => 'Test', 'zip' => '66666', 'email' => 'test@testmail.com', 'country' => 'US', ); $url = 'http://domain/api/customer/set_customer_details'; $headers = array( 'api-key: 44b5498dbcb481a0d00b404c0169af62', 'api-username: offerit_admin' ); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PATCH"); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data)); curl_setopt($curl, CURLOPT_URL, $url); $resp = curl_exec($curl); //dumps an associative array representation of the json var_dump(json_decode($resp, true)); // Close request to clear up some resources curl_close($curl); ?>
Python
- This example requires pip and the request library which can be installed via pip by: 'pip install requests'
import requests import json url = 'http://domain/api/customer/set_customer_details' payload = { 'customer_id': 191, 'firstname': 'Test', 'zip': '66666', 'email': 'test@testmail.com', 'country': 'US' } headers = { 'api-key': '44b5498dbcb481a0d00b404c0169af62', 'api-username': 'offerit_admin' } res = requests.patch(url, data=payload, headers=headers) print res.json()
node.js
- This example requires npm and the request module which can be installed via npm by: 'npm install request'
var request = require('request'); data = { 'customer_id': 191, 'firstname': 'Test', 'zip': '66666', 'email': 'test@testmail.com', 'country': 'US' } var options = { url: 'http://domain/api/customer/set_customer_details', method: 'PATCH', form: data, json: true, headers: { 'api-key': '44b5498dbcb481a0d00b404c0169af62', 'api-username': 'offerit_admin' } }; function callback(error, response, body) { if (!error && response.statusCode == 200) { console.log(body); } else{ console.log(body); } } request(options, callback);
Curl
curl -X PATCH 'http://domain/api/customer/set_customer_details' -H "api-key: 44b5498dbcb481a0d00b404c0169af62" -H "api-username: offerit_admin" -H "Content-Type: application/x-www-form-urlencoded" -d 'customer_id=191&firstname=Test&zip=66666&email=test@testmail.com&country=US'