Class: Io::Flow::V0::Models::ItemForm

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

Overview

The item form defines the data required to create an item.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ ItemForm

Returns a new instance of ItemForm.



46989
46990
46991
46992
46993
46994
46995
46996
46997
46998
46999
47000
47001
47002
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46989

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:number, :locale, :name, :currency, :price], 'ItemForm')
  @number = HttpClient::Preconditions.assert_class('number', opts.delete(:number), String)
  @locale = HttpClient::Preconditions.assert_class('locale', opts.delete(:locale), String)
  @name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String)
  @currency = HttpClient::Preconditions.assert_class('currency', opts.delete(:currency), String)
  @price = HttpClient::Preconditions.assert_class('price', opts.delete(:price), Numeric)
  @categories = (x = opts.delete(:categories); x.nil? ? nil : HttpClient::Preconditions.assert_class('categories', x, Array).map { |v| HttpClient::Preconditions.assert_class('categories', v, String) })
  @description = (x = opts.delete(:description); x.nil? ? nil : HttpClient::Preconditions.assert_class('description', x, String))
  @attributes = (x = opts.delete(:attributes); x.nil? ? nil : HttpClient::Preconditions.assert_class('attributes', x, Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('attributes', d[1], String); h })
  @dimensions = (x = opts.delete(:dimensions); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Dimensions) ? x : ::Io::Flow::V0::Models::Dimensions.new(x)))
  @images = (x = opts.delete(:images); x.nil? ? nil : HttpClient::Preconditions.assert_class('images', x, Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::ImageForm) ? x : ::Io::Flow::V0::Models::ImageForm.new(x)) })
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



46987
46988
46989
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46987

def attributes
  @attributes
end

#categoriesObject (readonly)

Returns the value of attribute categories.



46987
46988
46989
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46987

def categories
  @categories
end

#currencyObject (readonly)

Returns the value of attribute currency.



46987
46988
46989
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46987

def currency
  @currency
end

#descriptionObject (readonly)

Returns the value of attribute description.



46987
46988
46989
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46987

def description
  @description
end

#dimensionsObject (readonly)

Returns the value of attribute dimensions.



46987
46988
46989
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46987

def dimensions
  @dimensions
end

#imagesObject (readonly)

Returns the value of attribute images.



46987
46988
46989
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46987

def images
  @images
end

#localeObject (readonly)

Returns the value of attribute locale.



46987
46988
46989
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46987

def locale
  @locale
end

#nameObject (readonly)

Returns the value of attribute name.



46987
46988
46989
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46987

def name
  @name
end

#numberObject (readonly)

Returns the value of attribute number.



46987
46988
46989
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46987

def number
  @number
end

#priceObject (readonly)

Returns the value of attribute price.



46987
46988
46989
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46987

def price
  @price
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



47008
47009
47010
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 47008

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

#to_hashObject



47012
47013
47014
47015
47016
47017
47018
47019
47020
47021
47022
47023
47024
47025
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 47012

def to_hash
  {
    :number => number,
    :locale => locale,
    :name => name,
    :currency => currency,
    :price => price,
    :categories => categories.nil? ? nil : categories,
    :description => description,
    :attributes => attributes.nil? ? nil : attributes,
    :dimensions => dimensions.nil? ? nil : dimensions.to_hash,
    :images => images.nil? ? nil : images.map { |o| o.to_hash }
  }
end

#to_jsonObject



47004
47005
47006
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 47004

def to_json
  JSON.dump(to_hash)
end