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, extension_id = nil) ⇒ ShoppingCartExtension

Returns a new instance of ShoppingCartExtension.

Raises:

  • (ArgumentError)


10
11
12
13
14
15
16
17
18
19
# File 'lib/ingenico/connect/sdk/domain/metadata/shopping_cart_extension.rb', line 10

def initialize(creator, name, version, extension_id=nil)
  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
  @extension_id = extension_id
end

Instance Attribute Details

#creatorObject (readonly)

Returns the value of attribute creator.



53
54
55
# File 'lib/ingenico/connect/sdk/domain/metadata/shopping_cart_extension.rb', line 53

def creator
  @creator
end

#extension_idObject (readonly)

Returns the value of attribute extension_id.



53
54
55
# File 'lib/ingenico/connect/sdk/domain/metadata/shopping_cart_extension.rb', line 53

def extension_id
  @extension_id
end

#nameObject (readonly)

Returns the value of attribute name.



53
54
55
# File 'lib/ingenico/connect/sdk/domain/metadata/shopping_cart_extension.rb', line 53

def name
  @name
end

#versionObject (readonly)

Returns the value of attribute version.



53
54
55
# File 'lib/ingenico/connect/sdk/domain/metadata/shopping_cart_extension.rb', line 53

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, version and extensionId – Overridden so ShoppingCartExtension can retain mandatory default arguments ++



26
27
28
29
30
31
32
# File 'lib/ingenico/connect/sdk/domain/metadata/shopping_cart_extension.rb', line 26

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')
  extension_id = hash['extensionId'] if hash.has_key?('extensionId')
  self.new(creator, name, version, extension_id)
end

Instance Method Details

#from_hash(hash) ⇒ Object

loads shopping cart metadata from a parameter hash



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

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'
  @extension_id = hash['extensionId'] if hash.has_key? 'extensionId'
end

#to_hObject

Converts the shopping cart metadata to a hash



35
36
37
38
39
40
41
42
# File 'lib/ingenico/connect/sdk/domain/metadata/shopping_cart_extension.rb', line 35

def to_h
  hash = super
  hash['creator'] = @creator unless @creator.nil?
  hash['name'] = @name unless @name.nil?
  hash['version'] = @version unless @version.nil?
  hash['extensionId'] = @extension_id unless @extension_id.nil?
  hash
end