Class: LedgerSync::Ledgers::Response
- Inherits:
-
Object
- Object
- LedgerSync::Ledgers::Response
- Defined in:
- lib/ledger_sync/ledgers/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Class Method Summary collapse
- .new_from_faraday_response(faraday_response:, request:) ⇒ Object
- .new_from_oauth_response(oauth_response:, request:) ⇒ Object
Instance Method Summary collapse
- #failure? ⇒ Boolean
-
#initialize(request:, status:, body: nil, headers: {}, raw: nil) ⇒ Response
constructor
A new instance of Response.
- #success? ⇒ Boolean
Constructor Details
#initialize(request:, status:, body: nil, headers: {}, raw: nil) ⇒ Response
Returns a new instance of Response.
12 13 14 15 16 17 18 |
# File 'lib/ledger_sync/ledgers/response.rb', line 12 def initialize(request:, status:, body: nil, headers: {}, raw: nil) @body = parse_json(body) @headers = headers @raw = raw @request = request @status = status end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
6 7 8 |
# File 'lib/ledger_sync/ledgers/response.rb', line 6 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
6 7 8 |
# File 'lib/ledger_sync/ledgers/response.rb', line 6 def headers @headers end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
6 7 8 |
# File 'lib/ledger_sync/ledgers/response.rb', line 6 def raw @raw end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
6 7 8 |
# File 'lib/ledger_sync/ledgers/response.rb', line 6 def request @request end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
6 7 8 |
# File 'lib/ledger_sync/ledgers/response.rb', line 6 def status @status end |
Class Method Details
.new_from_faraday_response(faraday_response:, request:) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/ledger_sync/ledgers/response.rb', line 28 def self.new_from_faraday_response(faraday_response:, request:) new( body: faraday_response.body, headers: faraday_response.headers, raw: faraday_response, request: request, status: faraday_response.status ) end |
.new_from_oauth_response(oauth_response:, request:) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/ledger_sync/ledgers/response.rb', line 38 def self.new_from_oauth_response(oauth_response:, request:) # Uses the same API new_from_faraday_response( faraday_response: oauth_response, request: request ) end |
Instance Method Details
#failure? ⇒ Boolean
20 21 22 |
# File 'lib/ledger_sync/ledgers/response.rb', line 20 def failure? !success? end |
#success? ⇒ Boolean
24 25 26 |
# File 'lib/ledger_sync/ledgers/response.rb', line 24 def success? (200..299).include?(status) end |