Class: NewStoreApi::SubscriptionResponse

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

Overview

SubscriptionResponse 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_name = nil, user_id = nil, topic_name = SKIP, topic_value = SKIP) ⇒ SubscriptionResponse

Returns a new instance of SubscriptionResponse.



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

def initialize(app_name = nil, user_id = nil, topic_name = SKIP,
               topic_value = SKIP)
  @app_name = app_name
  @topic_name = topic_name unless topic_name == SKIP
  @topic_value = topic_value unless topic_value == SKIP
  @user_id = user_id
end

Instance Attribute Details

#app_nameString

Identifier of the app name where this topic makes sense.

Returns:

  • (String)


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

def app_name
  @app_name
end

#topic_nameString

Identifier topic name for this subscription

Returns:

  • (String)


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

def topic_name
  @topic_name
end

#topic_valueString

Identifier topic value for this subscription which can be 'True' or 'False'

Returns:

  • (String)


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

def topic_value
  @topic_value
end

#user_idString

Identifier of the user who wants to subscribe to a new topic.

Returns:

  • (String)


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

def user_id
  @user_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/new_store_api/models/subscription_response.rb', line 61

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  app_name = hash.key?('app_name') ? hash['app_name'] : nil
  user_id = hash.key?('user_id') ? hash['user_id'] : nil
  topic_name = hash.key?('topic_name') ? hash['topic_name'] : SKIP
  topic_value = hash.key?('topic_value') ? hash['topic_value'] : SKIP

  # Create object from extracted values.
  SubscriptionResponse.new(app_name,
                           user_id,
                           topic_name,
                           topic_value)
end

.namesObject

A mapping from model property names to API property names.



30
31
32
33
34
35
36
37
# File 'lib/new_store_api/models/subscription_response.rb', line 30

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['app_name'] = 'app_name'
  @_hash['topic_name'] = 'topic_name'
  @_hash['topic_value'] = 'topic_value'
  @_hash['user_id'] = 'user_id'
  @_hash
end

.nullablesObject

An array for nullable fields



48
49
50
# File 'lib/new_store_api/models/subscription_response.rb', line 48

def self.nullables
  []
end

.optionalsObject

An array for optional fields



40
41
42
43
44
45
# File 'lib/new_store_api/models/subscription_response.rb', line 40

def self.optionals
  %w[
    topic_name
    topic_value
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



85
86
87
88
89
# File 'lib/new_store_api/models/subscription_response.rb', line 85

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} app_name: #{@app_name.inspect}, topic_name: #{@topic_name.inspect},"\
  " topic_value: #{@topic_value.inspect}, user_id: #{@user_id.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



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

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} app_name: #{@app_name}, topic_name: #{@topic_name}, topic_value:"\
  " #{@topic_value}, user_id: #{@user_id}>"
end