Class: Io::Flow::V0::Clients::TrackingLabels
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::TrackingLabels
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
- #get(organization, incoming = {}) ⇒ Object
- #get_by_id(organization, id) ⇒ Object
- #get_versions(organization, incoming = {}) ⇒ Object
-
#initialize(client) ⇒ TrackingLabels
constructor
A new instance of TrackingLabels.
- #post(organization, tracking_label_form) ⇒ Object
Constructor Details
#initialize(client) ⇒ TrackingLabels
Returns a new instance of TrackingLabels.
5139 5140 5141 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5139 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#get(organization, incoming = {}) ⇒ Object
5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5143 def get(organization, incoming={}) HttpClient::Preconditions.assert_class('organization', organization, String) opts = HttpClient::Helper.symbolize_keys(incoming) query = { :id => (x = opts.delete(:id); x.nil? ? nil : HttpClient::Preconditions.assert_class('id', x, Array).map { |v| HttpClient::Preconditions.assert_class('id', v, String) }), :tracking_id => (x = opts.delete(:tracking_id); x.nil? ? nil : HttpClient::Preconditions.assert_class('tracking_id', x, Array).map { |v| HttpClient::Preconditions.assert_class('tracking_id', v, String) }), :limit => HttpClient::Preconditions.assert_class('limit', (x = opts.delete(:limit); x.nil? ? 25 : x), Integer), :offset => HttpClient::Preconditions.assert_class('offset', (x = opts.delete(:offset); x.nil? ? 0 : x), Integer), :sort => HttpClient::Preconditions.assert_class('sort', (x = opts.delete(:sort); x.nil? ? "-created_at" : x), String) }.delete_if { |k, v| v.nil? } r = @client.request("/#{CGI.escape(organization)}/tracking-labels").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::TrackingLabel.new(x) } end |
#get_by_id(organization, id) ⇒ Object
5177 5178 5179 5180 5181 5182 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5177 def get_by_id(organization, id) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('id', id, String) r = @client.request("/#{CGI.escape(organization)}/tracking-labels/#{CGI.escape(id)}").get ::Io::Flow::V0::Models::TrackingLabel.new(r) end |
#get_versions(organization, incoming = {}) ⇒ Object
5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5164 def get_versions(organization, incoming={}) HttpClient::Preconditions.assert_class('organization', organization, String) opts = HttpClient::Helper.symbolize_keys(incoming) query = { :id => (x = opts.delete(:id); x.nil? ? nil : HttpClient::Preconditions.assert_class('id', x, Array).map { |v| HttpClient::Preconditions.assert_class('id', v, String) }), :limit => HttpClient::Preconditions.assert_class('limit', (x = opts.delete(:limit); x.nil? ? 25 : x), Integer), :offset => HttpClient::Preconditions.assert_class('offset', (x = opts.delete(:offset); x.nil? ? 0 : x), Integer), :sort => HttpClient::Preconditions.assert_class('sort', (x = opts.delete(:sort); x.nil? ? "journal_timestamp" : x), String) }.delete_if { |k, v| v.nil? } r = @client.request("/#{CGI.escape(organization)}/tracking-labels/versions").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::TrackingLabelVersion.new(x) } end |
#post(organization, tracking_label_form) ⇒ Object
5157 5158 5159 5160 5161 5162 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5157 def post(organization, tracking_label_form) HttpClient::Preconditions.assert_class('organization', organization, String) (x = tracking_label_form; x.is_a?(::Io::Flow::V0::Models::TrackingLabelForm) ? x : ::Io::Flow::V0::Models::TrackingLabelForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/tracking-labels").with_json(tracking_label_form.to_json).post ::Io::Flow::V0::Models::TrackingLabel.new(r) end |