Class: Worldline::Acquiring::SDK::Domain::ShoppingCartExtension
- Inherits:
-
DataObject
- Object
- DataObject
- Worldline::Acquiring::SDK::Domain::ShoppingCartExtension
- Defined in:
- lib/worldline/acquiring/sdk/domain/shopping_cart_extension.rb
Overview
Represents metadata part of shopping carts.
Instance Attribute Summary collapse
-
#creator ⇒ String
readonly
The current value of creator.
-
#extension_id ⇒ String
readonly
The current value of extension_id.
-
#name ⇒ String
readonly
The current value of name.
-
#version ⇒ String
readonly
The current value of version.
Class Method Summary collapse
-
.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 ++.
Instance Method Summary collapse
-
#from_hash(hash) ⇒ Object
loads shopping cart metadata from a parameter hash.
-
#initialize(creator, name, version, extension_id = nil) ⇒ ShoppingCartExtension
constructor
A new instance of ShoppingCartExtension.
-
#to_h ⇒ Object
Converts the shopping cart metadata to a hash.
Constructor Details
#initialize(creator, name, version, extension_id = nil) ⇒ ShoppingCartExtension
Returns a new instance of ShoppingCartExtension.
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/worldline/acquiring/sdk/domain/shopping_cart_extension.rb', line 14 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
#creator ⇒ String (readonly)
Returns the current value of creator.
13 14 15 |
# File 'lib/worldline/acquiring/sdk/domain/shopping_cart_extension.rb', line 13 def creator @creator end |
#extension_id ⇒ String (readonly)
Returns the current value of extension_id.
13 14 15 |
# File 'lib/worldline/acquiring/sdk/domain/shopping_cart_extension.rb', line 13 def extension_id @extension_id end |
#name ⇒ String (readonly)
Returns the current value of name.
13 14 15 |
# File 'lib/worldline/acquiring/sdk/domain/shopping_cart_extension.rb', line 13 def name @name end |
#version ⇒ String (readonly)
Returns the current value of version.
13 14 15 |
# File 'lib/worldline/acquiring/sdk/domain/shopping_cart_extension.rb', line 13 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 ++
30 31 32 33 34 35 36 |
# File 'lib/worldline/acquiring/sdk/domain/shopping_cart_extension.rb', line 30 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
49 50 51 52 53 54 55 |
# File 'lib/worldline/acquiring/sdk/domain/shopping_cart_extension.rb', line 49 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_h ⇒ Object
Converts the shopping cart metadata to a hash
39 40 41 42 43 44 45 46 |
# File 'lib/worldline/acquiring/sdk/domain/shopping_cart_extension.rb', line 39 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 |