Difference between revisions of "NATS4 REST API Set Affiliate Settings"
From TMM Wiki
Jump to navigationJump to searchLine 4: | Line 4: | ||
== '''PATCH /affiliate/setsettings''' == | == '''PATCH /affiliate/setsettings''' == | ||
'''Description''' | '''Description''' | ||
− | *The /affiliate/setsettings endpoint is a feature in [[NATS4]] that allows you to change settings for your [[Ct#Affiliate|affiliates]] outside of the [[NATS]] system. The response contains one parameter named result. If the modification was successful then result will be 1. If it was not successful then the result will be 0. | + | *The /affiliate/setsettings endpoint is a feature in [[NATS4]] that allows you to change settings for your [[Ct#Affiliate|affiliates]] outside of the [[NATS]] system. The response contains one parameter named result. If the modification was successful then result will be 1 or greater. If it was not successful then the result will be 0. |
'''Resource URL''' | '''Resource URL''' | ||
Line 158: | Line 158: | ||
[ | [ | ||
{ | { | ||
− | "result": | + | "result": 2 |
} | } | ||
] | ] | ||
Line 164: | Line 164: | ||
== '''Example Code''' == | == '''Example Code''' == | ||
+ | |||
+ | |||
+ | '''PHP''' | ||
+ | <pre> | ||
+ | <?php | ||
+ | |||
+ | $data = array( | ||
+ | 'email_on_member_insufficient' => 1, | ||
+ | 'notify_password' => 1 | ||
+ | ); | ||
+ | |||
+ | $url = 'http://domain.com/api/affiliate/setsettings'; | ||
+ | $curl = curl_init(); | ||
+ | |||
+ | $headers = array( | ||
+ | 'api_key: 44b5498dbcb481a0d00b404c0169af62', | ||
+ | 'api_username: tmm1phrvezsbu' | ||
+ | ); | ||
+ | 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); | ||
+ | var_dump($resp); | ||
+ | //dumps an associative array representation of the json | ||
+ | var_dump(json_decode($resp, true)); | ||
+ | // Close request to clear up some resources | ||
+ | curl_close($curl); | ||
+ | ?> | ||
+ | |||
+ | </pre> | ||
+ | |||
+ | '''Python''' | ||
+ | *This example requires pip and the request library which can be installed via pip by: 'pip install requests' | ||
+ | <pre> | ||
+ | import requests | ||
+ | |||
+ | url = 'http://nats.tobias-dev.com/api/affiliate/setsettings' | ||
+ | headers = { | ||
+ | 'api_key': '44b5498dbcb481a0d00b404c0169af62', | ||
+ | 'api_username': 'tmm1phrvezsbu' | ||
+ | } | ||
+ | data = { | ||
+ | 'email_on_member_insufficient': 1, | ||
+ | 'notify_password': 1 | ||
+ | } | ||
+ | |||
+ | res = requests.patch(url, data=data, headers=headers) | ||
+ | print res.json() | ||
+ | |||
+ | </pre> | ||
+ | |||
+ | '''node.js''' | ||
+ | *This example requires npm and the request module which can be installed via npm by: 'npm install request' | ||
+ | <pre> | ||
+ | var request = require('request'); | ||
+ | |||
+ | var options = { | ||
+ | url: 'http://nats.tobias-dev.com/api/affiliate/setsettings', | ||
+ | method: 'PATCH', | ||
+ | json: true, | ||
+ | form: { | ||
+ | 'email_on_member_insufficient': 1, | ||
+ | 'notify_password': 1 | ||
+ | |||
+ | }, | ||
+ | headers: { | ||
+ | 'api_key': '44b5498dbcb481a0d00b404c0169af62', | ||
+ | 'api_username': 'tmm1phrvezsbu' | ||
+ | } | ||
+ | }; | ||
+ | |||
+ | function callback(error, response, body) { | ||
+ | if (!error && response.statusCode == 200) { | ||
+ | console.log(body); | ||
+ | } | ||
+ | else{ | ||
+ | console.log(body); | ||
+ | } | ||
+ | |||
+ | } | ||
+ | |||
+ | request(options, callback); | ||
+ | |||
+ | </pre> | ||
+ | |||
+ | |||
+ | [[Category:NATS4 API Articles]] |
Revision as of 00:22, 18 March 2015
PATCH /affiliate/setsettings
Description
- The /affiliate/setsettings endpoint is a feature in NATS4 that allows you to change settings for your affiliates outside of the NATS system. The response contains one parameter named result. If the modification was successful then result will be 1 or greater. If it was not successful then the result will be 0.
Resource URL
- http://domain/api/affiliate/setsettings
- Replace domain with the nats 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
- loginid: is the affiliates loginid
- type: integer
- required
- notify_password: is the notify_password value
- type: integer
- optional
- nofify_payvia: is the notify_payvia value
- type: integer
- optional
- notify_payvia_info: is the notify_payvia_info value
- type: integer
- optional
- notify_defaults: is the notify_defaults value
- type: integer
- optional
- notify_details: is the notify_details value
- type: integer
- optional
- notify_settings: is the notify_settings value
- type: integer
- optional
- notify_member_change: is the notify_member_change value
- type: integer
- optional
- notify_member_voiced: is the notify_member_voided value
- type: integer
- optional
- notify_member_chargeback: is the nofity_member_chargeback value
- type: integer
- optional
- notify_member_credited: is the notify_member_credited value
- type: integer
- optional
- notify_member_insufficient: is the notify_member_insufficient value
- type: integer
- optional
- notify_member_cancelled: is the notify_member_cancelled value
- type: integer
- optional
- notify_member_rebilled: is the notify_member_rebilled value
- type: integer
- optional
- notify_member_joined: is the notify_member_joined balue
- type: integer
- optional
- verify_details: is the verify_details value
- type: integer
- optional
- verify_settings: is the verify_settings value
- type: integer
- optional
- verify_defaults: is the veryify_defaults value
- type: integer
- optional
- verify_payvia: is the verify_payvia value
- type: integer
- optional
- verify_payvia_info: is the verify_payvia_info value
- type: integer
- optional
- email_promotional: is the email_promotional value
- type: integer
- optional
- email_on_notify: is the email_on_notify value
- type: integer
- optional
- email_on_member_change: is the email_on_member_change value
- type: integer
- optional
- email_on_member_voided: is the email_on_member_voided value
- type: integer
- optional
- email_on_member_chargeback: is the email_on_member_chargeback value
- type: integer
- optional
- email_on_member_credited: is the email_on_member_credited value
- type: integer
- optional
- email_on_member_insufficient: is the email_on_member_insufficient val
- type: integer
- optional
- email_on_member_cancelled: is the email_on_member_cancelled value
- type: integer
- optional
- email_on_member_rebilled: is the email_on_member_rebilled value
- type: integer
- optional
- email_on_member_joined: is the email_on_member_joined value
- type: integer
- optional
- access_preset: is the access_preset value
- type: integer
- optional
- post_member_approval: is the post_member_approval value
- type: integer
- optional
- post_member_rebill: is the post_member_rebill value
- type: integer
- optional
- post_member_upgrade: is the post_member_upgrade value
- type: integer
- optional
- post_member_expire: is the post_member_expire value
- type: integer
- optional
- post_member_insufficient: is the post_member_insufficient value
- type: integer
- optional
- post_member_credit: is the post_member_credit value
- type: integer
- optional
- post_member_chargeback: is the post_member_chargeback value
- type: integer
- optional
- post_member_void: is the post_member_void value
- type: integer
- optional
- post_member_upgradedeny: is the post_member_ugpradedeny value
- type: integer
- optional
- post_member_change_details: is the post_member_changedetails value
- type: integer
- optional
Example Request
PATCH
http://domain/api/v1/affiliate/setsettings
- Response:
[ { "result": 2 } ]
Example Code
PHP
<?php $data = array( 'email_on_member_insufficient' => 1, 'notify_password' => 1 ); $url = 'http://domain.com/api/affiliate/setsettings'; $curl = curl_init(); $headers = array( 'api_key: 44b5498dbcb481a0d00b404c0169af62', 'api_username: tmm1phrvezsbu' ); 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); var_dump($resp); //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 url = 'http://nats.tobias-dev.com/api/affiliate/setsettings' headers = { 'api_key': '44b5498dbcb481a0d00b404c0169af62', 'api_username': 'tmm1phrvezsbu' } data = { 'email_on_member_insufficient': 1, 'notify_password': 1 } res = requests.patch(url, data=data, 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'); var options = { url: 'http://nats.tobias-dev.com/api/affiliate/setsettings', method: 'PATCH', json: true, form: { 'email_on_member_insufficient': 1, 'notify_password': 1 }, headers: { 'api_key': '44b5498dbcb481a0d00b404c0169af62', 'api_username': 'tmm1phrvezsbu' } }; function callback(error, response, body) { if (!error && response.statusCode == 200) { console.log(body); } else{ console.log(body); } } request(options, callback);