M4 API Exchange rate update

From Kolmisoft Wiki
Revision as of 11:29, 28 November 2022 by Admin (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

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