pixela 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -1
- data/lib/pixela.rb +1 -0
- data/lib/pixela/client.rb +12 -3
- data/lib/pixela/client/webhook_methods.rb +77 -0
- data/lib/pixela/version.rb +1 -1
- data/lib/pixela/webhook.rb +46 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0bdf58874af8d488cace583d00efc11a2bda3e095fe5ee4b9f4afaf83bbaab00
|
4
|
+
data.tar.gz: 44b273ab85f3761f72619b839785d95aa6b8d2b8945abef19ff2cdde24d887fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: adebc2de07fd39ada466ccf27edbbaed2ae47b5ec16b984265a5ffc91e2280a08807dfd0a279790a4a29a5c63c04598d0e1b5c714f69bbb8eafb80fbb32718e7
|
7
|
+
data.tar.gz: 8c487b204b5e8a2d0417bc210c4c21a2f8812b6ff1e72159118b470464bbe8b4f409a1f85f60df0916945faba9f8b5dbd9cd9fa732c3380a20fa0f48093a540c
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
## Unreleased
|
2
|
-
[full changelog](http://github.com/sue445/pixela/compare/v0.
|
2
|
+
[full changelog](http://github.com/sue445/pixela/compare/v0.4.0...master)
|
3
|
+
|
4
|
+
## v0.4.0
|
5
|
+
[full changelog](http://github.com/sue445/pixela/compare/v0.3.0...v0.4.0)
|
6
|
+
|
7
|
+
* Support webhook API
|
8
|
+
* https://github.com/sue445/pixela/issues/23
|
9
|
+
* https://github.com/sue445/pixela/pull/24
|
3
10
|
|
4
11
|
## v0.3.0
|
5
12
|
[full changelog](http://github.com/sue445/pixela/compare/v0.2.0...v0.3.0)
|
data/lib/pixela.rb
CHANGED
data/lib/pixela/client.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
module Pixela
|
2
2
|
class Client
|
3
|
-
autoload :GraphMethods,
|
4
|
-
autoload :PixelMethods,
|
5
|
-
autoload :UserMethods,
|
3
|
+
autoload :GraphMethods, "pixela/client/graph_methods"
|
4
|
+
autoload :PixelMethods, "pixela/client/pixel_methods"
|
5
|
+
autoload :UserMethods, "pixela/client/user_methods"
|
6
|
+
autoload :WebhookMethods, "pixela/client/webhook_methods"
|
6
7
|
|
7
8
|
include GraphMethods
|
8
9
|
include PixelMethods
|
9
10
|
include UserMethods
|
11
|
+
include WebhookMethods
|
10
12
|
|
11
13
|
API_ENDPOINT = "https://pixe.la/v1"
|
12
14
|
|
@@ -34,6 +36,13 @@ module Pixela
|
|
34
36
|
Graph.new(client: self, graph_id: graph_id)
|
35
37
|
end
|
36
38
|
|
39
|
+
# @param webhook_hash [String]
|
40
|
+
#
|
41
|
+
# @return [Pixela::Webhook]
|
42
|
+
def webhook(webhook_hash)
|
43
|
+
Webhook.new(client: self, webhook_hash: webhook_hash)
|
44
|
+
end
|
45
|
+
|
37
46
|
private
|
38
47
|
|
39
48
|
# @!attribute [r] token
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module Pixela::Client::WebhookMethods
|
2
|
+
# Create a new Webhook.
|
3
|
+
#
|
4
|
+
# @param graph_id [String]
|
5
|
+
# @param type [String]
|
6
|
+
#
|
7
|
+
# @return [Hashie::Mash]
|
8
|
+
#
|
9
|
+
# @raise [Pixela::PixelaError] API is failed
|
10
|
+
#
|
11
|
+
# @see https://pixe.la/#api-webhook
|
12
|
+
#
|
13
|
+
# @example
|
14
|
+
# client.create_webhook(graph_id: "test-graph", type: "increment")
|
15
|
+
def create_webhook(graph_id:, type:)
|
16
|
+
params = {
|
17
|
+
graphID: graph_id,
|
18
|
+
type: type,
|
19
|
+
}
|
20
|
+
|
21
|
+
with_error_handling do
|
22
|
+
connection.post("users/#{username}/webhooks", params, user_token_headers).body
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# Get all predefined webhooks definitions.
|
27
|
+
#
|
28
|
+
# @return [Array<Hashie::Mash>]
|
29
|
+
#
|
30
|
+
# @raise [Pixela::PixelaError] API is failed
|
31
|
+
#
|
32
|
+
# @see https://pixe.la/#api-webhook
|
33
|
+
#
|
34
|
+
# @example
|
35
|
+
# client.get_webhooks
|
36
|
+
def get_webhooks
|
37
|
+
with_error_handling do
|
38
|
+
connection.get("users/#{username}/webhooks", nil, user_token_headers).body.webhooks
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# Invoke the webhook registered in advance.
|
43
|
+
#
|
44
|
+
# @param webhook_hash [String]
|
45
|
+
#
|
46
|
+
# @return [Hashie::Mash]
|
47
|
+
#
|
48
|
+
# @raise [Pixela::PixelaError] API is failed
|
49
|
+
#
|
50
|
+
# @see https://pixe.la/#api-webhook
|
51
|
+
#
|
52
|
+
# @example
|
53
|
+
# client.invoke_webhook(webhook_hash: "<webhookHash>")
|
54
|
+
def invoke_webhook(webhook_hash:)
|
55
|
+
with_error_handling do
|
56
|
+
connection.post("users/#{username}/webhooks/#{webhook_hash}", nil, default_headers).body
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# Delete the registered Webhook.
|
61
|
+
#
|
62
|
+
# @param webhook_hash [String]
|
63
|
+
#
|
64
|
+
# @return [Hashie::Mash]
|
65
|
+
#
|
66
|
+
# @raise [Pixela::PixelaError] API is failed
|
67
|
+
#
|
68
|
+
# @see https://pixe.la/#api-webhook
|
69
|
+
#
|
70
|
+
# @example
|
71
|
+
# client.delete_webhook(webhook_hash: "<webhookHash>")
|
72
|
+
def delete_webhook(webhook_hash:)
|
73
|
+
with_error_handling do
|
74
|
+
connection.delete("users/#{username}/webhooks/#{webhook_hash}", nil, user_token_headers).body
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
data/lib/pixela/version.rb
CHANGED
@@ -0,0 +1,46 @@
|
|
1
|
+
module Pixela
|
2
|
+
class Webhook
|
3
|
+
# @!attribute [r] client
|
4
|
+
# @return [Pixela::Client]
|
5
|
+
attr_reader :client
|
6
|
+
|
7
|
+
# @!attribute [r] webhook_hash
|
8
|
+
# @return [String]
|
9
|
+
attr_reader :webhook_hash
|
10
|
+
|
11
|
+
# @param client [Pixela::Client]
|
12
|
+
# @param webhook_hash [String]
|
13
|
+
def initialize(client:, webhook_hash:)
|
14
|
+
@client = client
|
15
|
+
@webhook_hash = webhook_hash
|
16
|
+
end
|
17
|
+
|
18
|
+
# Invoke the webhook registered in advance.
|
19
|
+
#
|
20
|
+
# @return [Hashie::Mash]
|
21
|
+
#
|
22
|
+
# @raise [Pixela::PixelaError] API is failed
|
23
|
+
#
|
24
|
+
# @see https://pixe.la/#api-webhook
|
25
|
+
#
|
26
|
+
# @example
|
27
|
+
# client.webhook("<webhookHash>").invoke
|
28
|
+
def invoke
|
29
|
+
client.invoke_webhook(webhook_hash: webhook_hash)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Delete the registered Webhook.
|
33
|
+
#
|
34
|
+
# @return [Hashie::Mash]
|
35
|
+
#
|
36
|
+
# @raise [Pixela::PixelaError] API is failed
|
37
|
+
#
|
38
|
+
# @see https://pixe.la/#api-webhook
|
39
|
+
#
|
40
|
+
# @example
|
41
|
+
# client.webhook("<webhookHash>").delete
|
42
|
+
def delete
|
43
|
+
client.delete_webhook(webhook_hash: webhook_hash)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
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: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sue445
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -245,10 +245,12 @@ files:
|
|
245
245
|
- lib/pixela/client/graph_methods.rb
|
246
246
|
- lib/pixela/client/pixel_methods.rb
|
247
247
|
- lib/pixela/client/user_methods.rb
|
248
|
+
- lib/pixela/client/webhook_methods.rb
|
248
249
|
- lib/pixela/configuration.rb
|
249
250
|
- lib/pixela/graph.rb
|
250
251
|
- lib/pixela/pixel.rb
|
251
252
|
- lib/pixela/version.rb
|
253
|
+
- lib/pixela/webhook.rb
|
252
254
|
- pixela.gemspec
|
253
255
|
homepage: https://github.com/sue445/pixela
|
254
256
|
licenses:
|