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.
6438 6439 6440 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6438 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_id(organization, id) ⇒ Object
6489 6490 6491 6492 6493 6494 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6489 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.
6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6443 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.
6482 6483 6484 6485 6486 6487 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6482 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.
6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6467 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.
6459 6460 6461 6462 6463 6464 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6459 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 |