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.



23864
23865
23866
23867
23868
23869
23870
23871
23872
23873
23874
23875
23876
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23864

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_atObject (readonly)

Returns the value of attribute completed_at.



23862
23863
23864
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23862

def completed_at
  @completed_at
end

#created_atObject (readonly)

Returns the value of attribute created_at.



23862
23863
23864
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23862

def created_at
  @created_at
end

#deliveriesObject (readonly)

Returns the value of attribute deliveries.



23862
23863
23864
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23862

def deliveries
  @deliveries
end

#idObject (readonly)

Returns the value of attribute id.



23862
23863
23864
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23862

def id
  @id
end

#organization_qObject (readonly)

Returns the value of attribute organization_q.



23862
23863
23864
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23862

def organization_q
  @organization_q
end

#started_atObject (readonly)

Returns the value of attribute started_at.



23862
23863
23864
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23862

def started_at
  @started_at
end

#statusObject (readonly)

Returns the value of attribute status.



23862
23863
23864
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23862

def status
  @status
end

#typeObject (readonly)

Returns the value of attribute type.



23862
23863
23864
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23862

def type
  @type
end

#urlObject (readonly)

Returns the value of attribute url.



23862
23863
23864
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23862

def url
  @url
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



23882
23883
23884
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23882

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

#to_hashObject



23886
23887
23888
23889
23890
23891
23892
23893
23894
23895
23896
23897
23898
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23886

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_jsonObject



23878
23879
23880
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23878

def to_json
  JSON.dump(to_hash)
end