Blesta Source Documentation

ExchangeRate

AbstractYes

Abstract class that all Currency Exchange Rate Processors must extend

Attributes
#[AllowDynamicProperties]
Table of Contents

Properties

$key

Methods

__construct() Initializes the exchange rate processor
getRate() Fetches the exchange rate from currency A to currency B using the given amount
requiresKey() Determines whether an API key is necessary to retrieve exchange rates via the processor
setKey() Sets the API key necessary to retrieve exchange rates
convertRates() Updates all currency rates given to convert the rates relative to the given currency
Properties
Methods

__construct()

Initializes the exchange rate processor

public abstract __construct(Http $Http) : mixed
Parameters
$Http : Http

The Http component to more easily facilitate HTTP requests to fetch data

getRate()

Fetches the exchange rate from currency A to currency B using the given amount

public abstract getRate(string $currency_from, string $currency_to[, float $amount = 1.0 ]) : mixed
Parameters
$currency_from : string

The ISO 4217 currency code to convert from

$currency_to : string

The ISO 4217 currency code to convert to

$amount : float = 1.0

The amount to convert

Return values
mixed

(bool) false on error or an array containing the exchange rate information including:

  • rate
  • updated The date/time of the last update in YYYY-MM-DD HH:MM:SS format in UTC time

requiresKey()

Determines whether an API key is necessary to retrieve exchange rates via the processor

public requiresKey() : bool
Return values
bool

True if an API key is required, or false otherwise

setKey()

Sets the API key necessary to retrieve exchange rates

public setKey(string $key) : mixed
Parameters
$key : string

The key for the exchange rate processor API

convertRates()

Updates all currency rates given to convert the rates relative to the given currency

protected convertRates(string $to_currency, array<string|int, mixed> $rates) : array<string|int, mixed>
Parameters
$to_currency : string

The ISO 4217 currency code to convert relative to

$rates : array<string|int, mixed>

A key/value list of all currencies and their rates. The $to_currency must be in the list

Return values
array<string|int, mixed>

A key/value list of all currency exchange rates

Tags
subpackage

components.exchangerates

copyright

Copyright (c) 2010-2017, Phillips Data, Inc.

license

http://www.blesta.com/license/ The Blesta License Agreement

link

Blesta


        
On this page

Search results