Class: Io::Flow::V0::Models::JsonpResponse
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::JsonpResponse
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
The jsonp_response defines the schema for all Flow APIs calls made over JSONP, providing access to the specific response status, headers, and body from the underlying service. See docs.flow.io/#jsonp for details
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ JsonpResponse
constructor
A new instance of JsonpResponse.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ JsonpResponse
Returns a new instance of JsonpResponse.
19681 19682 19683 19684 19685 19686 19687 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19681 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:status, :headers, :body], 'JsonpResponse') @status = HttpClient::Preconditions.assert_class('status', opts.delete(:status), Integer) @headers = HttpClient::Preconditions.assert_class('headers', opts.delete(:headers), Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('headers', d[1], Array).map { |v| HttpClient::Preconditions.assert_class('headers', v, String) }; h } @body = HttpClient::Preconditions.assert_class('body', HttpClient::Helper.to_object(opts.delete(:body)), Hash) end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
19679 19680 19681 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19679 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
19679 19680 19681 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19679 def headers @headers end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
19679 19680 19681 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19679 def status @status end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
19693 19694 19695 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19693 def copy(incoming={}) JsonpResponse.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
19697 19698 19699 19700 19701 19702 19703 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19697 def to_hash { :status => status, :headers => headers.inject({}) { |hash, o| hash[o[0]] = o[1].nil? ? nil : o[1]; hash }, :body => body } end |
#to_json ⇒ Object
19689 19690 19691 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19689 def to_json JSON.dump(to_hash) end |