Class: NewStoreApi::Notification

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

Overview

Notification 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(type = nil, body = SKIP, subtitle = SKIP, title = SKIP) ⇒ Notification

Returns a new instance of Notification.



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

def initialize(type = nil, body = SKIP, subtitle = SKIP, title = SKIP)
  @body = body unless body == SKIP
  @subtitle = subtitle unless subtitle == SKIP
  @title = title unless title == SKIP
  @type = type
end

Instance Attribute Details

#bodyString

Notification body

Returns:

  • (String)


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

def body
  @body
end

#subtitleString

Notification sub title

Returns:

  • (String)


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

def subtitle
  @subtitle
end

#titleString

Notification title

Returns:

  • (String)


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

def title
  @title
end

#typeString

Notification type alert or background

Returns:

  • (String)


26
27
28
# File 'lib/new_store_api/models/notification.rb', line 26

def type
  @type
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  type = hash.key?('type') ? hash['type'] : nil
  body = hash.key?('body') ? hash['body'] : SKIP
  subtitle = hash.key?('subtitle') ? hash['subtitle'] : SKIP
  title = hash.key?('title') ? hash['title'] : SKIP

  # Create object from extracted values.
  Notification.new(type,
                   body,
                   subtitle,
                   title)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['body'] = 'body'
  @_hash['subtitle'] = 'subtitle'
  @_hash['title'] = 'title'
  @_hash['type'] = 'type'
  @_hash
end

.nullablesObject

An array for nullable fields



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

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    body
    subtitle
    title
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



83
84
85
86
87
# File 'lib/new_store_api/models/notification.rb', line 83

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} body: #{@body.inspect}, subtitle: #{@subtitle.inspect}, title:"\
  " #{@title.inspect}, type: #{@type.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



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

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} body: #{@body}, subtitle: #{@subtitle}, title: #{@title}, type: #{@type}>"
end