Class: NewStoreApi::TagResponse

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

Overview

TagResponse 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(id = nil, created_at = SKIP, display_name = SKIP, import_id = SKIP, store_ids = SKIP, updated_at = SKIP) ⇒ TagResponse

Returns a new instance of TagResponse.



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

def initialize(id = nil, created_at = SKIP, display_name = SKIP,
               import_id = SKIP, store_ids = SKIP, updated_at = SKIP)
  @created_at = created_at unless created_at == SKIP
  @display_name = display_name unless display_name == SKIP
  @id = id
  @import_id = import_id unless import_id == SKIP
  @store_ids = store_ids unless store_ids == SKIP
  @updated_at = updated_at unless updated_at == SKIP
end

Instance Attribute Details

#created_atDateTime

Timestamp of the tag creation.

Returns:

  • (DateTime)


15
16
17
# File 'lib/new_store_api/models/tag_response.rb', line 15

def created_at
  @created_at
end

#display_nameString

The human readable tag identifier.

Returns:

  • (String)


19
20
21
# File 'lib/new_store_api/models/tag_response.rb', line 19

def display_name
  @display_name
end

#idString

The tag identifier.

Returns:

  • (String)


23
24
25
# File 'lib/new_store_api/models/tag_response.rb', line 23

def id
  @id
end

#import_idString

The import this tag is associated with, if any.

Returns:

  • (String)


27
28
29
# File 'lib/new_store_api/models/tag_response.rb', line 27

def import_id
  @import_id
end

#store_idsArray[String]

A list of store IDs the tag belongs to. If no store ID is provided, then the tag is global and will be visible for all the stores.

Returns:

  • (Array[String])


32
33
34
# File 'lib/new_store_api/models/tag_response.rb', line 32

def store_ids
  @store_ids
end

#updated_atDateTime

Timestamp of the latest tag update.

Returns:

  • (DateTime)


36
37
38
# File 'lib/new_store_api/models/tag_response.rb', line 36

def updated_at
  @updated_at
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
# File 'lib/new_store_api/models/tag_response.rb', line 79

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : nil
  created_at = if hash.key?('created_at')
                 (DateTimeHelper.from_rfc3339(hash['created_at']) if hash['created_at'])
               else
                 SKIP
               end
  display_name = hash.key?('display_name') ? hash['display_name'] : SKIP
  import_id = hash.key?('import_id') ? hash['import_id'] : SKIP
  store_ids = hash.key?('store_ids') ? hash['store_ids'] : SKIP
  updated_at = if hash.key?('updated_at')
                 (DateTimeHelper.from_rfc3339(hash['updated_at']) if hash['updated_at'])
               else
                 SKIP
               end

  # Create object from extracted values.
  TagResponse.new(id,
                  created_at,
                  display_name,
                  import_id,
                  store_ids,
                  updated_at)
end

.namesObject

A mapping from model property names to API property names.



39
40
41
42
43
44
45
46
47
48
# File 'lib/new_store_api/models/tag_response.rb', line 39

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['created_at'] = 'created_at'
  @_hash['display_name'] = 'display_name'
  @_hash['id'] = 'id'
  @_hash['import_id'] = 'import_id'
  @_hash['store_ids'] = 'store_ids'
  @_hash['updated_at'] = 'updated_at'
  @_hash
end

.nullablesObject

An array for nullable fields



62
63
64
65
66
# File 'lib/new_store_api/models/tag_response.rb', line 62

def self.nullables
  %w[
    import_id
  ]
end

.optionalsObject

An array for optional fields



51
52
53
54
55
56
57
58
59
# File 'lib/new_store_api/models/tag_response.rb', line 51

def self.optionals
  %w[
    created_at
    display_name
    import_id
    store_ids
    updated_at
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



123
124
125
126
127
128
# File 'lib/new_store_api/models/tag_response.rb', line 123

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} created_at: #{@created_at.inspect}, display_name: #{@display_name.inspect},"\
  " id: #{@id.inspect}, import_id: #{@import_id.inspect}, store_ids: #{@store_ids.inspect},"\
  " updated_at: #{@updated_at.inspect}>"
end

#to_custom_created_atObject



107
108
109
# File 'lib/new_store_api/models/tag_response.rb', line 107

def to_custom_created_at
  DateTimeHelper.to_rfc3339(created_at)
end

#to_custom_updated_atObject



111
112
113
# File 'lib/new_store_api/models/tag_response.rb', line 111

def to_custom_updated_at
  DateTimeHelper.to_rfc3339(updated_at)
end

#to_sObject

Provides a human-readable string representation of the object.



116
117
118
119
120
# File 'lib/new_store_api/models/tag_response.rb', line 116

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} created_at: #{@created_at}, display_name: #{@display_name}, id: #{@id},"\
  " import_id: #{@import_id}, store_ids: #{@store_ids}, updated_at: #{@updated_at}>"
end