This commit is contained in:
parent
b741692018
commit
3f0312500b
3 changed files with 44 additions and 11 deletions
45
src/api.ml
45
src/api.ml
|
|
@ -178,41 +178,42 @@ end
|
|||
module ExchangeVersionResponse = struct
|
||||
type t = {
|
||||
version: string;
|
||||
(* todo: const string
|
||||
name: "taler-exchange";*)
|
||||
(* todo jsont const string
|
||||
`name: "taler-exchange"` *)
|
||||
name: string;
|
||||
implementation: string option;
|
||||
currency: string;
|
||||
shopping_url: string option;
|
||||
open_banking_gateway: string option;
|
||||
currency_specification: CurrencySpecification.t;
|
||||
supported_kyc_requirements: string list;
|
||||
aml_spa_dialect: string option;
|
||||
}
|
||||
|
||||
let jsont =
|
||||
let make version implementation currency shopping_url open_banking_gateway
|
||||
currency_specification supported_kyc_requirements aml_spa_dialect =
|
||||
let make version name implementation currency shopping_url
|
||||
open_banking_gateway currency_specification aml_spa_dialect =
|
||||
{
|
||||
version;
|
||||
name;
|
||||
implementation;
|
||||
currency;
|
||||
shopping_url;
|
||||
open_banking_gateway;
|
||||
currency_specification;
|
||||
supported_kyc_requirements;
|
||||
aml_spa_dialect;
|
||||
}
|
||||
in
|
||||
let version v = v.version in
|
||||
let name v = v.name in
|
||||
let implementation v = v.implementation in
|
||||
let currency v = v.currency in
|
||||
let shopping_url v = v.shopping_url in
|
||||
let open_banking_gateway v = v.open_banking_gateway in
|
||||
let currency_specification v = v.currency_specification in
|
||||
let supported_kyc_requirements v = v.supported_kyc_requirements in
|
||||
let aml_spa_dialect v = v.aml_spa_dialect in
|
||||
map ~kind:"ExchangeVersionResponse" make
|
||||
|> mem "version" Jsont.string ~enc:version
|
||||
|> mem "name" Jsont.string ~enc:name
|
||||
|> mem "implementation" (Jsont.option Jsont.string) ~enc:implementation
|
||||
|> mem "currency" Jsont.string ~enc:currency
|
||||
|> mem "shopping_url" (Jsont.option Jsont.string) ~enc:shopping_url
|
||||
|
|
@ -221,12 +222,38 @@ module ExchangeVersionResponse = struct
|
|||
~enc:open_banking_gateway
|
||||
|> mem "currency_specification" CurrencySpecification.jsont
|
||||
~enc:currency_specification
|
||||
|> mem "supported_kyc_requirements" (Jsont.list Jsont.string)
|
||||
~enc:supported_kyc_requirements
|
||||
|> mem "aml_spa_dialect" (Jsont.option Jsont.string) ~enc:aml_spa_dialect
|
||||
|> finish
|
||||
end
|
||||
|
||||
let config =
|
||||
let currency_specification =
|
||||
let open Config.Currency in
|
||||
let alt_unit_names =
|
||||
Parse_config.Alt_unit_names.encode_exn v.alt_unit_names
|
||||
in
|
||||
CurrencySpecification.
|
||||
{
|
||||
name= v.name;
|
||||
num_fractional_input_digits= v.fractional_input_digits;
|
||||
num_fractional_normal_digits= v.fractional_normal_digits;
|
||||
num_fractional_trailing_zero_digits= v.fractional_trailing_zero_digits;
|
||||
alt_unit_names;
|
||||
common_amounts= [];
|
||||
}
|
||||
in
|
||||
ExchangeVersionResponse.
|
||||
{
|
||||
version= protocol_version;
|
||||
name= "taler-exchange";
|
||||
currency= Config.currency;
|
||||
currency_specification;
|
||||
implementation= None;
|
||||
shopping_url= None;
|
||||
open_banking_gateway= None;
|
||||
aml_spa_dialect= None;
|
||||
}
|
||||
|
||||
module RsaDenominationKey = struct
|
||||
type t = {
|
||||
age_mask: int;
|
||||
|
|
|
|||
|
|
@ -239,7 +239,6 @@ let mk_keys ~db_conn (module Sm : Secmod.S) ~last_issue_date =
|
|||
|
||||
let jsont = ExchangeKeysResponse.jsont
|
||||
|
||||
(* TODO query param ?last_issue_date *)
|
||||
let f req server _env =
|
||||
Logs.info (fun m -> m "GET /keys");
|
||||
let db_conn = Vif.Server.device Devices.db_connection server in
|
||||
|
|
|
|||
|
|
@ -13,6 +13,11 @@
|
|||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. *)
|
||||
|
||||
let config req _server _env =
|
||||
Logs.info (fun m -> m "GET /config");
|
||||
let s = Api.(encode_exn ExchangeVersionResponse.jsont config) in
|
||||
Respond_util.respond_with_ok_json s req
|
||||
|
||||
let hello req _server _env =
|
||||
let open Vif.Response in
|
||||
let open Syntax in
|
||||
|
|
@ -33,7 +38,9 @@ let routes =
|
|||
get_ (v "privacy") --> Static.privacy;
|
||||
]
|
||||
in
|
||||
let status_info = [ get_ (rel / "keys") --> Http_keys.f ] in
|
||||
let status_info =
|
||||
[ get_ (rel / "config") --> config; get_ (rel / "keys") --> Http_keys.f ]
|
||||
in
|
||||
let management =
|
||||
let open Http_management in
|
||||
let v s = rel / "management" / s in
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue