. */ declare(strict_types=1); namespace FireflyIII\Transformers\V2; use FireflyIII\Models\CurrencyExchangeRate; use Illuminate\Support\Collection; /** * Class AccountTransformer */ class ExchangeRateTransformer extends AbstractTransformer { /** * This method collects meta-data for one or all accounts in the transformer's collection. */ public function collectMetaData(Collection $objects): Collection { return $objects; } /** * Transform the account. */ public function transform(CurrencyExchangeRate $rate): array { return [ 'id' => (string) $rate->id, 'created_at' => $rate->created_at->toAtomString(), 'updated_at' => $rate->updated_at->toAtomString(), 'from_currency_id' => (string) $rate->fromCurrency->id, 'from_currency_code' => $rate->fromCurrency->code, 'from_currency_symbol' => $rate->fromCurrency->symbol, 'from_currency_decimal_places' => $rate->fromCurrency->decimal_places, 'to_currency_id' => (string) $rate->toCurrency->id, 'to_currency_code' => $rate->toCurrency->code, 'to_currency_symbol' => $rate->toCurrency->symbol, 'to_currency_decimal_places' => $rate->toCurrency->decimal_places, 'rate' => $rate->rate, 'date' => $rate->date->toAtomString(), 'links' => [ [ 'rel' => 'self', 'uri' => sprintf('/exchange-rates/%s', $rate->id), ], ], ]; } }