Class: Urbanairship::Push::Push
- Inherits:
-
Object
- Object
- Urbanairship::Push::Push
- Defined in:
- lib/urbanairship/push/push.rb
Overview
A Push Notification.
Constant Summary
Constants included from Common
Instance Attribute Summary collapse
-
#audience ⇒ Object
Returns the value of attribute audience.
-
#campaigns ⇒ Object
Returns the value of attribute campaigns.
-
#client ⇒ Object
writeonly
Sets the attribute client.
-
#device_types ⇒ Object
Returns the value of attribute device_types.
-
#in_app ⇒ Object
Returns the value of attribute in_app.
-
#localizations ⇒ Object
Returns the value of attribute localizations.
-
#message ⇒ Object
Returns the value of attribute message.
-
#notification ⇒ Object
Returns the value of attribute notification.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(client) ⇒ Push
constructor
Initialize a Push Object.
- #payload ⇒ Object
-
#send_push ⇒ PushResponse
Send the Push Object.
Methods included from Loggable
create_logger, #logger, logger
Methods included from Common
#apid_path, #channel_path, #compact_helper, #create_and_send_path, #custom_events_path, #device_token_path, #experiments_path, #lists_path, #named_users_path, #open_channel_path, #pipelines_path, #push_path, #reports_path, #required, #schedules_path, #segments_path, #tag_lists_path, #try_helper
Constructor Details
#initialize(client) ⇒ Push
Initialize a Push Object
28 29 30 |
# File 'lib/urbanairship/push/push.rb', line 28 def initialize(client) @client = client end |
Instance Attribute Details
#audience ⇒ Object
Returns the value of attribute audience.
13 14 15 |
# File 'lib/urbanairship/push/push.rb', line 13 def audience @audience end |
#campaigns ⇒ Object
Returns the value of attribute campaigns.
13 14 15 |
# File 'lib/urbanairship/push/push.rb', line 13 def campaigns @campaigns end |
#client=(value) ⇒ Object (writeonly)
Sets the attribute client
11 12 13 |
# File 'lib/urbanairship/push/push.rb', line 11 def client=(value) @client = value end |
#device_types ⇒ Object
Returns the value of attribute device_types.
13 14 15 |
# File 'lib/urbanairship/push/push.rb', line 13 def device_types @device_types end |
#in_app ⇒ Object
Returns the value of attribute in_app.
13 14 15 |
# File 'lib/urbanairship/push/push.rb', line 13 def in_app @in_app end |
#localizations ⇒ Object
Returns the value of attribute localizations.
13 14 15 |
# File 'lib/urbanairship/push/push.rb', line 13 def localizations @localizations end |
#message ⇒ Object
Returns the value of attribute message.
13 14 15 |
# File 'lib/urbanairship/push/push.rb', line 13 def @message end |
#notification ⇒ Object
Returns the value of attribute notification.
13 14 15 |
# File 'lib/urbanairship/push/push.rb', line 13 def notification @notification end |
#options ⇒ Object
Returns the value of attribute options.
13 14 15 |
# File 'lib/urbanairship/push/push.rb', line 13 def @options end |
Instance Method Details
#payload ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/urbanairship/push/push.rb', line 32 def payload compact_helper({ audience: audience, notification: notification, options: , device_types: device_types, message: , in_app: in_app, campaigns: campaigns, localizations: localizations }) end |
#send_push ⇒ PushResponse
Send the Push Object
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/urbanairship/push/push.rb', line 51 def send_push response = @client.send_request( method: 'POST', body: JSON.dump(payload), path: push_path, content_type: 'application/json' ) pr = PushResponse.new(http_response_body: response['body'], http_response_code: response['code'].to_s) logger.info { pr.format } pr end |