Class: NewStoreApi::Recipients

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

Overview

Recipients of the notification that might be a list of users or group by a custom topics. If more than one is set, the result is the intersection of them. They are technically filterd by the AND operator.

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, topics = SKIP, user_ids = SKIP) ⇒ Recipients

Returns a new instance of Recipients.



48
49
50
51
52
# File 'lib/new_store_api/models/recipients.rb', line 48

def initialize(app_name = nil, topics = SKIP, user_ids = SKIP)
  @app_name = app_name
  @topics = topics unless topics == SKIP
  @user_ids = user_ids unless user_ids == SKIP
end

Instance Attribute Details

#app_nameString

Recipients in a specific app

Returns:

  • (String)


16
17
18
# File 'lib/new_store_api/models/recipients.rb', line 16

def app_name
  @app_name
end

#topicsObject

Recipients by subscriptions to a topics by name and value

Returns:

  • (Object)


20
21
22
# File 'lib/new_store_api/models/recipients.rb', line 20

def topics
  @topics
end

#user_idsArray[String]

List of users who receive the notification

Returns:

  • (Array[String])


24
25
26
# File 'lib/new_store_api/models/recipients.rb', line 24

def user_ids
  @user_ids
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/new_store_api/models/recipients.rb', line 55

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  app_name = hash.key?('app_name') ? hash['app_name'] : nil
  topics = hash.key?('topics') ? hash['topics'] : SKIP
  user_ids = hash.key?('user_ids') ? hash['user_ids'] : SKIP

  # Create object from extracted values.
  Recipients.new(app_name,
                 topics,
                 user_ids)
end

.namesObject

A mapping from model property names to API property names.



27
28
29
30
31
32
33
# File 'lib/new_store_api/models/recipients.rb', line 27

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['app_name'] = 'app_name'
  @_hash['topics'] = 'topics'
  @_hash['user_ids'] = 'user_ids'
  @_hash
end

.nullablesObject

An array for nullable fields



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

def self.nullables
  []
end

.optionalsObject

An array for optional fields



36
37
38
39
40
41
# File 'lib/new_store_api/models/recipients.rb', line 36

def self.optionals
  %w[
    topics
    user_ids
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



76
77
78
79
80
# File 'lib/new_store_api/models/recipients.rb', line 76

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

#to_sObject

Provides a human-readable string representation of the object.



70
71
72
73
# File 'lib/new_store_api/models/recipients.rb', line 70

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