Class: ShellCardManagementApIs::ProductGroup

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

Overview

ProductGroup Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(reference_id = SKIP, product_group_id = SKIP, name = SKIP, is_default = SKIP, is_fuel_type = SKIP, products = SKIP) ⇒ ProductGroup

Returns a new instance of ProductGroup.



71
72
73
74
75
76
77
78
79
# File 'lib/shell_card_management_ap_is/models/product_group.rb', line 71

def initialize(reference_id = SKIP, product_group_id = SKIP, name = SKIP,
               is_default = SKIP, is_fuel_type = SKIP, products = SKIP)
  @reference_id = reference_id unless reference_id == SKIP
  @product_group_id = product_group_id unless product_group_id == SKIP
  @name = name unless name == SKIP
  @is_default = is_default unless is_default == SKIP
  @is_fuel_type = is_fuel_type unless is_fuel_type == SKIP
  @products = products unless products == SKIP
end

Instance Attribute Details

#is_defaultTrueClass | FalseClass

Indicates whether this is a default Product Group at ColCo level or not. Note: The Customer level default settings are not considered here.

Returns:

  • (TrueClass | FalseClass)


28
29
30
# File 'lib/shell_card_management_ap_is/models/product_group.rb', line 28

def is_default
  @is_default
end

#is_fuel_typeTrueClass | FalseClass

Identifies the type of Product group. true - if it is a Fuel type Product group false - if it is Non-Fuel type

Returns:

  • (TrueClass | FalseClass)


34
35
36
# File 'lib/shell_card_management_ap_is/models/product_group.rb', line 34

def is_fuel_type
  @is_fuel_type
end

#nameString

Product group name

Returns:

  • (String)


23
24
25
# File 'lib/shell_card_management_ap_is/models/product_group.rb', line 23

def name
  @name
end

#product_group_idString

Product group ID

Returns:

  • (String)


19
20
21
# File 'lib/shell_card_management_ap_is/models/product_group.rb', line 19

def product_group_id
  @product_group_id
end

#productsArray[ProductAllOf0]

Identifies the type of Product group. true - if it is a Fuel type Product group false - if it is Non-Fuel type

Returns:



40
41
42
# File 'lib/shell_card_management_ap_is/models/product_group.rb', line 40

def products
  @products
end

#reference_idInteger

Referenced Purchase Category Id Example: 123, 124

Returns:

  • (Integer)


15
16
17
# File 'lib/shell_card_management_ap_is/models/product_group.rb', line 15

def reference_id
  @reference_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/shell_card_management_ap_is/models/product_group.rb', line 82

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  reference_id = hash.key?('ReferenceId') ? hash['ReferenceId'] : SKIP
  product_group_id =
    hash.key?('ProductGroupId') ? hash['ProductGroupId'] : SKIP
  name = hash.key?('Name') ? hash['Name'] : SKIP
  is_default = hash.key?('IsDefault') ? hash['IsDefault'] : SKIP
  is_fuel_type = hash.key?('IsFuelType') ? hash['IsFuelType'] : SKIP
  # Parameter is an array, so we need to iterate through it
  products = nil
  unless hash['Products'].nil?
    products = []
    hash['Products'].each do |structure|
      products << (ProductAllOf0.from_hash(structure) if structure)
    end
  end

  products = SKIP unless hash.key?('Products')

  # Create object from extracted values.
  ProductGroup.new(reference_id,
                   product_group_id,
                   name,
                   is_default,
                   is_fuel_type,
                   products)
end

.namesObject

A mapping from model property names to API property names.



43
44
45
46
47
48
49
50
51
52
# File 'lib/shell_card_management_ap_is/models/product_group.rb', line 43

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['reference_id'] = 'ReferenceId'
  @_hash['product_group_id'] = 'ProductGroupId'
  @_hash['name'] = 'Name'
  @_hash['is_default'] = 'IsDefault'
  @_hash['is_fuel_type'] = 'IsFuelType'
  @_hash['products'] = 'Products'
  @_hash
end

.nullablesObject

An array for nullable fields



67
68
69
# File 'lib/shell_card_management_ap_is/models/product_group.rb', line 67

def self.nullables
  []
end

.optionalsObject

An array for optional fields



55
56
57
58
59
60
61
62
63
64
# File 'lib/shell_card_management_ap_is/models/product_group.rb', line 55

def self.optionals
  %w[
    reference_id
    product_group_id
    name
    is_default
    is_fuel_type
    products
  ]
end