Class: Io::Flow::V0::Models::Export

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Overview

Exports represent data extraction requests (e.g. download my catalog items to a CSV file)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ Export

Returns a new instance of Export.



12449
12450
12451
12452
12453
12454
12455
12456
12457
12458
12459
12460
12461
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12449

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :type, :status, :organization_q, :created_at, :deliveries], 'Export')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @type = (x = opts.delete(:type); x.is_a?(::Io::Flow::V0::Models::ExportType) ? x : ::Io::Flow::V0::Models::ExportType.from_json(x))
  @status = (x = opts.delete(:status); x.is_a?(::Io::Flow::V0::Models::ExportStatus) ? x : ::Io::Flow::V0::Models::ExportStatus.apply(x))
  @organization_q = HttpClient::Preconditions.assert_class('organization_q', opts.delete(:organization_q), String)
  @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))
  @url = (x = opts.delete(:url); x.nil? ? nil : HttpClient::Preconditions.assert_class('url', x, String))
  @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

Instance Attribute Details

#completed_at ⇒ Object (readonly)

Returns the value of attribute completed_at.



12447
12448
12449
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12447

def completed_at
  @completed_at
end

#created_at ⇒ Object (readonly)

Returns the value of attribute created_at.



12447
12448
12449
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12447

def created_at
  @created_at
end

#deliveries ⇒ Object (readonly)

Returns the value of attribute deliveries.



12447
12448
12449
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12447

def deliveries
  @deliveries
end

#id ⇒ Object (readonly)

Returns the value of attribute id.



12447
12448
12449
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12447

def id
  @id
end

#organization_q ⇒ Object (readonly)

Returns the value of attribute organization_q.



12447
12448
12449
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12447

def organization_q
  @organization_q
end

#started_at ⇒ Object (readonly)

Returns the value of attribute started_at.



12447
12448
12449
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12447

def started_at
  @started_at
end

#status ⇒ Object (readonly)

Returns the value of attribute status.



12447
12448
12449
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12447

def status
  @status
end

#type ⇒ Object (readonly)

Returns the value of attribute type.



12447
12448
12449
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12447

def type
  @type
end

#url ⇒ Object (readonly)

Returns the value of attribute url.



12447
12448
12449
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12447

def url
  @url
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



12467
12468
12469
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12467

def copy(incoming={})
  Export.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#to_hash ⇒ Object



12471
12472
12473
12474
12475
12476
12477
12478
12479
12480
12481
12482
12483
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12471

def to_hash
  {
    :id => id,
    :type => type.to_hash,
    :status => status.value,
    :organization_q => organization_q,
    :created_at => created_at,
    :started_at => started_at,
    :completed_at => completed_at,
    :url => url,
    :deliveries => deliveries.map { |o| o.to_hash }
  }
end

#to_json ⇒ Object



12463
12464
12465
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12463

def to_json
  JSON.dump(to_hash)
end