Class: Multicard::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/multicard/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http_status:, body:, headers: {}) ⇒ Response

Returns a new instance of Response.



7
8
9
10
11
# File 'lib/multicard/response.rb', line 7

def initialize(http_status:, body:, headers: {})
  @http_status = http_status
  @body = body
  @headers = headers
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



5
6
7
# File 'lib/multicard/response.rb', line 5

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



5
6
7
# File 'lib/multicard/response.rb', line 5

def headers
  @headers
end

#http_statusObject (readonly)

Returns the value of attribute http_status.



5
6
7
# File 'lib/multicard/response.rb', line 5

def http_status
  @http_status
end

Instance Method Details

#[](key) ⇒ Object



29
30
31
# File 'lib/multicard/response.rb', line 29

def [](key)
  data&.[](key)
end

#dataObject



17
18
19
# File 'lib/multicard/response.rb', line 17

def data
  body[:data]
end

#error_codeObject



21
22
23
# File 'lib/multicard/response.rb', line 21

def error_code
  body.dig(:error, :code)
end

#error_detailsObject



25
26
27
# File 'lib/multicard/response.rb', line 25

def error_details
  body.dig(:error, :details)
end

#success?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/multicard/response.rb', line 13

def success?
  body[:success] == true
end