pixela 1.5.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3c390c81b40e7d104a1e81987394e6111e0f80fe5d1556340f7a3116dc8b0e5d
4
- data.tar.gz: 1869873ca527f4990a34bf148a44634109e6d4a2ae6b7cbc1cedd16281236539
3
+ metadata.gz: a19da817bef056e3d3cc66258e4bce7813bccdb9d8d6e185f0d348283c424c84
4
+ data.tar.gz: cdc62d67befebedfc0c4c4b60c777271d0cacf419b363568f7fd1a923715047d
5
5
  SHA512:
6
- metadata.gz: b18dbd0f05991d21b51b92845d02bb6f14577d80b8a29202f44da5cac7920cff2f5d33e7c2581d9ed9658561138be95c071e551fff6680b27cbd60ed85370a01
7
- data.tar.gz: fb7cfff2961cfb02a2c4a8c4ddab1c81e90402af6e388333c8b3ba6a861334a8f384feee2879e3e22c706a0b9469665d74987a82ec2f89e65ca52dfc0cb75efc
6
+ metadata.gz: 80480cae33a1c20da25abdeca2e2162468b8a0bf0effded2d7ae3cf612cc8fd7aa96ef9149306e9b23e25101ad65894d9d9654e7a48125534b770d0dfd6978ff
7
+ data.tar.gz: 6d4ba1cfee75fa49a0c1cdb940437e47fdf6e02326ade8972c98ebbbe4f23274a2fdcd668474c5f7efaf68e4488641284ba9f21a78a403613b14cbcdcfc88bd8
@@ -29,14 +29,12 @@ jobs:
29
29
 
30
30
  matrix:
31
31
  ruby:
32
- - ruby:2.3
33
32
  - ruby:2.4
34
33
  - ruby:2.5
35
34
  - ruby:2.6
36
35
  - ruby:2.7
37
36
  - rubylang/ruby:master-nightly-bionic
38
37
  gemfile:
39
- - faraday_0.gemfile
40
38
  - faraday_1.gemfile
41
39
  include:
42
40
  - ruby: rubylang/ruby:master-nightly-bionic
@@ -1,5 +1,17 @@
1
1
  ## Unreleased
2
- [full changelog](http://github.com/sue445/pixela/compare/v1.5.0...master)
2
+ [full changelog](http://github.com/sue445/pixela/compare/v2.0.0...master)
3
+
4
+ ## v2.0.0
5
+ [full changelog](http://github.com/sue445/pixela/compare/v1.5.0...v2.0.0)
6
+
7
+ ### :warning: Breaking changes :warning:
8
+ * Remove Channel and Notification
9
+ * https://github.com/sue445/pixela/pull/75
10
+ * https://github.com/a-know/Pixela/releases/tag/v1.19.0
11
+ * Drop support for faraday v0.x
12
+ * https://github.com/sue445/pixela/pull/77
13
+ * Drop support for ruby 2.3
14
+ * https://github.com/sue445/pixela/pull/78
3
15
 
4
16
  ## v1.5.0
5
17
  [full changelog](http://github.com/sue445/pixela/compare/v1.4.2...v1.5.0)
@@ -5,11 +5,9 @@ require "faraday_curl"
5
5
  require "date"
6
6
 
7
7
  module Pixela
8
- autoload :Channel, "pixela/channel"
9
8
  autoload :Client, "pixela/client"
10
9
  autoload :Configuration, "pixela/configuration"
11
10
  autoload :Graph, "pixela/graph"
12
- autoload :Notification, "pixela/notification"
13
11
  autoload :Pixel, "pixela/pixel"
14
12
  autoload :Response, "pixela/response"
15
13
  autoload :Webhook, "pixela/webhook"
@@ -1,15 +1,11 @@
1
1
  module Pixela
2
2
  class Client
3
- autoload :ChannelMethods, "pixela/client/channel_methods"
4
3
  autoload :GraphMethods, "pixela/client/graph_methods"
5
- autoload :NotificationMethods, "pixela/client/notificaton_methods"
6
4
  autoload :PixelMethods, "pixela/client/pixel_methods"
7
5
  autoload :UserMethods, "pixela/client/user_methods"
8
6
  autoload :WebhookMethods, "pixela/client/webhook_methods"
9
7
 
10
- include ChannelMethods
11
8
  include GraphMethods
12
- include NotificationMethods
13
9
  include PixelMethods
14
10
  include UserMethods
15
11
  include WebhookMethods
@@ -47,13 +43,6 @@ module Pixela
47
43
  Webhook.new(client: self, webhook_hash: webhook_hash)
48
44
  end
49
45
 
50
- # @param channel_id [String]
51
- #
52
- # @return [Pixela::Channel]
53
- def channel(channel_id)
54
- Channel.new(client: self, channel_id: channel_id)
55
- end
56
-
57
46
  private
58
47
 
59
48
  # @!attribute [r] token
@@ -81,7 +70,7 @@ module Pixela
81
70
 
82
71
  def with_error_handling
83
72
  yield
84
- rescue *faraday_errors => error
73
+ rescue Faraday::ClientError, Faraday::ServerError => error
85
74
  begin
86
75
  body = JSON.parse(error.response[:body])
87
76
  raise PixelaError, body["message"]
@@ -90,14 +79,6 @@ module Pixela
90
79
  end
91
80
  end
92
81
 
93
- def faraday_errors
94
- if Gem::Version.create(Faraday::VERSION) >= Gem::Version.create("1.0.0")
95
- return [Faraday::ClientError, Faraday::ServerError]
96
- end
97
-
98
- [Faraday::Error::ClientError]
99
- end
100
-
101
82
  def default_headers
102
83
  {
103
84
  "User-Agent" => "Pixela v#{Pixela::VERSION} (https://github.com/sue445/pixela)",
@@ -118,10 +99,5 @@ module Pixela
118
99
 
119
100
  date.strftime("%Y%m%d")
120
101
  end
121
-
122
- def compact_hash(hash)
123
- # NOTE: Hash#compact is available since MRI 2.4+
124
- hash.reject { |_, v| v.nil? }
125
- end
126
102
  end
127
103
  end
@@ -33,7 +33,7 @@ module Pixela::Client::GraphMethods
33
33
  }
34
34
 
35
35
  with_error_handling do
36
- connection.post("users/#{username}/graphs", compact_hash(params)).body
36
+ connection.post("users/#{username}/graphs", params.compact).body
37
37
  end
38
38
  end
39
39
 
@@ -126,7 +126,7 @@ module Pixela::Client::GraphMethods
126
126
  end
127
127
 
128
128
  with_error_handling do
129
- connection.put("users/#{username}/graphs/#{graph_id}", compact_hash(params)).body
129
+ connection.put("users/#{username}/graphs/#{graph_id}", params.compact).body
130
130
  end
131
131
  end
132
132
 
@@ -170,7 +170,7 @@ module Pixela::Client::GraphMethods
170
170
 
171
171
  res =
172
172
  with_error_handling do
173
- connection.get("users/#{username}/graphs/#{graph_id}/pixels", compact_hash(params)).body
173
+ connection.get("users/#{username}/graphs/#{graph_id}/pixels", params.compact).body
174
174
  end
175
175
 
176
176
  res.pixels.map { |ymd| Date.parse(ymd) }
@@ -22,7 +22,7 @@ module Pixela::Client::PixelMethods
22
22
  }
23
23
 
24
24
  with_error_handling do
25
- connection.post("users/#{username}/graphs/#{graph_id}", compact_hash(params)).body
25
+ connection.post("users/#{username}/graphs/#{graph_id}", params.compact).body
26
26
  end
27
27
  end
28
28
 
@@ -80,7 +80,7 @@ module Pixela::Client::PixelMethods
80
80
  }
81
81
 
82
82
  with_error_handling do
83
- connection.put("users/#{username}/graphs/#{graph_id}/#{to_ymd(date)}", compact_hash(params)).body
83
+ connection.put("users/#{username}/graphs/#{graph_id}/#{to_ymd(date)}", params.compact).body
84
84
  end
85
85
  end
86
86
 
@@ -22,13 +22,6 @@ module Pixela
22
22
  Pixel.new(client: client, graph_id: graph_id, date: date)
23
23
  end
24
24
 
25
- # @param notification_id [String]
26
- #
27
- # @return [Pixela::Notification]
28
- def notification(notification_id)
29
- Notification.new(client: client, graph_id: graph_id, notification_id: notification_id)
30
- end
31
-
32
25
  # Create a new pixelation graph definition.
33
26
  #
34
27
  # @param name [String]
@@ -1,3 +1,3 @@
1
1
  module Pixela
2
- VERSION = "1.5.0"
2
+ VERSION = "2.0.0"
3
3
  end
@@ -34,9 +34,9 @@ Gem::Specification.new do |spec|
34
34
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
35
35
  spec.require_paths = ["lib"]
36
36
 
37
- spec.required_ruby_version = ">= 2.3.0"
37
+ spec.required_ruby_version = ">= 2.4.0"
38
38
 
39
- spec.add_dependency "faraday"
39
+ spec.add_dependency "faraday", ">= 1.0.0"
40
40
  spec.add_dependency "faraday_curl"
41
41
  spec.add_dependency "faraday_middleware"
42
42
  spec.add_dependency "hashie"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pixela
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - sue445
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-06 00:00:00.000000000 Z
11
+ date: 2020-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 1.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 1.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: faraday_curl
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -240,20 +240,15 @@ files:
240
240
  - Rakefile
241
241
  - bin/console
242
242
  - bin/setup
243
- - gemfiles/faraday_0.gemfile
244
243
  - gemfiles/faraday_1.gemfile
245
244
  - lib/pixela.rb
246
- - lib/pixela/channel.rb
247
245
  - lib/pixela/client.rb
248
- - lib/pixela/client/channel_methods.rb
249
246
  - lib/pixela/client/graph_methods.rb
250
- - lib/pixela/client/notificaton_methods.rb
251
247
  - lib/pixela/client/pixel_methods.rb
252
248
  - lib/pixela/client/user_methods.rb
253
249
  - lib/pixela/client/webhook_methods.rb
254
250
  - lib/pixela/configuration.rb
255
251
  - lib/pixela/graph.rb
256
- - lib/pixela/notification.rb
257
252
  - lib/pixela/pixel.rb
258
253
  - lib/pixela/response.rb
259
254
  - lib/pixela/version.rb
@@ -266,7 +261,7 @@ metadata:
266
261
  homepage_uri: https://github.com/sue445/pixela
267
262
  source_code_uri: https://github.com/sue445/pixela
268
263
  changelog_uri: https://github.com/sue445/pixela/blob/master/CHANGELOG.md
269
- post_install_message:
264
+ post_install_message:
270
265
  rdoc_options: []
271
266
  require_paths:
272
267
  - lib
@@ -274,7 +269,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
274
269
  requirements:
275
270
  - - ">="
276
271
  - !ruby/object:Gem::Version
277
- version: 2.3.0
272
+ version: 2.4.0
278
273
  required_rubygems_version: !ruby/object:Gem::Requirement
279
274
  requirements:
280
275
  - - ">="
@@ -282,7 +277,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
282
277
  version: '0'
283
278
  requirements: []
284
279
  rubygems_version: 3.1.2
285
- signing_key:
280
+ signing_key:
286
281
  specification_version: 4
287
282
  summary: Pixela API client for Ruby
288
283
  test_files: []
@@ -1,8 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
-
5
- # Specify your gem's dependencies in pixela.gemspec
6
- gemspec path: "../"
7
-
8
- gem "faraday", "~> 0.17"
@@ -1,106 +0,0 @@
1
- module Pixela
2
- class Channel
3
- # @!attribute [r] client
4
- # @return [Pixela::Client]
5
- attr_reader :client
6
-
7
- # @!attribute [r] id
8
- # @return [String]
9
- attr_reader :channel_id
10
-
11
- # @param client [Pixela::Client]
12
- # @param graph_id [String]
13
- def initialize(client:, channel_id:)
14
- @client = client
15
- @channel_id = channel_id
16
- end
17
-
18
- # Create a new channel settings for notification.
19
- #
20
- # @param name [String]
21
- # @param type [String]
22
- # @param detail [Hash]
23
- #
24
- # @return [Pixela::Response]
25
- #
26
- # @raise [Pixela::PixelaError] API is failed
27
- #
28
- # @see https://docs.pixe.la/entry/post-channel
29
- #
30
- # @example
31
- # client.channel("my-channel").create(name: "My slack channel", type: "slack", detail: {url: "https://hooks.slack.com/services/T035DA4QD/B06LMAV40/xxxx", userName: "Pixela Notification", channelName: "pixela-notify"})
32
- def create(name:, type:, detail:)
33
- client.create_channel(channel_id: channel_id, name: name, type: type, detail: detail)
34
- end
35
-
36
- # Create a new channel settings for slack notification.
37
- #
38
- # @param name [String]
39
- # @param url [String]
40
- # @param user_name [String]
41
- # @param channel_name [String]
42
- #
43
- # @return [Pixela::Response]
44
- #
45
- # @raise [Pixela::PixelaError] API is failed
46
- #
47
- # @see https://docs.pixe.la/entry/post-channel
48
- #
49
- # @example
50
- # client.channel("my-channel").create_with_slack(name: "My slack channel", url: "https://hooks.slack.com/services/T035DA4QD/B06LMAV40/xxxx", user_name: "Pixela Notification", channel_name: "pixela-notify")
51
- def create_with_slack(name:, url:, user_name:, channel_name:)
52
- client.create_slack_channel(channel_id: channel_id, name: name, url: url, user_name: user_name, channel_name: channel_name)
53
- end
54
-
55
- # Update predefined channel settings.
56
- #
57
- # @param name [String]
58
- # @param type [String]
59
- # @param detail [Hash]
60
- #
61
- # @return [Pixela::Response]
62
- #
63
- # @raise [Pixela::PixelaError] API is failed
64
- #
65
- # @see https://docs.pixe.la/entry/put-channel
66
- #
67
- # @example
68
- # client.channel("my-channel").update(name: "My slack channel", type: "slack", detail: {url: "https://hooks.slack.com/services/T035DA4QD/B06LMAV40/xxxx", userName: "Pixela Notification", channelName: "pixela-notify"})
69
- def update(name:, type:, detail:)
70
- client.update_channel(channel_id: channel_id, name: name, type: type, detail: detail)
71
- end
72
-
73
- # Update predefined slack channel settings.
74
- #
75
- # @param name [String]
76
- # @param url [String]
77
- # @param user_name [String]
78
- # @param channel_name [String]
79
- #
80
- # @return [Pixela::Response]
81
- #
82
- # @raise [Pixela::PixelaError] API is failed
83
- #
84
- # @see https://docs.pixe.la/entry/post-channel
85
- #
86
- # @example
87
- # client.channel("my-channel").update_with_slack(name: "My slack channel", url: "https://hooks.slack.com/services/T035DA4QD/B06LMAV40/xxxx", user_name: "Pixela Notification", channel_name: "pixela-notify")
88
- def update_with_slack(name:, url:, user_name:, channel_name:)
89
- client.update_slack_channel(channel_id: channel_id, name: name, url: url, user_name: user_name, channel_name: channel_name)
90
- end
91
-
92
- # Delete predefined channel settings.
93
- #
94
- # @see https://docs.pixe.la/entry/delete-channel
95
- #
96
- # @return [Pixela::Response]
97
- #
98
- # @raise [Pixela::PixelaError] API is failed
99
- #
100
- # @example
101
- # client.channel("my-channel").delete
102
- def delete
103
- client.delete_channel(channel_id: channel_id)
104
- end
105
- end
106
- end
@@ -1,148 +0,0 @@
1
- module Pixela::Client::ChannelMethods
2
- # Create a new channel settings for notification.
3
- #
4
- # @param channel_id [String]
5
- # @param name [String]
6
- # @param type [String]
7
- # @param detail [Hash]
8
- #
9
- # @return [Pixela::Response]
10
- #
11
- # @raise [Pixela::PixelaError] API is failed
12
- #
13
- # @see https://docs.pixe.la/entry/post-channel
14
- #
15
- # @example
16
- # client.create_channel(channel_id: "my-channel", name: "My slack channel", type: "slack", detail: {url: "https://hooks.slack.com/services/T035DA4QD/B06LMAV40/xxxx", userName: "Pixela Notification", channelName: "pixela-notify"})
17
- def create_channel(channel_id:, name:, type:, detail:)
18
- params = {
19
- id: channel_id,
20
- name: name,
21
- type: type,
22
- detail: detail,
23
- }
24
-
25
- with_error_handling do
26
- connection.post("users/#{username}/channels", compact_hash(params)).body
27
- end
28
- end
29
-
30
- # Create a new channel settings for slack notification.
31
- #
32
- # @param channel_id [String]
33
- # @param name [String]
34
- # @param url [String]
35
- # @param user_name [String]
36
- # @param channel_name [String]
37
- #
38
- # @return [Pixela::Response]
39
- #
40
- # @raise [Pixela::PixelaError] API is failed
41
- #
42
- # @see https://docs.pixe.la/entry/post-channel
43
- #
44
- # @example
45
- # client.create_slack_channel(channel_id: "my-channel", name: "My slack channel", url: "https://hooks.slack.com/services/T035DA4QD/B06LMAV40/xxxx", user_name: "Pixela Notification", channel_name: "pixela-notify")
46
- def create_slack_channel(channel_id:, name:, url:, user_name:, channel_name:)
47
- create_channel(
48
- channel_id: channel_id,
49
- name: name,
50
- type: "slack",
51
- detail: {
52
- url: url,
53
- userName: user_name,
54
- channelName: channel_name,
55
- },
56
- )
57
- end
58
-
59
- # Get all predefined channels.
60
- #
61
- # @see https://docs.pixe.la/entry/get-channels
62
- #
63
- # @return [Array<Pixela::Response>]
64
- #
65
- # @raise [Pixela::PixelaError] API is failed
66
- #
67
- # @example
68
- # client.get_channels
69
- def get_channels
70
- with_error_handling do
71
- connection.get("users/#{username}/channels").body.channels
72
- end
73
- end
74
-
75
- # Update predefined channel settings.
76
- #
77
- # @param channel_id [String]
78
- # @param name [String]
79
- # @param type [String]
80
- # @param detail [Hash]
81
- #
82
- # @return [Pixela::Response]
83
- #
84
- # @raise [Pixela::PixelaError] API is failed
85
- #
86
- # @see https://docs.pixe.la/entry/put-channel
87
- #
88
- # @example
89
- # client.update_channel(channel_id: "my-channel", name: "My slack channel", type: "slack", detail: {url: "https://hooks.slack.com/services/T035DA4QD/B06LMAV40/xxxx", userName: "Pixela Notification", channelName: "pixela-notify"})
90
- def update_channel(channel_id:, name:, type:, detail:)
91
- params = {
92
- name: name,
93
- type: type,
94
- detail: detail,
95
- }
96
-
97
- with_error_handling do
98
- connection.put("users/#{username}/channels/#{channel_id}", compact_hash(params)).body
99
- end
100
- end
101
-
102
- # Update predefined slack channel settings.
103
- #
104
- # @param channel_id [String]
105
- # @param name [String]
106
- # @param url [String]
107
- # @param user_name [String]
108
- # @param channel_name [String]
109
- #
110
- # @return [Pixela::Response]
111
- #
112
- # @raise [Pixela::PixelaError] API is failed
113
- #
114
- # @see https://docs.pixe.la/entry/post-channel
115
- #
116
- # @example
117
- # client.update_slack_channel(channel_id: "my-channel", name: "My slack channel", url: "https://hooks.slack.com/services/T035DA4QD/B06LMAV40/xxxx", user_name: "Pixela Notification", channel_name: "pixela-notify")
118
- def update_slack_channel(channel_id:, name:, url:, user_name:, channel_name:)
119
- update_channel(
120
- channel_id: channel_id,
121
- name: name,
122
- type: "slack",
123
- detail: {
124
- url: url,
125
- userName: user_name,
126
- channelName: channel_name,
127
- },
128
- )
129
- end
130
-
131
- # Delete predefined channel settings.
132
- #
133
- # @param channel_id [String]
134
- #
135
- # @see https://docs.pixe.la/entry/delete-channel
136
- #
137
- # @return [Pixela::Response]
138
- #
139
- # @raise [Pixela::PixelaError] API is failed
140
- #
141
- # @example
142
- # client.delete_channel(channel_id: "my-channel")
143
- def delete_channel(channel_id:)
144
- with_error_handling do
145
- connection.delete("users/#{username}/channels/#{channel_id}").body
146
- end
147
- end
148
- end
@@ -1,105 +0,0 @@
1
- module Pixela::Client::NotificationMethods
2
- # Create a notification rule.
3
- #
4
- # @param graph_id [String]
5
- # @param notification_id [String]
6
- # @param name [String]
7
- # @param target [String]
8
- # @param condition [String]
9
- # @param threshold [String]
10
- # @param remind_by [String]
11
- # @param channel_id [String]
12
- #
13
- # @return [Pixela::Response]
14
- #
15
- # @raise [Pixela::PixelaError] API is failed
16
- #
17
- # @see https://docs.pixe.la/entry/post-notification
18
- #
19
- # @example
20
- # client.create_notification(graph_id: "test-graph", notification_id: "my-notification-rule", name: "my notification rule", target: "quantity", condition: ">", threshold: "5", remind_by: "21", channel_id: "my-channel")
21
- def create_notification(graph_id:, notification_id:, name:, target:, condition:, threshold:, remind_by: nil, channel_id:)
22
- params = {
23
- id: notification_id,
24
- name: name,
25
- target: target,
26
- condition: condition,
27
- threshold: threshold,
28
- remindBy: remind_by,
29
- channelID: channel_id,
30
- }
31
-
32
- with_error_handling do
33
- connection.post("users/#{username}/graphs/#{graph_id}/notifications", compact_hash(params)).body
34
- end
35
- end
36
-
37
- # Get all predefined notifications.
38
- #
39
- # @param graph_id [String]
40
- #
41
- # @return [Array<Pixela::Response>]
42
- #
43
- # @raise [Pixela::PixelaError] API is failed
44
- #
45
- # @see https://docs.pixe.la/entry/get-notifications
46
- #
47
- # @example
48
- # client.get_notifications(graph_id: "test-graph")
49
- def get_notifications(graph_id:)
50
- with_error_handling do
51
- connection.get("users/#{username}/graphs/#{graph_id}/notifications").body.notifications
52
- end
53
- end
54
-
55
- # Update predefined notification rule.
56
- #
57
- # @param graph_id [String]
58
- # @param notification_id [String]
59
- # @param name [String]
60
- # @param target [String]
61
- # @param condition [String]
62
- # @param threshold [String]
63
- # @param channel_id [String]
64
- #
65
- # @return [Pixela::Response]
66
- #
67
- # @raise [Pixela::PixelaError] API is failed
68
- #
69
- # @see https://docs.pixe.la/entry/put-notification
70
- #
71
- # @example
72
- # client.update_notification(graph_id: "test-graph", notification_id: "my-notification-rule", name: "my notification rule", target: "quantity", condition: ">", threshold: "5", channel_id: "my-channel")
73
- def update_notification(graph_id:, notification_id:, name:, target:, condition:, threshold:, channel_id:)
74
- params = {
75
- name: name,
76
- target: target,
77
- condition: condition,
78
- threshold: threshold,
79
- channelID: channel_id,
80
- }
81
-
82
- with_error_handling do
83
- connection.put("users/#{username}/graphs/#{graph_id}/notifications/#{notification_id}", compact_hash(params)).body
84
- end
85
- end
86
-
87
- # Delete predefined notification settings.
88
- #
89
- # @param graph_id [String]
90
- # @param notification_id [String]
91
- #
92
- # @return [Pixela::Response]
93
- #
94
- # @raise [Pixela::PixelaError] API is failed
95
- #
96
- # @see https://docs.pixe.la/entry/delete-notification
97
- #
98
- # @example
99
- # client.delete_notification(graph_id: "test-graph", notification_id: "my-notification-rule")
100
- def delete_notification(graph_id:, notification_id:)
101
- with_error_handling do
102
- connection.delete("users/#{username}/graphs/#{graph_id}/notifications/#{notification_id}").body
103
- end
104
- end
105
- end
@@ -1,79 +0,0 @@
1
- module Pixela
2
- class Notification
3
- # @!attribute [r] client
4
- # @return [Pixela::Client]
5
- attr_reader :client
6
-
7
- # @!attribute [r] graph_id
8
- # @return [String]
9
- attr_reader :graph_id
10
-
11
- # @!attribute [r] notification_id
12
- # @return [String]
13
- attr_reader :notification_id
14
-
15
- # @param client [Pixela::Client]
16
- # @param graph_id [String]
17
- # @param notification_id [String]
18
- def initialize(client:, graph_id:, notification_id:)
19
- @client = client
20
- @graph_id = graph_id
21
- @notification_id = notification_id
22
- end
23
-
24
- # Create a notification rule.
25
- #
26
- # @param name [String]
27
- # @param target [String]
28
- # @param condition [String]
29
- # @param threshold [String]
30
- # @param remind_by [String]
31
- # @param channel_id [String]
32
- #
33
- # @return [Pixela::Response]
34
- #
35
- # @raise [Pixela::PixelaError] API is failed
36
- #
37
- # @see https://docs.pixe.la/entry/post-notification
38
- #
39
- # @example
40
- # client.graph("test-graph").notification("my-notification-rule").create(name: "my notification rule", target: "quantity", condition: ">", threshold: "5", remind_by: "21", channel_id: "my-channel")
41
- def create(name:, target:, condition:, threshold:, remind_by: nil, channel_id:)
42
- client.create_notification(graph_id: graph_id, notification_id: notification_id, name: name, target: target, condition: condition, threshold: threshold, remind_by: remind_by, channel_id: channel_id)
43
- end
44
-
45
- # Update predefined notification rule.
46
- #
47
- # @param name [String]
48
- # @param target [String]
49
- # @param condition [String]
50
- # @param threshold [String]
51
- # @param channel_id [String]
52
- #
53
- # @return [Pixela::Response]
54
- #
55
- # @raise [Pixela::PixelaError] API is failed
56
- #
57
- # @see https://docs.pixe.la/entry/put-notification
58
- #
59
- # @example
60
- # client.graph("test-graph").notification("my-notification-rule").update(name: "my notification rule", target: "quantity", condition: ">", threshold: "5", channel_id: "my-channel")
61
- def update(name:, target:, condition:, threshold:, channel_id:)
62
- client.update_notification(graph_id: graph_id, notification_id: notification_id, name: name, target: target, condition: condition, threshold: threshold, channel_id: channel_id)
63
- end
64
-
65
- # Delete predefined notification settings.
66
- #
67
- # @return [Pixela::Response]
68
- #
69
- # @raise [Pixela::PixelaError] API is failed
70
- #
71
- # @see https://docs.pixe.la/entry/delete-notification
72
- #
73
- # @example
74
- # client.graph("test-graph").notification("my-notification-rule").delete
75
- def delete
76
- client.delete_notification(graph_id: graph_id, notification_id: notification_id)
77
- end
78
- end
79
- end