Class: CarbonPms::Client
- Inherits:
-
Object
- Object
- CarbonPms::Client
- Includes:
- HTTParty
- Defined in:
- lib/carbon_pms/client.rb
Instance Method Summary collapse
-
#apns_bulk_notificaton(options = {}) ⇒ Object
(also: #apns_bulk_notification)
Sends bulk push notifications to the APNS.
-
#apns_notificaton(options = {}) ⇒ Object
(also: #apns_notification)
Sends a push notification to the APNS.
-
#create_app(options = {}) ⇒ HTTParty::Response
Creates either a GCM or APNS app to receive push messages.
-
#gcm_notification(options = {}) ⇒ Object
Sends a push notification to GCM.
-
#initialize(host = CarbonPms.host, auth_token = CarbonPms.auth_token, version = CarbonPms.version) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(host = CarbonPms.host, auth_token = CarbonPms.auth_token, version = CarbonPms.version) ⇒ Client
Returns a new instance of Client.
8 9 10 11 12 13 14 15 16 |
# File 'lib/carbon_pms/client.rb', line 8 def initialize(host=CarbonPms.host, auth_token=CarbonPms.auth_token, version=CarbonPms.version) if host.downcase.start_with?('http://', 'https://') self.class.base_uri "#{host}/api" else self.class.base_uri "https://#{host}/api" end self.class.headers('Authorization' => %Q[Token token="#{auth_token}"]) if auth_token self.class.headers('Accept' => "application/vnd.carbon.pms.v#{version}") if version end |
Instance Method Details
#apns_bulk_notificaton(options = {}) ⇒ Object Also known as: apns_bulk_notification
Sends bulk push notifications to the APNS
74 75 76 |
# File 'lib/carbon_pms/client.rb', line 74 def apns_bulk_notificaton(={}) return post '/push/apns_bulk', body: end |
#apns_notificaton(options = {}) ⇒ Object Also known as: apns_notification
Sends a push notification to the APNS
57 58 59 |
# File 'lib/carbon_pms/client.rb', line 57 def apns_notificaton(={}) return post '/push/apns', body: end |
#create_app(options = {}) ⇒ HTTParty::Response
Creates either a GCM or APNS app to receive push messages. You must create an app before you can send push notifications.
38 39 40 41 42 43 44 |
# File 'lib/carbon_pms/client.rb', line 38 def create_app(={}) raise ArguementError, 'You must provide an app name' unless [:name] [:environment] = 'development' unless %w{production sandbox}.include? [:environment] return post('/app/apns', body: ) if .has_key? :certificate return post('/app/gcm', body: ) if .has_key? :auth_key raise ArguementError, 'You must provide a :certificate or :auth_key' end |
#gcm_notification(options = {}) ⇒ Object
Sends a push notification to GCM
89 90 91 |
# File 'lib/carbon_pms/client.rb', line 89 def gcm_notification(={}) return post '/push/gcm', body: end |