Class: AlPapi::Response
- Inherits:
-
Object
- Object
- AlPapi::Response
- Defined in:
- lib/al_papi/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#over_limit ⇒ Object
readonly
Returns the value of attribute over_limit.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#success ⇒ Object
readonly
Returns the value of attribute success.
-
#suspeneded ⇒ Object
readonly
Returns the value of attribute suspeneded.
Instance Method Summary collapse
-
#initialize(http, code, path, params) ⇒ Response
constructor
Initializing response object to be returned from API calls, used internally.
-
#over_limit? ⇒ Boolean
Convenience method to see if you have reached your hourly limit.
-
#parsed_body ⇒ Hashie::Mash
Parses JSON body of request and returns a Hashie::Mash.
-
#success? ⇒ Boolean
Convenience method to determine if request was successfull or not.
-
#suspended? ⇒ Boolean
Convenience method to see if your account is supended.
Constructor Details
#initialize(http, code, path, params) ⇒ Response
Initializing response object to be returned from API calls, used internally.
10 11 12 13 14 |
# File 'lib/al_papi/response.rb', line 10 def initialize(http, code, path, params) # @private @success, @body, @errors = http.success, http.response, http.errors @over_limit, @suspended = http.over_limit, http.suspended @code, @path, @params = code, path, params end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
3 4 5 |
# File 'lib/al_papi/response.rb', line 3 def body @body end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
3 4 5 |
# File 'lib/al_papi/response.rb', line 3 def code @code end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
3 4 5 |
# File 'lib/al_papi/response.rb', line 3 def errors @errors end |
#over_limit ⇒ Object (readonly)
Returns the value of attribute over_limit.
3 4 5 |
# File 'lib/al_papi/response.rb', line 3 def over_limit @over_limit end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
3 4 5 |
# File 'lib/al_papi/response.rb', line 3 def params @params end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/al_papi/response.rb', line 3 def path @path end |
#success ⇒ Object (readonly)
Returns the value of attribute success.
3 4 5 |
# File 'lib/al_papi/response.rb', line 3 def success @success end |
#suspeneded ⇒ Object (readonly)
Returns the value of attribute suspeneded.
3 4 5 |
# File 'lib/al_papi/response.rb', line 3 def suspeneded @suspeneded end |
Instance Method Details
#over_limit? ⇒ Boolean
Convenience method to see if you have reached your hourly limit
30 31 32 |
# File 'lib/al_papi/response.rb', line 30 def over_limit? @over_limit ? true : false end |
#parsed_body ⇒ Hashie::Mash
Parses JSON body of request and returns a Hashie::Mash
48 49 50 51 52 53 |
# File 'lib/al_papi/response.rb', line 48 def parsed_body hash = JSON.parse(@body) Hashie::Mash.new hash rescue {} end |
#success? ⇒ Boolean
Convenience method to determine if request was successfull or not
21 22 23 |
# File 'lib/al_papi/response.rb', line 21 def success? @success ? true : false end |
#suspended? ⇒ Boolean
Convenience method to see if your account is supended
39 40 41 |
# File 'lib/al_papi/response.rb', line 39 def suspended? @suspended ? true : false end |