Difference between revisions of "M4 API Exchange rate update"

From Kolmisoft Wiki
Jump to navigationJump to search
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
=Description=
=Description=
[[M2 API]] Exchange rate update. API method used to update Currency exchange rates.
[[M4 API]] Exchange rate update. API method used to update Currency exchange rates.
<br>
<br>
=Usage=
=Usage=
* Call: /api/exchange_rate_update.
* Call: /api/exchange_rate_update.
* Methods: POST, GET (if allowed, not recomended).
* Methods: POST, GET (if allowed, not recommended).
* Only System Admin and Managers (with a Currency Management Permission) can use this API method.
* Only System Admin and Managers (with Currency Management Permission) can use this API method.
<br>
<br>
===Parameters===
===Parameters===
Parameters which are '''included''' into hash:
Parameters which are '''included''' into hash:


* currency - name of a Currency (case sensitive) e.g. USD. '''Required'''.
* currency - the name of a Currency (case sensitive) e.g. USD. '''Required'''.
* rate - exchange rate. '''Required'''.
* rate - the exchange rate. '''Required'''.
<br>
<br>
Parameters which are '''not included''' into hash:
Parameters which are '''not included''' into hash:
Line 36: Line 36:
'''Errors'''
'''Errors'''


* <error>Access Denied</error> - User is not authorized or is a Simple User. Only Admin and Managers (with a Currency Management Permission) can use this API method.  
* <error>Access Denied</error> - User is not authorized or is a Simple User. Only Admin and Managers (with Currency Management Permission) can use this API method.  
* <error>You are not authorized to use this functionality</error> - Manager has not permission to use this API method.  
* <error>You are not authorized to use this functionality</error> - The manager has not permission to use this API method.  
* <error>Incorrect hash</error> - hash is not correct. Check API_Secret_Key and order of parameters while concatenating a hash_string.
* <error>Incorrect hash</error> - hash is not correct. Check API_Secret_Key and the order of parameters while concatenating a hash_string.
* <error>Exchange rate is invalid</error> - Exchange rate is not a valid number.  
* <error>Exchange rate is invalid</error> - Exchange rate is not a valid number.  
* <error>Currency was not found</error> - Currency was not found by its name or an automatic update is enabled for it.  
* <error>Currency was not found</error> - Currency was not found by its name or an automatic update is enabled for it.  
Line 50: Line 50:
   </status>
   </status>
  </page>
  </page>
<br>
<br><br>
 
=See also=
=See also=


* [[M2 API]]
* [[M4 API]]

Latest revision as of 11:29, 28 November 2022

Description

M4 API Exchange rate update. API method used to update Currency exchange rates.

Usage

  • Call: /api/exchange_rate_update.
  • Methods: POST, GET (if allowed, not recommended).
  • Only System Admin and Managers (with Currency Management Permission) can use this API method.


Parameters

Parameters which are included into hash:

  • currency - the name of a Currency (case sensitive) e.g. USD. Required.
  • rate - the exchange rate. Required.


Parameters which are not included into hash:

  • hash - SHA1 hash constructed using the parameters which are listed above. Note that the parameters are shown in the same order as they need to be when generating the hash. The last parameter in a row is API_Secret_Key ( More described in Constructing hash). Required.
  • u - username for authentication. Required.

NOTE Only Currencies which have the automatic update disabled can be used in this API.

Request

We have u = admin, API Secret Key = secret. We send:

HTML POST:http://<SERVER_IP>/billing/api/exchange_rate_update?u=admin&currency=AMD&rate=45.5&hash=cd4e5e92a0fe326d6f5c1d40a7952bb4442e1b5d

Returns

Success

<?xml version="1.0" encoding="UTF-8"?>
<page>
  <status>
    <success>Currency successfully updated</success>
  </status>
</page>


Errors

  • <error>Access Denied</error> - User is not authorized or is a Simple User. Only Admin and Managers (with Currency Management Permission) can use this API method.
  • <error>You are not authorized to use this functionality</error> - The manager has not permission to use this API method.
  • <error>Incorrect hash</error> - hash is not correct. Check API_Secret_Key and the order of parameters while concatenating a hash_string.
  • <error>Exchange rate is invalid</error> - Exchange rate is not a valid number.
  • <error>Currency was not found</error> - Currency was not found by its name or an automatic update is enabled for it.

Example:

<?xml version="1.0" encoding="UTF-8"?>
<page>
  <status>
    <error>Exchange rate is invalid</error>
  </status>
</page>



See also