Class: Blockchain0x::Resources::PaymentCreateBody

Inherits:
Struct
  • Object
show all
Defined in:
lib/blockchain0x/resources/payments.rb

Overview

PaymentCreateBody is the typed body for POST /v1/payments. Snake_case on the Ruby side; camelCase on the wire (via ‘#to_h_wire`). Mirrors the Python PaymentCreateBody dataclass + Go PaymentCreateRequest struct.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(agent_id:, to:, amount_wei:, token: nil, metadata: nil) ⇒ PaymentCreateBody

Returns a new instance of PaymentCreateBody.



33
34
35
# File 'lib/blockchain0x/resources/payments.rb', line 33

def initialize(agent_id:, to:, amount_wei:, token: nil, metadata: nil)
  super
end

Instance Attribute Details

#agent_idObject

Returns the value of attribute agent_id

Returns:

  • (Object)

    the current value of agent_id



25
26
27
# File 'lib/blockchain0x/resources/payments.rb', line 25

def agent_id
  @agent_id
end

#amount_weiObject

Returns the value of attribute amount_wei

Returns:

  • (Object)

    the current value of amount_wei



25
26
27
# File 'lib/blockchain0x/resources/payments.rb', line 25

def amount_wei
  @amount_wei
end

#metadataObject

Returns the value of attribute metadata

Returns:

  • (Object)

    the current value of metadata



25
26
27
# File 'lib/blockchain0x/resources/payments.rb', line 25

def 
  @metadata
end

#toObject

Returns the value of attribute to

Returns:

  • (Object)

    the current value of to



25
26
27
# File 'lib/blockchain0x/resources/payments.rb', line 25

def to
  @to
end

#tokenObject

Returns the value of attribute token

Returns:

  • (Object)

    the current value of token



25
26
27
# File 'lib/blockchain0x/resources/payments.rb', line 25

def token
  @token
end

Instance Method Details

#to_h_wireObject



37
38
39
40
41
42
43
44
45
46
# File 'lib/blockchain0x/resources/payments.rb', line 37

def to_h_wire
  h = {
    'agentId' => agent_id,
    'to' => to,
    'amountWei' => amount_wei,
  }
  h['token'] = token unless token.nil?
  h['metadata'] = .to_h unless .nil?
  h
end