Class: Io::Flow::V0::Clients::TrackingEvents
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::TrackingEvents
- 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) ⇒ TrackingEvents
constructor
A new instance of TrackingEvents.
Constructor Details
#initialize(client) ⇒ TrackingEvents
Returns a new instance of TrackingEvents.
5096 5097 5098 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5096 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#get(organization, incoming = {}) ⇒ Object
5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5100 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) }), :tracking_label_id => (x = opts.delete(:tracking_label_id); x.nil? ? nil : HttpClient::Preconditions.assert_class('tracking_label_id', x, Array).map { |v| HttpClient::Preconditions.assert_class('tracking_label_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-events").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::TrackingEvent.new(x) } end |
#get_by_id(organization, id) ⇒ Object
5128 5129 5130 5131 5132 5133 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5128 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-events/#{CGI.escape(id)}").get ::Io::Flow::V0::Models::TrackingEvent.new(r) end |
#get_versions(organization, incoming = {}) ⇒ Object
5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5115 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-events/versions").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::TrackingEventVersion.new(x) } end |