Class: Sendicate::Request
- Inherits:
-
Object
- Object
- Sendicate::Request
- Includes:
- HTTParty
- Defined in:
- lib/sendicate/request.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
Returns the value of attribute response.
Class Method Summary collapse
- .delete(path, options = {}, &block) ⇒ Object
- .get(path, options = {}, &block) ⇒ Object
- .patch(path, options = {}, &block) ⇒ Object
- .post(path, options = {}, &block) ⇒ Object
- .put(path, options = {}, &block) ⇒ Object
Instance Method Summary collapse
-
#initialize(response) ⇒ Request
constructor
A new instance of Request.
- #parsed_response ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(response) ⇒ Request
Returns a new instance of Request.
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/sendicate/request.rb', line 30 def initialize(response) @response = response unless success? case response.code when 400 raise BadRequest when 401 raise Unauthorized when 404 raise ResourceNotFound end end end |
Instance Attribute Details
#response ⇒ Object
Returns the value of attribute response.
8 9 10 |
# File 'lib/sendicate/request.rb', line 8 def response @response end |
Class Method Details
.delete(path, options = {}, &block) ⇒ Object
26 27 28 |
# File 'lib/sendicate/request.rb', line 26 def self.delete(path, ={}, &block) new(super) end |
.get(path, options = {}, &block) ⇒ Object
10 11 12 |
# File 'lib/sendicate/request.rb', line 10 def self.get(path, ={}, &block) new(super) end |
.patch(path, options = {}, &block) ⇒ Object
18 19 20 |
# File 'lib/sendicate/request.rb', line 18 def self.patch(path, ={}, &block) new(super) end |
.post(path, options = {}, &block) ⇒ Object
14 15 16 |
# File 'lib/sendicate/request.rb', line 14 def self.post(path, ={}, &block) new(super) end |
.put(path, options = {}, &block) ⇒ Object
22 23 24 |
# File 'lib/sendicate/request.rb', line 22 def self.put(path, ={}, &block) new(super) end |
Instance Method Details
#parsed_response ⇒ Object
44 45 46 |
# File 'lib/sendicate/request.rb', line 44 def parsed_response response.parsed_response end |
#success? ⇒ Boolean
48 49 50 |
# File 'lib/sendicate/request.rb', line 48 def success? [200, 201].include?(response.code) end |