Class: Io::Flow::V0::Models::ImportForm

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

Overview

Import forms create imports. The import type defines both the type of the import (e.g. the CSV File format) and the URL at which the source data are available. If you do not have a URL readily available, you can first upload a file via the Flow API - see the resource named ‘Upload’

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ ImportForm

Returns a new instance of ImportForm.



40418
40419
40420
40421
40422
40423
40424
40425
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40418

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:type, :source_url], 'ImportForm')
  @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 = (x = opts.delete(:filename); x.nil? ? nil : HttpClient::Preconditions.assert_class('filename', x, String))
  @emails = (x = opts.delete(:emails); x.nil? ? nil : HttpClient::Preconditions.assert_class('emails', x, Array).map { |v| HttpClient::Preconditions.assert_class('emails', v, String) })
end

Instance Attribute Details

#emailsObject (readonly)

Returns the value of attribute emails.



40416
40417
40418
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40416

def emails
  @emails
end

#filenameObject (readonly)

Returns the value of attribute filename.



40416
40417
40418
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40416

def filename
  @filename
end

#source_urlObject (readonly)

Returns the value of attribute source_url.



40416
40417
40418
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40416

def source_url
  @source_url
end

#typeObject (readonly)

Returns the value of attribute type.



40416
40417
40418
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40416

def type
  @type
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



40431
40432
40433
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40431

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

#to_hashObject



40435
40436
40437
40438
40439
40440
40441
40442
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40435

def to_hash
  {
    :type => type.value,
    :source_url => source_url,
    :filename => filename,
    :emails => emails.nil? ? nil : emails
  }
end

#to_jsonObject



40427
40428
40429
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40427

def to_json
  JSON.dump(to_hash)
end