open_payments/types

Types

The access rights granted to (or requested for) an access token. Shared by grant requests and access token responses.

pub type Access {
  AccessIncoming(
    actions: List(IncomingAction),
    identifier: option.Option(String),
  )
  AccessOutgoing(
    actions: List(OutgoingAction),
    identifier: String,
    limits: option.Option(Limits),
  )
  AccessQuote(actions: List(QuoteAction))
}

Constructors

See https://openpayments.dev/apis/auth-server/operations/post-token/

pub type AccessTokenResponse {
  AccessTokenResponse(
    value: String,
    manage: String,
    expires_in: option.Option(Int),
    access: List(Access),
  )
}

Constructors

  • AccessTokenResponse(
      value: String,
      manage: String,
      expires_in: option.Option(Int),
      access: List(Access),
    )

A monetary amount, expressed as a value in the asset’s minor unit together with the asset code and scale needed to interpret it.

pub type Amount {
  Amount(value: String, asset_code: String, asset_scale: Int)
}

Constructors

  • Amount(value: String, asset_code: String, asset_scale: Int)

A debitAmount/receiveAmount pair, of which at most one is present. Shared by outgoing payment grant limits and quote creation.

pub type AmountOption {
  NoAmount
  DebitAmount(Amount)
  ReceiveAmount(Amount)
}

Constructors

The actions that can be granted or exercised on incoming payments.

pub type IncomingAction {
  IncomingCreate
  IncomingComplete
  IncomingRead
  IncomingReadAll
  IncomingList
  IncomingListAll
}

Constructors

  • IncomingCreate
  • IncomingComplete
  • IncomingRead
  • IncomingReadAll
  • IncomingList
  • IncomingListAll

A public key in JWK format, as published on a wallet address’s JWKS endpoint or sent as part of a client-directed-identity grant request.

pub type Key {
  Key(
    kid: String,
    x: String,
    alg: String,
    kty: String,
    crv: String,
    use_: String,
  )
}

Constructors

  • Key(
      kid: String,
      x: String,
      alg: String,
      kty: String,
      crv: String,
      use_: String,
    )

Limits placed on an outgoing payment grant, restricting the receiver, interval, and/or amount that payments made under the grant may use.

pub type Limits {
  Limits(
    receiver: option.Option(String),
    interval: option.Option(String),
    amount: AmountOption,
  )
}

Constructors

The actions that can be granted or exercised on outgoing payments.

pub type OutgoingAction {
  OutgoingCreate
  OutgoingRead
  OutgoingReadAll
  OutgoingList
  OutgoingListAll
}

Constructors

  • OutgoingCreate
  • OutgoingRead
  • OutgoingReadAll
  • OutgoingList
  • OutgoingListAll

Cursor pagination info shared by list responses.

pub type PageInfo {
  PageInfo(
    start_cursor: option.Option(String),
    end_cursor: option.Option(String),
    has_next_page: Bool,
    has_previous_page: Bool,
  )
}

Constructors

  • PageInfo(
      start_cursor: option.Option(String),
      end_cursor: option.Option(String),
      has_next_page: Bool,
      has_previous_page: Bool,
    )

The actions that can be granted or exercised on quotes.

pub type QuoteAction {
  QuoteCreate
  QuoteRead
  QuoteReadAll
}

Constructors

  • QuoteCreate
  • QuoteRead
  • QuoteReadAll

Values

pub fn add_amount_option(
  fields: List(#(String, json.Json)),
  amount: AmountOption,
) -> List(#(String, json.Json))

Prepends the encoded debitAmount or receiveAmount field to fields when amount carries one, otherwise leaves fields unchanged.

pub fn add_query(
  query: List(#(String, String)),
  name: String,
  value: option.Option(a),
  encode: fn(a) -> String,
) -> List(#(String, String))

Prepends #(name, value) to query when value is Some(v), otherwise leaves query unchanged. Used to build query strings with optional parameters.

pub fn decode_access() -> decode.Decoder(Access)

Decodes an Access from its Open Payments JSON representation.

pub fn decode_access_token_response() -> decode.Decoder(
  AccessTokenResponse,
)

Decodes an AccessTokenResponse from its Open Payments JSON representation.

pub fn decode_amount() -> decode.Decoder(Amount)

Decodes an Amount from its Open Payments JSON representation.

pub fn decode_amount_option() -> decode.Decoder(AmountOption)

Decodes an AmountOption from a JSON object that may carry a debitAmount field, a receiveAmount field, or neither.

pub fn decode_incoming_action() -> decode.Decoder(IncomingAction)

Decodes an IncomingAction from its Open Payments JSON string value.

pub fn decode_limits() -> decode.Decoder(Limits)

Decodes Limits from its Open Payments JSON representation.

pub fn decode_outgoing_action() -> decode.Decoder(OutgoingAction)

Decodes an OutgoingAction from its Open Payments JSON string value.

pub fn decode_page_info() -> decode.Decoder(PageInfo)

Decodes a PageInfo from its Open Payments JSON representation.

pub fn decode_quote_action() -> decode.Decoder(QuoteAction)

Decodes a QuoteAction from its Open Payments JSON string value.

pub fn encode_access(access: Access) -> json.Json

Encodes an Access as its Open Payments JSON representation.

pub fn encode_amount(amount: Amount) -> json.Json

Encodes an Amount as its Open Payments JSON representation (value/assetCode/assetScale).

pub fn encode_incoming_action(
  action: IncomingAction,
) -> json.Json

Encodes an IncomingAction as its Open Payments JSON string value.

pub fn encode_limits(limits: Limits) -> json.Json

Encodes Limits as its Open Payments JSON representation.

pub fn encode_outgoing_action(
  action: OutgoingAction,
) -> json.Json

Encodes an OutgoingAction as its Open Payments JSON string value.

pub fn encode_quote_action(action: QuoteAction) -> json.Json

Encodes a QuoteAction as its Open Payments JSON string value.

pub fn optional_field(
  fields: List(#(String, json.Json)),
  name: String,
  value: option.Option(a),
  encode: fn(a) -> json.Json,
) -> List(#(String, json.Json))

Prepends #(name, encode(v)) to fields when value is Some(v), otherwise leaves fields unchanged. Used to build JSON objects with optional fields.

Search Document