Class: Apnotic::AbstractNotification

Inherits:
Object
  • Object
show all
Defined in:
lib/apnotic/abstract_notification.rb

Direct Known Subclasses

MdmNotification, Notification

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token) ⇒ AbstractNotification

Returns a new instance of AbstractNotification.



17
18
19
20
# File 'lib/apnotic/abstract_notification.rb', line 17

def initialize(token)
  @token   = token
  @apns_id = SecureRandom.uuid
end

Instance Attribute Details

#apns_collapse_idObject

Returns the value of attribute apns_collapse_id.



9
10
11
# File 'lib/apnotic/abstract_notification.rb', line 9

def apns_collapse_id
  @apns_collapse_id
end

#apns_idObject

Returns the value of attribute apns_id.



9
10
11
# File 'lib/apnotic/abstract_notification.rb', line 9

def apns_id
  @apns_id
end

#authorizationObject

Returns the value of attribute authorization.



9
10
11
# File 'lib/apnotic/abstract_notification.rb', line 9

def authorization
  @authorization
end

#expirationObject

Returns the value of attribute expiration.



9
10
11
# File 'lib/apnotic/abstract_notification.rb', line 9

def expiration
  @expiration
end

#priorityObject

Returns the value of attribute priority.



9
10
11
# File 'lib/apnotic/abstract_notification.rb', line 9

def priority
  @priority
end

#push_typeObject

Returns the value of attribute push_type.



9
10
11
# File 'lib/apnotic/abstract_notification.rb', line 9

def push_type
  @push_type
end

#tokenObject (readonly)

Returns the value of attribute token.



8
9
10
# File 'lib/apnotic/abstract_notification.rb', line 8

def token
  @token
end

#topicObject

Returns the value of attribute topic.



9
10
11
# File 'lib/apnotic/abstract_notification.rb', line 9

def topic
  @topic
end

Instance Method Details

#authorization_headerObject



26
27
28
# File 'lib/apnotic/abstract_notification.rb', line 26

def authorization_header
  authorization ? "bearer #{authorization}" : nil
end

#background_notification?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/apnotic/abstract_notification.rb', line 30

def background_notification?
  false
end

#bodyObject



22
23
24
# File 'lib/apnotic/abstract_notification.rb', line 22

def body
  JSON.dump(to_hash).force_encoding(Encoding::BINARY)
end