Class: NftmakerApi::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Response

Returns a new instance of Response.



8
9
10
# File 'lib/nftmaker_api/response.rb', line 8

def initialize(response)
  @original_response = response
end

Instance Attribute Details

#original_responseObject (readonly) Also known as: original

Returns the value of attribute original_response.



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

def original_response
  @original_response
end

Instance Method Details

#errorObject



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

def error
  @error ||= success? ? nil : Error.new(self)
end

#error?Boolean

Returns:

  • (Boolean)


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

def error?
  !success?
end

#parsedObject Also known as: to_h



12
13
14
# File 'lib/nftmaker_api/response.rb', line 12

def parsed
  @parsed = Oj.load(@original_response.body) || {}
end

#success?Boolean

Returns:

  • (Boolean)


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

def success?
  @original_response.status == 200
end