Class: ShellDataReportingApIs::PurchaseCategories

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/shell_data_reporting_ap_is/models/purchase_categories.rb

Overview

PurchaseCategories Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(id = SKIP, code = SKIP, name = SKIP, is_visible = SKIP, product_groups = SKIP) ⇒ PurchaseCategories

Returns a new instance of PurchaseCategories.



83
84
85
86
87
88
89
90
# File 'lib/shell_data_reporting_ap_is/models/purchase_categories.rb', line 83

def initialize(id = SKIP, code = SKIP, name = SKIP, is_visible = SKIP,
               product_groups = SKIP)
  @id = id unless id == SKIP
  @code = code unless code == SKIP
  @name = name unless name == SKIP
  @is_visible = is_visible unless is_visible == SKIP
  @product_groups = product_groups unless product_groups == SKIP
end

Instance Attribute Details

#codeString

Purchase category code Example: 0,1, 2 etc. Full list below: 0 - All Fuels (without VP) and Lubricants 1 - Fuel Save only 2 - Fuel Save and Lubricants 3 - No Restrictions 4 - VP and Fuel Save 5 - Diesel ONLY 6 - Diesel and Lubricants 7 - VP and Lubricants 8 - VP and Fuel Save and Lubricants

Returns:

  • (String)


29
30
31
# File 'lib/shell_data_reporting_ap_is/models/purchase_categories.rb', line 29

def code
  @code
end

#idInteger

Purchase category Id

Returns:

  • (Integer)


14
15
16
# File 'lib/shell_data_reporting_ap_is/models/purchase_categories.rb', line 14

def id
  @id
end

#is_visibleTrueClass | FalseClass

If True then PurchaseCategory can be used while submitting new order cards requests. If false this PurchaseCategory will not be used for Ordering Cards.

Returns:

  • (TrueClass | FalseClass)


50
51
52
# File 'lib/shell_data_reporting_ap_is/models/purchase_categories.rb', line 50

def is_visible
  @is_visible
end

#nameString

Purchase category name Example: Fuel Save Only Full list below: 0 - All Fuels (without VP) and Lubricants 1 - Fuel Save only 2 - Fuel Save and Lubricants 3 - No Restrictions 4 - VP and Fuel Save 5 - Diesel ONLY 6 - Diesel and Lubricants 7 - VP and Lubricants 8 - VP and Fuel Save and Lubricants

Returns:

  • (String)


44
45
46
# File 'lib/shell_data_reporting_ap_is/models/purchase_categories.rb', line 44

def name
  @name
end

#product_groupsString

List of Default product groups

Returns:

  • (String)


54
55
56
# File 'lib/shell_data_reporting_ap_is/models/purchase_categories.rb', line 54

def product_groups
  @product_groups
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/shell_data_reporting_ap_is/models/purchase_categories.rb', line 93

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('Id') ? hash['Id'] : SKIP
  code = hash.key?('Code') ? hash['Code'] : SKIP
  name = hash.key?('Name') ? hash['Name'] : SKIP
  is_visible = hash.key?('IsVisible') ? hash['IsVisible'] : SKIP
  product_groups = hash.key?('ProductGroups') ? hash['ProductGroups'] : SKIP

  # Create object from extracted values.
  PurchaseCategories.new(id,
                         code,
                         name,
                         is_visible,
                         product_groups)
end

.namesObject

A mapping from model property names to API property names.



57
58
59
60
61
62
63
64
65
# File 'lib/shell_data_reporting_ap_is/models/purchase_categories.rb', line 57

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'Id'
  @_hash['code'] = 'Code'
  @_hash['name'] = 'Name'
  @_hash['is_visible'] = 'IsVisible'
  @_hash['product_groups'] = 'ProductGroups'
  @_hash
end

.nullablesObject

An array for nullable fields



79
80
81
# File 'lib/shell_data_reporting_ap_is/models/purchase_categories.rb', line 79

def self.nullables
  []
end

.optionalsObject

An array for optional fields



68
69
70
71
72
73
74
75
76
# File 'lib/shell_data_reporting_ap_is/models/purchase_categories.rb', line 68

def self.optionals
  %w[
    id
    code
    name
    is_visible
    product_groups
  ]
end