Class: ShellCardManagementApIs::ProductRestrictionCard

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/shell_card_management_ap_is/models/product_restriction_card.rb

Overview

ProductRestrictionCard Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(products = SKIP, product_groups = SKIP) ⇒ ProductRestrictionCard

Returns a new instance of ProductRestrictionCard.



45
46
47
48
# File 'lib/shell_card_management_ap_is/models/product_restriction_card.rb', line 45

def initialize(products = SKIP, product_groups = SKIP)
  @products = products unless products == SKIP
  @product_groups = product_groups unless product_groups == SKIP
end

Instance Attribute Details

#product_groupsArray[String]

An array of product group IDs. Optional. Example: [ “670246404”, “40557126” ]

Returns:

  • (Array[String])


22
23
24
# File 'lib/shell_card_management_ap_is/models/product_restriction_card.rb', line 22

def product_groups
  @product_groups
end

#productsArray[String]

An array of 3-digit global product codes. Optional. Example: [ “033”, “021”, “023”]

Returns:

  • (Array[String])


16
17
18
# File 'lib/shell_card_management_ap_is/models/product_restriction_card.rb', line 16

def products
  @products
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



51
52
53
54
55
56
57
58
59
60
61
# File 'lib/shell_card_management_ap_is/models/product_restriction_card.rb', line 51

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  products = hash.key?('Products') ? hash['Products'] : SKIP
  product_groups = hash.key?('ProductGroups') ? hash['ProductGroups'] : SKIP

  # Create object from extracted values.
  ProductRestrictionCard.new(products,
                             product_groups)
end

.namesObject

A mapping from model property names to API property names.



25
26
27
28
29
30
# File 'lib/shell_card_management_ap_is/models/product_restriction_card.rb', line 25

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['products'] = 'Products'
  @_hash['product_groups'] = 'ProductGroups'
  @_hash
end

.nullablesObject

An array for nullable fields



41
42
43
# File 'lib/shell_card_management_ap_is/models/product_restriction_card.rb', line 41

def self.nullables
  []
end

.optionalsObject

An array for optional fields



33
34
35
36
37
38
# File 'lib/shell_card_management_ap_is/models/product_restriction_card.rb', line 33

def self.optionals
  %w[
    products
    product_groups
  ]
end