Class: NewStoreApi::Notification
- Defined in:
- lib/new_store_api/models/notification.rb
Overview
Notification Model.
Instance Attribute Summary collapse
-
#body ⇒ String
Notification body.
-
#subtitle ⇒ String
Notification sub title.
-
#title ⇒ String
Notification title.
-
#type ⇒ String
Notification type alert or background.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(type = nil, body = SKIP, subtitle = SKIP, title = SKIP) ⇒ Notification
constructor
A new instance of Notification.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
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
#body ⇒ String
Notification body
14 15 16 |
# File 'lib/new_store_api/models/notification.rb', line 14 def body @body end |
#subtitle ⇒ String
Notification sub title
18 19 20 |
# File 'lib/new_store_api/models/notification.rb', line 18 def subtitle @subtitle end |
#title ⇒ String
Notification title
22 23 24 |
# File 'lib/new_store_api/models/notification.rb', line 22 def title @title end |
#type ⇒ String
Notification type alert or background
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 |
.names ⇒ Object
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 |
.nullables ⇒ Object
An array for nullable fields
48 49 50 |
# File 'lib/new_store_api/models/notification.rb', line 48 def self.nullables [] end |
.optionals ⇒ Object
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
#inspect ⇒ Object
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_s ⇒ Object
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 |