Class: X402::SettlementResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/x402/settlement_response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ SettlementResponse

Returns a new instance of SettlementResponse.



7
8
9
10
11
12
13
# File 'lib/x402/settlement_response.rb', line 7

def initialize(attributes = {})
  @success = attributes[:success] || attributes["success"]
  @transaction = attributes[:transaction] || attributes["transaction"]
  @network = attributes[:network] || attributes["network"]
  @payer = attributes[:payer] || attributes["payer"]
  @error_reason = attributes[:error_reason] || attributes["errorReason"]
end

Instance Attribute Details

#error_reasonObject

Returns the value of attribute error_reason.



5
6
7
# File 'lib/x402/settlement_response.rb', line 5

def error_reason
  @error_reason
end

#networkObject

Returns the value of attribute network.



5
6
7
# File 'lib/x402/settlement_response.rb', line 5

def network
  @network
end

#payerObject

Returns the value of attribute payer.



5
6
7
# File 'lib/x402/settlement_response.rb', line 5

def payer
  @payer
end

#successObject

Returns the value of attribute success.



5
6
7
# File 'lib/x402/settlement_response.rb', line 5

def success
  @success
end

#transactionObject

Returns the value of attribute transaction.



5
6
7
# File 'lib/x402/settlement_response.rb', line 5

def transaction
  @transaction
end

Instance Method Details

#success?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/x402/settlement_response.rb', line 15

def success?
  success == true
end

#to_base64Object



33
34
35
# File 'lib/x402/settlement_response.rb', line 33

def to_base64
  Base64.strict_encode64(to_json)
end

#to_hObject



19
20
21
22
23
24
25
26
27
# File 'lib/x402/settlement_response.rb', line 19

def to_h
  {
    success: success,
    transaction: transaction,
    network: network,
    payer: payer,
    errorReason: error_reason
  }
end

#to_json(*args) ⇒ Object



29
30
31
# File 'lib/x402/settlement_response.rb', line 29

def to_json(*args)
  to_h.to_json(*args)
end