Difference between revisions of "Offerit REST API Set Currency Exchange Rates"
From Offerit
Offeritnick (talk | contribs) |
Offeritnick (talk | contribs) |
||
| Line 3: | Line 3: | ||
}} | }} | ||
<font color="red">* COMING SOON *</font> | <font color="red">* COMING SOON *</font> | ||
| − | == '''PATCH / | + | == '''PATCH /service/set_currency_exchange_rates''' == |
'''Description''' | '''Description''' | ||
| Line 9: | Line 9: | ||
'''Resource URL''' | '''Resource URL''' | ||
| − | *<nowiki>http://domain/api/ | + | *<nowiki>http://domain/api/service/set_currency_exchange_rates</nowiki> |
| Line 37: | Line 37: | ||
<pre> | <pre> | ||
<?php | <?php | ||
| − | $url = 'http://domain/api/ | + | $url = 'http://domain/api/service/set_currency_exchange_rates'; |
$curl = curl_init(); | $curl = curl_init(); | ||
Latest revision as of 12:30, 16 July 2019
* COMING SOON *
PATCH /service/set_currency_exchange_rates
Description
- Sets currency exchange rates in your configuration. For example, in the Configuration Admin, "Currency - All" section, you can update the value for a rate such as "EUR Exchange Rate to USD".
Resource URL
- http://domain/api/service/set_currency_exchange_rates
Response Format
- JSON
- PATCH
- HTTP headers
Parameters
- base
- type: string
- required
- base currency to set rates for
- rates
- type: array
- required
- Array of other currencies with the conversion rate to the "base" parameter above.
Example Code
PHP
<?php
$url = 'http://domain/api/service/set_currency_exchange_rates';
$curl = curl_init();
$headers = array(
'api-key: 44b5498dbcb481a0d00b404c0169af62',
'api-username: productsupport'
);
$data = Array(
'base' => 'USD',
'rates' => Array(
'EUR' => 0.8639308856,
'AUD' => 1.4094168468,
'CAD' => 1.3047084234,
),
);
$data_string = http_build_query($data);
$url .= '?'.$data_string;
curl_setopt($curl, CURLOPT_GET, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_URL, $url);
$resp = curl_exec($curl);
//dumps an associative array representation of the json response
$output = json_decode($resp, true);
if($output !== NULL) {
//json was valid. Dump the decoded array
print_r($output);
}
else {
//invalid json, just dump the raw response
print_r($resp);
}
// Close request to clear up some resources
curl_close($curl);
?>
Example Output
Array
(
[result] => success
[message] => Saved new rates to config. EUR: 0.8639308856; AUD: 1.4094168468; CAD: 1.3047084234;
)