Skip to content

Commit

Permalink
Expand api for exchange rates
Browse files Browse the repository at this point in the history
  • Loading branch information
JC5 committed Jan 26, 2025
1 parent 5e2f603 commit 12719a7
Show file tree
Hide file tree
Showing 8 changed files with 324 additions and 1 deletion.
4 changes: 4 additions & 0 deletions configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@
'description' => 'User groups are the objects around which "financial administrations" are built.',
'api_version' => ['v1'],
],
'currency_exchange_rates' => [
'description' => 'All currency exchange rates.',
'api_version' => ['v1'],
],

// v2 net worth
'net-worth' => ['description' => 'Shows you the net worth of the current user.', 'api_version' => ['v2']],
Expand Down
185 changes: 185 additions & 0 deletions yaml/v1/paths/models/currency-exchange-rate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
/exchange-rates:
get:
summary: List all exchange rates.
description: List exchange rates.
operationId: listCurrencyExchangeRates
tags:
- currency_exchange_rates
parameters:
!correlationParameter,3
!limitParameter,3
!pageParameter,3
responses:
"200":
description: A list of all available currency exchange rates.
content:
application/vnd.api+json:
schema:
$ref: '#/components/schemas/CurrencyExchangeRateArray'
!unauthenticatedResponse,3
!notFoundResponse,3
!badRequestResponse,3
!internalExceptionResponse,3
/exchange-rates/{id}:
get:
summary: List a single specific exchange rate.
description: List a single specific exchange rate
operationId: listSpecificCurrencyExchangeRate
tags:
- currency_exchange_rates
parameters:
!correlationParameter,3
!limitParameter,3
!pageParameter,3
- in: path
name: id
required: true
schema:
type: string
example: "123"
description: The ID of the requested currency exchange rate.
responses:
"200":
description: A list of currency exchange rates.
content:
application/vnd.api+json:
schema:
$ref: '#/components/schemas/CurrencyExchangeRateSingle'
!unauthenticatedResponse,3
!notFoundResponse,3
!badRequestResponse,3
!internalExceptionResponse,3
delete:
operationId: deleteSpecificCurrencyExchangeRate
description: "Delete a specific currency exchange rate."
summary: "Delete a specific currency exchange rate."
tags:
- currency_exchange_rates
parameters:
!correlationParameter,3
- in: path
name: id
required: true
schema:
type: string
example: "123"
description: The ID of the requested currency exchange rate.
responses:
"204":
description: "Currency exchange rate deleted."
!unauthenticatedResponse,3
!notFoundResponse,3
!badRequestResponse,3
!internalExceptionResponse,3
put:
summary: Update existing currency exchange rate.
description: |
Used to update a single currency exchange rate
operationId: updateCurrencyExchangeRate
parameters:
!correlationParameter,3
- in: path
name: id
required: true
schema:
type: string
example: "123"
description: The ID of the currency exchange rate.
tags:
- links
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/CurrencyExchangeRateUpdate'
application/x-www-form-urlencoded:
schema:
$ref: '#/components/schemas/CurrencyExchangeRateUpdate'
description: JSON array or formdata with updated exchange rate information. See the model for the exact specifications.
required: true
responses:
"200":
description: 'Updated exchange rate stored, result in response'
content:
application/vnd.api+json:
schema:
$ref: '#/components/schemas/CurrencyExchangeRateSingle'
!validationErrorResponse,3
!unauthenticatedResponse,3
!notFoundResponse,3
!badRequestResponse,3

/exchange-rates/rates/{from}/{to}:
get:
summary: List all exchange rate from/to the mentioned currencies.
description: List all exchange rate from/to the mentioned currencies.
operationId: listSpecificCurrencyExchangeRates
tags:
- currency_exchange_rates
parameters:
!correlationParameter,3
!limitParameter,3
!pageParameter,3
- in: path
name: from
required: true
schema:
type: string
example: "EUR"
description: "The currency code of the 'from' currency."
- in: path
name: from
required: true
schema:
type: string
example: "USD"
description: "The currency code of the 'to' currency."
responses:
"200":
description: A list of currency exchange rates.
content:
application/vnd.api+json:
schema:
$ref: '#/components/schemas/CurrencyExchangeRateArray'
!unauthenticatedResponse,3
!notFoundResponse,3
!badRequestResponse,3
!internalExceptionResponse,3
delete:
operationId: deleteSpecificCurrencyExchangeRates
description: "Delete all currency exchange rates from 'from' to 'to' on a specific date or today."
summary: "Delete all currency exchange rates from 'from' to 'to'."
tags:
- currency_exchange_rates
parameters:
!correlationParameter,3
- in: path
name: from
required: true
schema:
type: string
example: "EUR"
description: "The currency code of the 'from' currency."
- in: path
name: from
required: true
schema:
type: string
example: "USD"
description: "The currency code of the 'to' currency."
- in: query
name: date
description: |
A date formatted YYYY-MM-DD. Defaults to today.
required: false
schema:
type: string
format: date
example: "2018-09-17"
responses:
"204":
description: "Currency exchange rate(s) deleted."
!unauthenticatedResponse,3
!notFoundResponse,3
!badRequestResponse,3
!internalExceptionResponse,3
15 changes: 15 additions & 0 deletions yaml/v1/schemas/arrays/CurrencyExchangeRateArray.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
CurrencyExchangeRateArray:
type: object
required:
- data
- meta
- links
properties:
data:
type: array
items:
$ref: '#/components/schemas/CurrencyExchangeRateRead'
meta:
$ref: '#/components/schemas/Meta'
links:
$ref: '#/components/schemas/PageLink'
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
CurrencyExchangeRateRead:
type: object
required:
- type
- id
- attributes
- links
properties:
type:
type: string
format: string
example: "currency_exchange_rates"
description: "Immutable value"
id:
type: string
format: string
example: "2"
attributes:
$ref: '#/components/schemas/CurrencyExchangeRateReadAttributes'
links:
$ref: '#/components/schemas/ObjectLink'
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
CurrencyExchangeRateReadAttributes:
type: object
properties:
created_at:
type: string
format: date-time
example: "2018-09-17T12:46:47+01:00"
readOnly: true
updated_at:
type: string
format: date-time
example: "2018-09-17T12:46:47+01:00"
readOnly: true
from_currency_id:
type: string
format: string
example: "12"
readOnly: true
description: "Base currency ID for this exchange rate entry."
from_currency_code:
type: string
format: string
example: "EUR"
readOnly: true
description: "Base currency code for this exchange rate entry."
from_currency_symbol:
type: string
format: string
example: "$"
readOnly: true
description: "Base currency symbol for this exchange rate entry."
from_currency_decimal_places:
type: integer
format: int32
example: 2
readOnly: true
description: "Base currency decimal places for this exchange rate entry."
to_currency_id:
type: string
format: string
example: "12"
readOnly: true
description: "Destination currency ID for this exchange rate entry."
to_currency_code:
type: string
format: string
example: "EUR"
readOnly: true
description: "Destination currency code for this exchange rate entry."
to_currency_symbol:
type: string
format: string
example: "$"
readOnly: true
description: "Destination currency symbol for this exchange rate entry."
to_currency_decimal_places:
type: integer
format: int32
example: 2
readOnly: true
description: "Destination currency decimal places for this exchange rate entry."
rate:
type: string
format: string
example: "1.10340"
readOnly: true
description: "The actual exchange rate. How many 'to' currency will you get for 1 'from' currency?"
date:
type: string
format: date-time
readOnly: true
example: "2018-09-17T12:46:47+01:00"
description: "Date and time of the exchange rate."
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CurrencyExchangeRateSingle:
type: object
required:
- data
properties:
data:
$ref: '#/components/schemas/CurrencyExchangeRateRead'
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
CurrencyExchangeRateUpdate:
type: object
required:
- date
- rate
properties:
date:
type: string
format: date
example: "2018-09-17"
description: The date to which the exchange rate is applicable.
nullable: false
rate:
type: string
format: string
nullable: false
example: "2.3456"
description: "The exchange rate from the base currency to the destination currency."
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ UserGroupReadAttributes:
can_see_members:
type: boolean
format: boolean
example: false
example: true
readOnly: true
description: "Can the current user see the members of this user group?"
title:
Expand Down

0 comments on commit 12719a7

Please sign in to comment.