Class: Io::Flow::V0::Models::Attachment

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ Attachment

Returns a new instance of Attachment.



28406
28407
28408
28409
28410
28411
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28406

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:type, :url], 'Attachment')
  @type = (x = opts.delete(:type); x.is_a?(::Io::Flow::V0::Models::AttachmentType) ? x : ::Io::Flow::V0::Models::AttachmentType.apply(x))
  @url = HttpClient::Preconditions.assert_class('url', opts.delete(:url), String)
end

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



28404
28405
28406
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28404

def type
  @type
end

#urlObject (readonly)

Returns the value of attribute url.



28404
28405
28406
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28404

def url
  @url
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



28417
28418
28419
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28417

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

#to_hashObject



28421
28422
28423
28424
28425
28426
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28421

def to_hash
  {
    :type => type.value,
    :url => url
  }
end

#to_jsonObject



28413
28414
28415
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28413

def to_json
  JSON.dump(to_hash)
end