Class: NewStoreApi::StoreListV1Dto

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

Overview

StoreListV1Dto 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(items = nil, next_page_key = SKIP) ⇒ StoreListV1Dto

Returns a new instance of StoreListV1Dto.



44
45
46
47
# File 'lib/new_store_api/models/store_list_v1_dto.rb', line 44

def initialize(items = nil, next_page_key = SKIP)
  @items = items
  @next_page_key = next_page_key unless next_page_key == SKIP
end

Instance Attribute Details

#itemsArray[StoreV1Dto]

List of stores.

Returns:



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

def items
  @items
end

#next_page_keyString

Next page key.

  • The value can be used for retrieving the next page by setting the start_at query parameter.
  • Having no value indicates that there are no further pages to be retrieved.

Returns:

  • (String)


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

def next_page_key
  @next_page_key
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/new_store_api/models/store_list_v1_dto.rb', line 50

def self.from_hash(hash)
  return nil unless hash

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

  items = nil unless hash.key?('items')
  next_page_key = hash.key?('next_page_key') ? hash['next_page_key'] : SKIP

  # Create object from extracted values.
  StoreListV1Dto.new(items,
                     next_page_key)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['items'] = 'items'
  @_hash['next_page_key'] = 'next_page_key'
  @_hash
end

.nullablesObject

An array for nullable fields



40
41
42
# File 'lib/new_store_api/models/store_list_v1_dto.rb', line 40

def self.nullables
  []
end

.optionalsObject

An array for optional fields



33
34
35
36
37
# File 'lib/new_store_api/models/store_list_v1_dto.rb', line 33

def self.optionals
  %w[
    next_page_key
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



78
79
80
81
# File 'lib/new_store_api/models/store_list_v1_dto.rb', line 78

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} items: #{@items.inspect}, next_page_key: #{@next_page_key.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



72
73
74
75
# File 'lib/new_store_api/models/store_list_v1_dto.rb', line 72

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} items: #{@items}, next_page_key: #{@next_page_key}>"
end