Class: SocketLabs::InjectionApi::SendResponse
- Inherits:
-
Object
- Object
- SocketLabs::InjectionApi::SendResponse
- Defined in:
- lib/socketlabs/injectionapi/send_response.rb
Overview
The response of an SocketLabsClient send request.
Instance Attribute Summary collapse
-
#address_results ⇒ Object
A Array of AddressResult objects that contain the status of each address that failed.
-
#result ⇒ Object
The result [SendResult] of the SocketLabsClient send request.
-
#transaction_receipt ⇒ Object
The unique key generated by the Injection API if an unexpected error occurs during the SocketLabsClient send request.
Instance Method Summary collapse
-
#initialize(result = nil, transaction_receipt = nil, address_results = nil, response_message = nil) ⇒ SendResponse
constructor
A new instance of SendResponse.
-
#response_message ⇒ Object
A message detailing why the SocketLabsClient send request failed.
- #response_name ⇒ Object
-
#to_json ⇒ Object
build json hash for SendResponse.
-
#to_s ⇒ Object
Represents the SendResponse as a str.
Constructor Details
#initialize(result = nil, transaction_receipt = nil, address_results = nil, response_message = nil) ⇒ SendResponse
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/socketlabs/injectionapi/send_response.rb', line 15 def initialize ( result = nil, transaction_receipt= nil, address_results= nil, = nil ) @result = result @transaction_receipt = transaction_receipt @address_results = [] unless address_results.nil? @address_results = address_results end end |
Instance Attribute Details
#address_results ⇒ Object
A Array of AddressResult objects that contain the status of each address that failed. If no messages failed this array is empty.
13 14 15 |
# File 'lib/socketlabs/injectionapi/send_response.rb', line 13 def address_results @address_results end |
#result ⇒ Object
The result [SendResult] of the SocketLabsClient send request.
7 8 9 |
# File 'lib/socketlabs/injectionapi/send_response.rb', line 7 def result @result end |
#transaction_receipt ⇒ Object
The unique key generated by the Injection API if an unexpected error occurs during the SocketLabsClient send request. This unique key can be used by SocketLabs support to troubleshoot the issue.
10 11 12 |
# File 'lib/socketlabs/injectionapi/send_response.rb', line 10 def transaction_receipt @transaction_receipt end |
Instance Method Details
#response_message ⇒ Object
A message detailing why the SocketLabsClient send request failed.
32 33 34 35 36 |
# File 'lib/socketlabs/injectionapi/send_response.rb', line 32 def unless @result.nil? @result[:message] end end |
#response_name ⇒ Object
38 39 40 41 42 |
# File 'lib/socketlabs/injectionapi/send_response.rb', line 38 def response_name unless @result.nil? @result[:name] end end |
#to_json ⇒ Object
build json hash for SendResponse
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/socketlabs/injectionapi/send_response.rb', line 50 def to_json(*) json = { :result => @result.to_json, :transactionReceipt => @transaction_receipt, :responseMessage => } if @address_results.length > 0 e = Array.new @address_results.each do |value| e.push(value.to_json) end json[:messageResults] = e end json.to_json end |
#to_s ⇒ Object
Represents the SendResponse as a str.
45 46 47 |
# File 'lib/socketlabs/injectionapi/send_response.rb', line 45 def to_s "#{response_name}: #{}" end |