Difference between revisions of "M4 API Exchange rate update"

From Kolmisoft Wiki
Jump to navigationJump to search
(Created page with '=Description= M2 API Exchange rate update. API method used to update Currency exchange rates. <br> =Usage= * Call: /api/exchange_rate_update. * Methods: POST, GET (if allowed…')
 
Line 54: Line 54:
=See also=
=See also=


* [[MOR API]]
* [[M2 API]]

Revision as of 13:36, 2 May 2017

Description

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

Usage

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


Parameters

Parameters which are included into hash:

  • currency - name of a Currency (case sensitive) e.g. USD. Required.
  • rate - 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 a 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>Incorrect hash</error> - hash is not correct. Check API_Secret_Key and 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