Class: Apnotic::Notification

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token) ⇒ Notification

Returns a new instance of Notification.



11
12
13
14
# File 'lib/apnotic/notification.rb', line 11

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

Instance Attribute Details

#alertObject

Returns the value of attribute alert.



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

def alert
  @alert
end

#apns_collapse_idObject

Returns the value of attribute apns_collapse_id.



9
10
11
# File 'lib/apnotic/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/notification.rb', line 9

def apns_id
  @apns_id
end

#authorizationObject

Returns the value of attribute authorization.



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

def authorization
  @authorization
end

#badgeObject

Returns the value of attribute badge.



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

def badge
  @badge
end

#categoryObject

Returns the value of attribute category.



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

def category
  @category
end

#content_availableObject

Returns the value of attribute content_available.



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

def content_available
  @content_available
end

#custom_payloadObject

Returns the value of attribute custom_payload.



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

def custom_payload
  @custom_payload
end

#expirationObject

Returns the value of attribute expiration.



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

def expiration
  @expiration
end

#mutable_contentObject

Returns the value of attribute mutable_content.



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

def mutable_content
  @mutable_content
end

#priorityObject

Returns the value of attribute priority.



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

def priority
  @priority
end

#soundObject

Returns the value of attribute sound.



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

def sound
  @sound
end

#tokenObject (readonly)

Returns the value of attribute token.



7
8
9
# File 'lib/apnotic/notification.rb', line 7

def token
  @token
end

#topicObject

Returns the value of attribute topic.



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

def topic
  @topic
end

#url_argsObject

Returns the value of attribute url_args.



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

def url_args
  @url_args
end

Instance Method Details

#authorization_headerObject



20
21
22
# File 'lib/apnotic/notification.rb', line 20

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

#bodyObject



16
17
18
# File 'lib/apnotic/notification.rb', line 16

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