Class: Weavr::Response
- Inherits:
-
Object
- Object
- Weavr::Response
- Includes:
- Gorillib::Model
- Defined in:
- lib/weavr/response.rb
Class Method Summary collapse
Instance Method Summary collapse
- #error_message ⇒ Object
-
#receive_status(param) ⇒ Object
Really wish there was validations for these.
-
#validate! ⇒ Object
def receive_body param end.
Class Method Details
.handle(status, headers, body) ⇒ Object
10 11 12 |
# File 'lib/weavr/response.rb', line 10 def self.handle(status, headers, body) self.receive(status: status, headers: headers, body: body).validate! end |
Instance Method Details
#error_message ⇒ Object
39 40 41 |
# File 'lib/weavr/response.rb', line 39 def body['message'] end |
#receive_status(param) ⇒ Object
Really wish there was validations for these
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/weavr/response.rb', line 15 def receive_status param case param when 200 @status = param when 400 errors << { status: 400 } when 404 errors << { status: 404 } when 500 errors << { status: 500 } end end |
#validate! ⇒ Object
def receive_body param end
34 35 36 37 |
# File 'lib/weavr/response.rb', line 34 def validate! raise RequestError.new unless errors.empty? body end |