class Ingenico::Direct::SDK::Domain::ShoppingCartExtension

Represents metadata part of shopping carts.

Attributes

creator[R]
extension_id[R]
name[R]
version[R]

Public Class Methods

new(creator, name, version, extension_id = nil) click to toggle source
# File lib/ingenico/direct/sdk/domain/shopping_cart_extension.rb, line 7
def initialize(creator, name, version, extension_id = nil)
  raise ArgumentError if creator.nil? || creator.strip.empty?
  raise ArgumentError if name.nil? || name.strip.empty?
  raise ArgumentError if version.nil? || version.to_s.strip.empty?

  @creator = creator
  @name = name
  @version = version.to_s
  @extension_id = extension_id
end
new_from_hash(hash) click to toggle source

Constructs a new ShoppingCartExtension from parameter hash the hash should contain a creator, name, version and extensionId

# File lib/ingenico/direct/sdk/domain/shopping_cart_extension.rb, line 23
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

Public Instance Methods

from_hash(hash) click to toggle source

loads shopping cart metadata from a parameter hash

# File lib/ingenico/direct/sdk/domain/shopping_cart_extension.rb, line 42
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() click to toggle source

Converts the shopping cart metadata to a hash

Calls superclass method Ingenico::Direct::SDK::DataObject#to_h
# File lib/ingenico/direct/sdk/domain/shopping_cart_extension.rb, line 32
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