Class: CloudFivePush::Notification

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/cloud_five_push/notification.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key = nil) ⇒ Notification

Returns a new instance of Notification.



11
12
13
14
15
16
17
18
19
# File 'lib/cloud_five_push/notification.rb', line 11

def initialize(api_key=nil)
  @api_key = api_key || CloudFivePush.api_key
  if @api_key.nil?
    raise "api_key is required (or set CloudFivePush.api_key)"
  end
  @broadcast = false
  @user_identifiers = []
  @aps_environment = CloudFivePush.aps_environment
end

Instance Attribute Details

#alertObject

Returns the value of attribute alert.



4
5
6
# File 'lib/cloud_five_push/notification.rb', line 4

def alert
  @alert
end

#api_keyObject

Returns the value of attribute api_key.



4
5
6
# File 'lib/cloud_five_push/notification.rb', line 4

def api_key
  @api_key
end

#aps_environmentObject

Returns the value of attribute aps_environment.



4
5
6
# File 'lib/cloud_five_push/notification.rb', line 4

def aps_environment
  @aps_environment
end

#badgeObject

Returns the value of attribute badge.



4
5
6
# File 'lib/cloud_five_push/notification.rb', line 4

def badge
  @badge
end

#broadcastObject

Returns the value of attribute broadcast.



4
5
6
# File 'lib/cloud_five_push/notification.rb', line 4

def broadcast
  @broadcast
end

#content_availableObject

Returns the value of attribute content_available.



4
5
6
# File 'lib/cloud_five_push/notification.rb', line 4

def content_available
  @content_available
end

#dataObject

Returns the value of attribute data.



4
5
6
# File 'lib/cloud_five_push/notification.rb', line 4

def data
  @data
end

#messageObject

Returns the value of attribute message.



4
5
6
# File 'lib/cloud_five_push/notification.rb', line 4

def message
  @message
end

#scheduled_atObject

Returns the value of attribute scheduled_at.



4
5
6
# File 'lib/cloud_five_push/notification.rb', line 4

def scheduled_at
  @scheduled_at
end

#user_identifiersObject

Returns the value of attribute user_identifiers.



4
5
6
# File 'lib/cloud_five_push/notification.rb', line 4

def user_identifiers
  @user_identifiers
end

Instance Method Details

#notify!Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/cloud_five_push/notification.rb', line 21

def notify!
  if blank_param?(@user_identifiers) && !@broadcast
    raise "Please set user_identifiers or set broadcast=true"
  end

  if @broadcast && !blank_param?(@user_identifiers)
    raise "Can't both broadcast and set user_identifiers"
  end

  self.class.post('/push/notify', body: push_params)
end