Class: PushNotifications::Client
- Inherits:
-
Object
- Object
- PushNotifications::Client
- Extended by:
- Forwardable
- Defined in:
- lib/push_notifications/client.rb
Defined Under Namespace
Classes: Response
Constant Summary collapse
- BASE_URL =
'pushnotifications.pusher.com/publish_api/v1/instances'
Instance Method Summary collapse
-
#initialize(config: PushNotifications) ⇒ Client
constructor
A new instance of Client.
- #post(resource, payload = {}) ⇒ Object
Constructor Details
#initialize(config: PushNotifications) ⇒ Client
Returns a new instance of Client.
15 16 17 |
# File 'lib/push_notifications/client.rb', line 15 def initialize(config: PushNotifications) @config = config end |
Instance Method Details
#post(resource, payload = {}) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/push_notifications/client.rb', line 19 def post(resource, payload = {}) url = build_url(resource) body = payload.to_json RestClient::Request.execute( method: :post, url: url, payload: body, headers: headers ) do |response| status = response.code body = JSON.parse(response.body) Response.new(status, body, status == 200 ? true : false) end end |