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.



22478
22479
22480
22481
22482
22483
22484
22485
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22478

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

#expiration ⇒ Object (readonly)

Returns the value of attribute expiration.



22476
22477
22478
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22476

def expiration
  @expiration
end

#id ⇒ Object (readonly)

Returns the value of attribute id.



22476
22477
22478
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22476

def id
  @id
end

#name ⇒ Object (readonly)

Returns the value of attribute name.



22476
22477
22478
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22476

def name
  @name
end

#url ⇒ Object (readonly)

Returns the value of attribute url.



22476
22477
22478
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22476

def url
  @url
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



22491
22492
22493
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22491

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

#to_hash ⇒ Object



22495
22496
22497
22498
22499
22500
22501
22502
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22495

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

#to_json ⇒ Object



22487
22488
22489
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22487

def to_json
  JSON.dump(to_hash)
end