Class: Io::Flow::V0::Models::Upload

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

Overview

Provides the ability to upload a file to a URL (an expiring s3 url, usually valid for 1 week)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ Upload

Returns a new instance of Upload.



66844
66845
66846
66847
66848
66849
66850
66851
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 66844

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :name, :url, :expiration], 'Upload')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String)
  @url = HttpClient::Preconditions.assert_class('url', opts.delete(:url), String)
  @expiration = HttpClient::Preconditions.assert_class('expiration', HttpClient::Helper.to_date_time_iso8601(opts.delete(:expiration)), DateTime)
end

Instance Attribute Details

#expirationObject (readonly)

Returns the value of attribute expiration.



66842
66843
66844
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 66842

def expiration
  @expiration
end

#idObject (readonly)

Returns the value of attribute id.



66842
66843
66844
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 66842

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



66842
66843
66844
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 66842

def name
  @name
end

#urlObject (readonly)

Returns the value of attribute url.



66842
66843
66844
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 66842

def url
  @url
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



66857
66858
66859
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 66857

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

#to_hashObject



66861
66862
66863
66864
66865
66866
66867
66868
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 66861

def to_hash
  {
    :id => id,
    :name => name,
    :url => url,
    :expiration => expiration
  }
end

#to_jsonObject



66853
66854
66855
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 66853

def to_json
  JSON.dump(to_hash)
end