Class: NewStoreApi::Rules

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/new_store_api/models/rules.rb

Overview

Rules Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(app_version = nil, associate_id = SKIP, store_id = SKIP) ⇒ Rules

Returns a new instance of Rules.



46
47
48
49
50
# File 'lib/new_store_api/models/rules.rb', line 46

def initialize(app_version = nil, associate_id = SKIP, store_id = SKIP)
  @app_version = app_version
  @associate_id = associate_id unless associate_id == SKIP
  @store_id = store_id unless store_id == SKIP
end

Instance Attribute Details

#app_versionString

A regex pattern to match one or multiple app versions.

Returns:

  • (String)


14
15
16
# File 'lib/new_store_api/models/rules.rb', line 14

def app_version
  @app_version
end

#associate_idString

A regex pattern to match one or multiple associateIds.

Returns:

  • (String)


18
19
20
# File 'lib/new_store_api/models/rules.rb', line 18

def associate_id
  @associate_id
end

#store_idString

A regex pattern to match one or multiple storeIds.

Returns:

  • (String)


22
23
24
# File 'lib/new_store_api/models/rules.rb', line 22

def store_id
  @store_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/new_store_api/models/rules.rb', line 53

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  app_version = hash.key?('appVersion') ? hash['appVersion'] : nil
  associate_id = hash.key?('associateId') ? hash['associateId'] : SKIP
  store_id = hash.key?('storeId') ? hash['storeId'] : SKIP

  # Create object from extracted values.
  Rules.new(app_version,
            associate_id,
            store_id)
end

.namesObject

A mapping from model property names to API property names.



25
26
27
28
29
30
31
# File 'lib/new_store_api/models/rules.rb', line 25

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['app_version'] = 'appVersion'
  @_hash['associate_id'] = 'associateId'
  @_hash['store_id'] = 'storeId'
  @_hash
end

.nullablesObject

An array for nullable fields



42
43
44
# File 'lib/new_store_api/models/rules.rb', line 42

def self.nullables
  []
end

.optionalsObject

An array for optional fields



34
35
36
37
38
39
# File 'lib/new_store_api/models/rules.rb', line 34

def self.optionals
  %w[
    associate_id
    store_id
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



75
76
77
78
79
# File 'lib/new_store_api/models/rules.rb', line 75

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} app_version: #{@app_version.inspect}, associate_id:"\
  " #{@associate_id.inspect}, store_id: #{@store_id.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



68
69
70
71
72
# File 'lib/new_store_api/models/rules.rb', line 68

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} app_version: #{@app_version}, associate_id: #{@associate_id}, store_id:"\
  " #{@store_id}>"
end