Module: Pixela::Client::NotificationMethods
- Included in:
- Pixela::Client
- Defined in:
- lib/pixela/client/notificaton_methods.rb
Instance Method Summary collapse
-
#create_notification(graph_id:, notification_id:, name:, target:, condition:, threshold:, remind_by: nil, channel_id:) ⇒ Pixela::Response
Create a notification rule.
-
#delete_notification(graph_id:, notification_id:) ⇒ Pixela::Response
Delete predefined notification settings.
-
#get_notifications(graph_id:) ⇒ Array<Pixela::Response>
Get all predefined notifications.
-
#update_notification(graph_id:, notification_id:, name:, target:, condition:, threshold:, channel_id:) ⇒ Pixela::Response
Update predefined notification rule.
Instance Method Details
#create_notification(graph_id:, notification_id:, name:, target:, condition:, threshold:, remind_by: nil, channel_id:) ⇒ Pixela::Response
Create a notification rule.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/pixela/client/notificaton_methods.rb', line 21 def create_notification(graph_id:, notification_id:, name:, target:, condition:, threshold:, remind_by: nil, channel_id:) params = { id: notification_id, name: name, target: target, condition: condition, threshold: threshold, remindBy: remind_by, channelID: channel_id, } with_error_handling do connection.post("users/#{username}/graphs/#{graph_id}/notifications", compact_hash(params)).body end end |
#delete_notification(graph_id:, notification_id:) ⇒ Pixela::Response
Delete predefined notification settings.
100 101 102 103 104 |
# File 'lib/pixela/client/notificaton_methods.rb', line 100 def delete_notification(graph_id:, notification_id:) with_error_handling do connection.delete("users/#{username}/graphs/#{graph_id}/notifications/#{notification_id}").body end end |
#get_notifications(graph_id:) ⇒ Array<Pixela::Response>
Get all predefined notifications.
49 50 51 52 53 |
# File 'lib/pixela/client/notificaton_methods.rb', line 49 def get_notifications(graph_id:) with_error_handling do connection.get("users/#{username}/graphs/#{graph_id}/notifications").body.notifications end end |
#update_notification(graph_id:, notification_id:, name:, target:, condition:, threshold:, channel_id:) ⇒ Pixela::Response
Update predefined notification rule.
73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/pixela/client/notificaton_methods.rb', line 73 def update_notification(graph_id:, notification_id:, name:, target:, condition:, threshold:, channel_id:) params = { name: name, target: target, condition: condition, threshold: threshold, channelID: channel_id, } with_error_handling do connection.put("users/#{username}/graphs/#{graph_id}/notifications/#{notification_id}", compact_hash(params)).body end end |