class Io::Flow::V0::Models::Import

Imports allow you to upload data to Flow via files in batch. Each import fetches data from a given URL. The type of the import determines which file format to expect and what data to update

Attributes

completed_at[R]
created_at[R]
deliveries[R]
filename[R]
id[R]
results[R]
source_url[R]
started_at[R]
status[R]
type[R]

Public Class Methods

new(incoming={}) click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 45439
def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :type, :source_url, :filename, :status, :created_at, :deliveries], 'Import')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @type = (x = opts.delete(:type); x.is_a?(::Io::Flow::V0::Models::ImportType) ? x : ::Io::Flow::V0::Models::ImportType.apply(x))
  @source_url = HttpClient::Preconditions.assert_class('source_url', opts.delete(:source_url), String)
  @filename = HttpClient::Preconditions.assert_class('filename', opts.delete(:filename), String)
  @status = (x = opts.delete(:status); x.is_a?(::Io::Flow::V0::Models::ExportStatus) ? x : ::Io::Flow::V0::Models::ExportStatus.apply(x))
  @created_at = HttpClient::Preconditions.assert_class('created_at', HttpClient::Helper.to_date_time_iso8601(opts.delete(:created_at)), DateTime)
  @started_at = (x = opts.delete(:started_at); x.nil? ? nil : HttpClient::Preconditions.assert_class('started_at', HttpClient::Helper.to_date_time_iso8601(x), DateTime))
  @completed_at = (x = opts.delete(:completed_at); x.nil? ? nil : HttpClient::Preconditions.assert_class('completed_at', HttpClient::Helper.to_date_time_iso8601(x), DateTime))
  @results = (x = opts.delete(:results); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::ImportResults) ? x : ::Io::Flow::V0::Models::ImportResults.new(x)))
  @deliveries = HttpClient::Preconditions.assert_class('deliveries', opts.delete(:deliveries), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::ExportDelivery) ? x : ::Io::Flow::V0::Models::ExportDelivery.from_json(x)) }
end

Public Instance Methods

copy(incoming={}) click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 45458
def copy(incoming={})
  Import.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end
to_hash() click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 45462
def to_hash
  {
    :id => id,
    :type => type.value,
    :source_url => source_url,
    :filename => filename,
    :status => status.value,
    :created_at => created_at,
    :started_at => started_at,
    :completed_at => completed_at,
    :results => results.nil? ? nil : results.to_hash,
    :deliveries => deliveries.map { |o| o.to_hash }
  }
end
to_json() click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 45454
def to_json
  JSON.dump(to_hash)
end