Class: Chatrix::Api::Push
- Inherits:
-
ApiComponent
- Object
- ApiComponent
- Chatrix::Api::Push
- Defined in:
- lib/chatrix/api/push.rb
Overview
Contains methods for accessing the "push" endpoints on the server.
Refer to the official documentation for more information about these.
Instance Method Summary collapse
-
#add_rule(scope, kind, id, rule, opts = {}) ⇒ Boolean
Adds or change a push rule.
-
#delete_rule(scope, kind, id) ⇒ Boolean
Deletes a push rule.
-
#disable(scope, kind, id) ⇒ Boolean
Disable a push rule.
-
#enable(scope, kind, id, enabled = true) ⇒ Boolean
Sets the enabled state of a rule, the default is to enable it.
-
#get_rule(scope, kind, id) ⇒ Hash
Gets a specific rule.
-
#get_rules(scope = nil) ⇒ Hash
Gets all the push rules defined for this user, optionally limited to a specific scope.
-
#modify_pusher(pusher) ⇒ Boolean
Add, remove, or modify pushers for the current user.
-
#pushers ⇒ Hash
Get all active pushers for the current user.
-
#set_actions(scope, kind, id, actions) ⇒ Boolean
Sets or modifies the actions for a rule.
Methods inherited from ApiComponent
Constructor Details
This class inherits a constructor from Chatrix::Api::ApiComponent
Instance Method Details
#add_rule(scope, kind, id, rule, opts = {}) ⇒ Boolean
Adds or change a push rule.
68 69 70 71 |
# File 'lib/chatrix/api/push.rb', line 68 def add_rule(scope, kind, id, rule, opts = {}) path = "/pushrules/#{scope}/#{kind}/#{id}" make_request(:put, path, params: opts, content: rule).code == 200 end |
#delete_rule(scope, kind, id) ⇒ Boolean
Deletes a push rule.
50 51 52 |
# File 'lib/chatrix/api/push.rb', line 50 def delete_rule(scope, kind, id) make_request(:delete, "/pushrules/#{scope}/#{kind}/#{id}").code == 200 end |
#disable(scope, kind, id) ⇒ Boolean
Disable a push rule.
This is essentially an alias for #enable with the last parameter
as false
.
105 106 107 |
# File 'lib/chatrix/api/push.rb', line 105 def disable(scope, kind, id) enable(scope, kind, id, false) end |
#enable(scope, kind, id, enabled = true) ⇒ Boolean
Sets the enabled state of a rule, the default is to enable it.
93 94 95 96 |
# File 'lib/chatrix/api/push.rb', line 93 def enable(scope, kind, id, enabled = true) path = "/pushrules/#{scope}/#{kind}/#{id}/actions" make_request(:put, path, content: { enabled: enabled }).code == 200 end |
#get_rule(scope, kind, id) ⇒ Hash
Gets a specific rule.
40 41 42 |
# File 'lib/chatrix/api/push.rb', line 40 def get_rule(scope, kind, id) make_request(:get, "/pushrules/#{scope}/#{kind}/#{id}").parsed_response end |
#get_rules(scope = nil) ⇒ Hash
Gets all the push rules defined for this user, optionally limited to a specific scope.
29 30 31 32 |
# File 'lib/chatrix/api/push.rb', line 29 def get_rules(scope = nil) path = scope ? "/pushrules/#{scope}" : '/pushrules' make_request(:get, path).parsed_response end |
#modify_pusher(pusher) ⇒ Boolean
Add, remove, or modify pushers for the current user.
20 21 22 |
# File 'lib/chatrix/api/push.rb', line 20 def modify_pusher(pusher) make_request(:post, '/pushers/set', content: pusher).code == 200 end |
#pushers ⇒ Hash
Get all active pushers for the current user.
12 13 14 |
# File 'lib/chatrix/api/push.rb', line 12 def pushers make_request(:get, '/pushers').parsed_response end |
#set_actions(scope, kind, id, actions) ⇒ Boolean
Sets or modifies the actions for a rule.
81 82 83 84 |
# File 'lib/chatrix/api/push.rb', line 81 def set_actions(scope, kind, id, actions) path = "/pushrules/#{scope}/#{kind}/#{id}/actions" make_request(:put, path, content: actions).code == 200 end |