Class: ShellCardManagementApIs::LocationRestriction

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

Overview

LocationRestriction Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(country_restrictions = SKIP, network_restrictions = SKIP, shell_site_restrictions = SKIP, partner_site_restrictions = SKIP) ⇒ LocationRestriction

Returns a new instance of LocationRestriction.



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

def initialize(country_restrictions = SKIP, network_restrictions = SKIP,
               shell_site_restrictions = SKIP,
               partner_site_restrictions = SKIP)
  @country_restrictions = country_restrictions unless country_restrictions == SKIP
  @network_restrictions = network_restrictions unless network_restrictions == SKIP
  @shell_site_restrictions = shell_site_restrictions unless shell_site_restrictions == SKIP
  unless partner_site_restrictions == SKIP
    @partner_site_restrictions =
      partner_site_restrictions
  end
end

Instance Attribute Details

#country_restrictionsCountryRestriction

TODO: Write general description for this method

Returns:



14
15
16
# File 'lib/shell_card_management_ap_is/models/location_restriction.rb', line 14

def country_restrictions
  @country_restrictions
end

#network_restrictionsArray[NetworkRestriction]

TODO: Write general description for this method

Returns:



18
19
20
# File 'lib/shell_card_management_ap_is/models/location_restriction.rb', line 18

def network_restrictions
  @network_restrictions
end

#partner_site_restrictionsArray[PartnerSiteRestriction]

TODO: Write general description for this method

Returns:



26
27
28
# File 'lib/shell_card_management_ap_is/models/location_restriction.rb', line 26

def partner_site_restrictions
  @partner_site_restrictions
end

#shell_site_restrictionsArray[ShellSiteRestriction]

TODO: Write general description for this method

Returns:



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

def shell_site_restrictions
  @shell_site_restrictions
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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
# File 'lib/shell_card_management_ap_is/models/location_restriction.rb', line 66

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  country_restrictions = CountryRestriction.from_hash(hash['CountryRestrictions']) if
    hash['CountryRestrictions']
  # Parameter is an array, so we need to iterate through it
  network_restrictions = nil
  unless hash['NetworkRestrictions'].nil?
    network_restrictions = []
    hash['NetworkRestrictions'].each do |structure|
      network_restrictions << (NetworkRestriction.from_hash(structure) if structure)
    end
  end

  network_restrictions = SKIP unless hash.key?('NetworkRestrictions')
  # Parameter is an array, so we need to iterate through it
  shell_site_restrictions = nil
  unless hash['ShellSiteRestrictions'].nil?
    shell_site_restrictions = []
    hash['ShellSiteRestrictions'].each do |structure|
      shell_site_restrictions << (ShellSiteRestriction.from_hash(structure) if structure)
    end
  end

  shell_site_restrictions = SKIP unless hash.key?('ShellSiteRestrictions')
  # Parameter is an array, so we need to iterate through it
  partner_site_restrictions = nil
  unless hash['PartnerSiteRestrictions'].nil?
    partner_site_restrictions = []
    hash['PartnerSiteRestrictions'].each do |structure|
      partner_site_restrictions << (PartnerSiteRestriction.from_hash(structure) if structure)
    end
  end

  partner_site_restrictions = SKIP unless hash.key?('PartnerSiteRestrictions')

  # Create object from extracted values.
  LocationRestriction.new(country_restrictions,
                          network_restrictions,
                          shell_site_restrictions,
                          partner_site_restrictions)
end

.namesObject

A mapping from model property names to API property names.



29
30
31
32
33
34
35
36
# File 'lib/shell_card_management_ap_is/models/location_restriction.rb', line 29

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['country_restrictions'] = 'CountryRestrictions'
  @_hash['network_restrictions'] = 'NetworkRestrictions'
  @_hash['shell_site_restrictions'] = 'ShellSiteRestrictions'
  @_hash['partner_site_restrictions'] = 'PartnerSiteRestrictions'
  @_hash
end

.nullablesObject

An array for nullable fields



49
50
51
# File 'lib/shell_card_management_ap_is/models/location_restriction.rb', line 49

def self.nullables
  []
end

.optionalsObject

An array for optional fields



39
40
41
42
43
44
45
46
# File 'lib/shell_card_management_ap_is/models/location_restriction.rb', line 39

def self.optionals
  %w[
    country_restrictions
    network_restrictions
    shell_site_restrictions
    partner_site_restrictions
  ]
end