Class: Io::Flow::V0::Clients::Imports
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::Imports
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
- #delete_by_id(organization, id) ⇒ Object
-
#get(organization, incoming = {}) ⇒ Object
Search imports.
-
#get_by_id(organization, id) ⇒ Object
Get a single import.
-
#get_versions(organization, incoming = {}) ⇒ Object
Provides visibility into recent changes of each import, including deletion.
-
#initialize(client) ⇒ Imports
constructor
A new instance of Imports.
-
#post(organization, import_form) ⇒ Object
Create an import.
Constructor Details
#initialize(client) ⇒ Imports
Returns a new instance of Imports.
7134 7135 7136 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7134 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_id(organization, id) ⇒ Object
7185 7186 7187 7188 7189 7190 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7185 def delete_by_id(organization, id) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('id', id, String) r = @client.request("/#{CGI.escape(organization)}/imports/#{CGI.escape(id)}").delete nil end |
#get(organization, incoming = {}) ⇒ Object
Search imports. Always paginated.
7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7139 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) }), :created_by_user_id => (x = opts.delete(:created_by_user_id); x.nil? ? nil : HttpClient::Preconditions.assert_class('created_by_user_id', x, String)), :type => (x = opts.delete(:type); x.nil? ? nil : HttpClient::Preconditions.assert_class('type', x, 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)}/imports").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::Import.new(x) } end |
#get_by_id(organization, id) ⇒ Object
Get a single import.
7178 7179 7180 7181 7182 7183 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7178 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)}/imports/#{CGI.escape(id)}").get ::Io::Flow::V0::Models::Import.new(r) end |
#get_versions(organization, incoming = {}) ⇒ Object
Provides visibility into recent changes of each import, including deletion.
7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7163 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) }), :import_id => (x = opts.delete(:import_id); x.nil? ? nil : HttpClient::Preconditions.assert_class('import_id', x, Array).map { |v| HttpClient::Preconditions.assert_class('import_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)}/imports/versions").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::ImportVersion.new(x) } end |
#post(organization, import_form) ⇒ Object
Create an import.
7155 7156 7157 7158 7159 7160 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7155 def post(organization, import_form) HttpClient::Preconditions.assert_class('organization', organization, String) (x = import_form; x.is_a?(::Io::Flow::V0::Models::ImportForm) ? x : ::Io::Flow::V0::Models::ImportForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/imports").with_json(import_form.to_json).post ::Io::Flow::V0::Models::Import.new(r) end |