Class: Io::Flow::V0::Models::CheckoutItemContent

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

Overview

A Checkout Item Content provides information about an item to support rendering of that item in the context of checkout

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ CheckoutItemContent

Returns a new instance of CheckoutItemContent.



16318
16319
16320
16321
16322
16323
16324
16325
16326
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16318

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:item, :name, :attributes], 'CheckoutItemContent')
  @item = (x = opts.delete(:item); x.is_a?(::Io::Flow::V0::Models::Item) ? x : ::Io::Flow::V0::Models::Item.new(x))
  @name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String)
  @description = (x = opts.delete(:description); x.nil? ? nil : HttpClient::Preconditions.assert_class('description', x, String))
  @attributes = HttpClient::Preconditions.assert_class('attributes', opts.delete(:attributes), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::CheckoutItemContentAttribute) ? x : ::Io::Flow::V0::Models::CheckoutItemContentAttribute.new(x)) }
  @image = (x = opts.delete(:image); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Image) ? x : ::Io::Flow::V0::Models::Image.new(x)))
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



16316
16317
16318
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16316

def attributes
  @attributes
end

#descriptionObject (readonly)

Returns the value of attribute description.



16316
16317
16318
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16316

def description
  @description
end

#imageObject (readonly)

Returns the value of attribute image.



16316
16317
16318
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16316

def image
  @image
end

#itemObject (readonly)

Returns the value of attribute item.



16316
16317
16318
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16316

def item
  @item
end

#nameObject (readonly)

Returns the value of attribute name.



16316
16317
16318
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16316

def name
  @name
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



16332
16333
16334
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16332

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

#to_hashObject



16336
16337
16338
16339
16340
16341
16342
16343
16344
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16336

def to_hash
  {
    :item => item.to_hash,
    :name => name,
    :description => description,
    :attributes => attributes.map { |o| o.to_hash },
    :image => image.nil? ? nil : image.to_hash
  }
end

#to_jsonObject



16328
16329
16330
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16328

def to_json
  JSON.dump(to_hash)
end