+ AccountRestriction
This commit is contained in:
parent
3667b6a9dd
commit
8f5980e650
1 changed files with 45 additions and 0 deletions
45
src/api.ml
45
src/api.ml
|
|
@ -1086,3 +1086,48 @@ module ZeroLimitedOperation = struct
|
||||||
|> mem "operation_type" Account_operation.jsont ~enc:operation_type
|
|> mem "operation_type" Account_operation.jsont ~enc:operation_type
|
||||||
|> finish
|
|> finish
|
||||||
end
|
end
|
||||||
|
|
||||||
|
module RegexAccountRestriction = struct
|
||||||
|
type t = {
|
||||||
|
payto_regex: string;
|
||||||
|
human_hint: string;
|
||||||
|
(* Map from IETF BCP 47 language tags to localized human hints. *)
|
||||||
|
human_hint_i18n: string option;
|
||||||
|
}
|
||||||
|
|
||||||
|
let jsont =
|
||||||
|
let make payto_regex human_hint human_hint_i18n =
|
||||||
|
{ payto_regex; human_hint; human_hint_i18n }
|
||||||
|
in
|
||||||
|
let payto_regex v = v.payto_regex in
|
||||||
|
let human_hint v = v.human_hint in
|
||||||
|
let human_hint_i18n v = v.human_hint_i18n in
|
||||||
|
let open Jsont.Object in
|
||||||
|
map ~kind:"RegexAccountRestriction" make
|
||||||
|
|> mem "payto_regex" Jsont.string ~enc:payto_regex
|
||||||
|
|> mem "human_hint" Jsont.string ~enc:human_hint
|
||||||
|
|> opt_mem "human_hint_i18n" Jsont.string ~enc:human_hint_i18n
|
||||||
|
|> finish
|
||||||
|
end
|
||||||
|
|
||||||
|
module AccountRestriction = struct
|
||||||
|
type t =
|
||||||
|
| Deny
|
||||||
|
| Regex of RegexAccountRestriction.t
|
||||||
|
|
||||||
|
let of_regex v = Regex v
|
||||||
|
let of_deny () = Deny
|
||||||
|
|
||||||
|
let jsont =
|
||||||
|
let open Jsont.Object in
|
||||||
|
let regex = Case.map "regex" RegexAccountRestriction.jsont ~dec:of_regex in
|
||||||
|
let deny = Case.map "deny" Jsont.ignore ~dec:of_deny in
|
||||||
|
let enc_case = function
|
||||||
|
| Regex v -> Case.value regex v
|
||||||
|
| Deny -> Case.value deny ()
|
||||||
|
in
|
||||||
|
let cases = Case.[ make regex; make deny ] in
|
||||||
|
map ~kind:"AccountRestriction" Fun.id
|
||||||
|
|> case_mem "type" Jsont.string ~enc:Fun.id ~enc_case cases
|
||||||
|
|> finish
|
||||||
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue