Class: BusinessCentral::Object::Response
- Inherits:
-
Object
- Object
- BusinessCentral::Object::Response
- Defined in:
- lib/business_central/object/response.rb
Instance Attribute Summary collapse
-
#results ⇒ Object
readonly
Returns the value of attribute results.
Class Method Summary collapse
- .not_found?(status) ⇒ Boolean
- .success?(status) ⇒ Boolean
- .success_no_content?(status) ⇒ Boolean
- .unauthorized?(status) ⇒ Boolean
Instance Method Summary collapse
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(response) ⇒ Response
Returns a new instance of Response.
28 29 30 31 32 33 34 35 |
# File 'lib/business_central/object/response.rb', line 28 def initialize(response) @results = nil return if response.blank? @response = JSON.parse(response) @response = @response['value'] if @response.key?('value') process end |
Instance Attribute Details
#results ⇒ Object (readonly)
Returns the value of attribute results.
26 27 28 |
# File 'lib/business_central/object/response.rb', line 26 def results @results end |
Class Method Details
.not_found?(status) ⇒ Boolean
21 22 23 |
# File 'lib/business_central/object/response.rb', line 21 def not_found?(status) status == 404 end |
.success?(status) ⇒ Boolean
9 10 11 |
# File 'lib/business_central/object/response.rb', line 9 def success?(status) [200, 201].include?(status) end |
.success_no_content?(status) ⇒ Boolean
13 14 15 |
# File 'lib/business_central/object/response.rb', line 13 def success_no_content?(status) status == 204 end |
.unauthorized?(status) ⇒ Boolean
17 18 19 |
# File 'lib/business_central/object/response.rb', line 17 def (status) status == 401 end |