Class: Ingenico::Connect::SDK::Domain::Metadata::ShoppingCartExtension

Inherits:
Ingenico::Connect::SDK::DataObject show all
Defined in:
lib/ingenico/connect/sdk/domain/metadata/shopping_cart_extension.rb

Overview

Represents metadata part of shopping carts.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(creator, name, version) ⇒ ShoppingCartExtension

Returns a new instance of ShoppingCartExtension.

Raises:

  • (ArgumentError)


7
8
9
10
11
12
13
14
15
# File 'lib/ingenico/connect/sdk/domain/metadata/shopping_cart_extension.rb', line 7

def initialize(creator, name, version)
  raise ArgumentError.new if creator.nil? or creator.strip.empty?
  raise ArgumentError.new if name.nil? or name.strip.empty?
  raise ArgumentError.new if version.nil? or version.to_s.strip.empty?

  @creator = creator
  @name = name
  @version = version.to_s
end

Instance Attribute Details

#creatorObject (readonly)

Returns the value of attribute creator.



46
47
48
# File 'lib/ingenico/connect/sdk/domain/metadata/shopping_cart_extension.rb', line 46

def creator
  @creator
end

#nameObject (readonly)

Returns the value of attribute name.



46
47
48
# File 'lib/ingenico/connect/sdk/domain/metadata/shopping_cart_extension.rb', line 46

def name
  @name
end

#versionObject (readonly)

Returns the value of attribute version.



46
47
48
# File 'lib/ingenico/connect/sdk/domain/metadata/shopping_cart_extension.rb', line 46

def version
  @version
end

Class Method Details

.new_from_hash(hash) ⇒ Object

Constructs a new ShoppingCartExtension from parameter hash the hash should contain a creator, name and version – Overridden so ShoppingCartExtension can retain mandatory default arguments ++



22
23
24
25
26
27
# File 'lib/ingenico/connect/sdk/domain/metadata/shopping_cart_extension.rb', line 22

def self.new_from_hash(hash)
  creator = hash['creator'] if hash.has_key?('creator')
  name = hash['name'] if hash.has_key?('name')
  version = hash['version'] if hash.has_key?('version')
  self.new(creator, name, version)
end

Instance Method Details

#from_hash(hash) ⇒ Object

loads shopping cart metadata from a parameter hash



39
40
41
42
43
44
# File 'lib/ingenico/connect/sdk/domain/metadata/shopping_cart_extension.rb', line 39

def from_hash(hash)
  super
  @creator = hash['creator'] if hash.has_key?('creator')
  @name = hash['name'] if hash.has_key?('name')
  @version = hash['version'] if hash.has_key?('version')
end

#to_hObject

Converts the shopping cart metadata to a hash



30
31
32
33
34
35
36
# File 'lib/ingenico/connect/sdk/domain/metadata/shopping_cart_extension.rb', line 30

def to_h
  hash = super
  add_to_hash(hash, 'creator', @creator)
  add_to_hash(hash, 'name', @name)
  add_to_hash(hash, 'version', @version)
  hash
end