zaikio-webhooks 0.0.5 → 0.0.10

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0284963ea43cfb186d4f911a8ae0ac18bf5f4d79ce7ed9171f16b39ab31a27b6'
4
- data.tar.gz: a428431616525d08df2219592481f335a1e79aaabf0f72ac5a9c8ac85db1b89f
3
+ metadata.gz: c1e4bb1dfafbb05d683f49875dfd21bec26c616a4e526e3e2d2c0de5cd2b1871
4
+ data.tar.gz: 198c277707f4f25d9a76c69a16f23d15b59b22bf46041748adb1f685ee9e2409
5
5
  SHA512:
6
- metadata.gz: 26bd963797a01f76f803f40dd1480fff156783423f8441a0cf6161c14955fe664cfbeda545a0d45bf1f88d31d456a9aee9f67e7493321e55fac09ca2a0b82385
7
- data.tar.gz: c98a228af1b46b23e836f7f39da6fa9c6fe08d815e129881af15e323182232a8b3f5e18612da09f140bc353e4b8b336c081da15cd192529cbf6dd135e136a221
6
+ metadata.gz: 97c1264c19fce2edd41dcc3055a7ac6f02951b7a8c2806f60bf59c40831af2d40452adf3fcbf489892cfee56523ccd39114a3135f826463332a09b354dbc7624
7
+ data.tar.gz: 6993041564dbae221625fc61fa916381d4838958fca8ece7dfea4ca8eb410e4ab06d31e4410dbfad20bd166acbab90fe56d121ae34d19ce5af1ce8b213b31e17
data/README.md CHANGED
@@ -34,13 +34,6 @@ Zaikio::Webhooks.configure do |config|
34
34
  my_other_app.shared_secret = "test-secret"
35
35
  end
36
36
  end
37
-
38
- # Perform job immediately, for all clients
39
- Zaikio::Webhooks.on "directory.revoked_access_token", RevokeAccessTokenJob,
40
- perform_now: true
41
- # Only for a specific client
42
- Zaikio::Webhooks.on "directory.machine_added", AddMachineJob,
43
- client_name: :my_app
44
37
  ```
45
38
 
46
39
  ### 3. Mount Engine
@@ -83,3 +76,38 @@ end
83
76
  Login to [Zaikio Hub](https://directory.zaikio.com/) and go to your Apps and go to Edit App and add your webhook URL e.g. `https://mydomain.de/zaikio/webhook/my_app_name`.
84
77
 
85
78
  Now you should receive all events you subscribed to.
79
+
80
+ ### 7. Usage
81
+
82
+ When everything is set up you can register events with custom jobs, using the
83
+ `Zaikio::Webhooks.on` function. This is idempotent and can be safely re-executed.
84
+
85
+ We can setup an initializer like so:
86
+
87
+ ```rb
88
+ # config/initializers/zaikio_webhooks.rb
89
+
90
+ # We need to add this special wrapper here because we're referencing autoloaded constants
91
+ # (RevokeAccessTokenJob, AddMachineJob) at boot time. For more information, see:
92
+ # https://guides.rubyonrails.org/autoloading_and_reloading_constants.html#autoloading-when-the-application-boots
93
+ Rails.application.reloader.to_prepare do
94
+ # Perform job immediately, for all clients
95
+ Zaikio::Webhooks.on "directory.revoked_access_token", RevokeAccessTokenJob,
96
+ perform_now: true
97
+ # Only for a specific client
98
+ Zaikio::Webhooks.on "directory.machine_added", AddMachineJob,
99
+ client_name: :my_app
100
+ end
101
+ ```
102
+
103
+ ## Contributing
104
+
105
+ - Make your changes and submit a pull request for them
106
+ - Make sure to update `CHANGELOG.md`
107
+
108
+ To release a new version of the gem:
109
+ - Update the version in `lib/zaikio/webhooks/version.rb`
110
+ - Update `CHANGELOG.md` to include the new version and its release date
111
+ - Commit and push your changes
112
+ - Create a [new release on GitHub](https://github.com/zaikio/zaikio-webhooks/releases/new)
113
+ - CircleCI will build the Gem package and push it Rubygems for you
@@ -30,7 +30,8 @@ module Zaikio
30
30
  end
31
31
 
32
32
  def event_params
33
- params.permit(:id, :name, :subject, :timestamp, :version, :link, :received_at, payload: {})
33
+ params.permit(:id, :client_name, :name, :subject, :timestamp,
34
+ :version, :link, :received_at, payload: {})
34
35
  end
35
36
  end
36
37
  end
@@ -1,3 +1,4 @@
1
+ require "active_support/core_ext/integer/time"
1
2
  require "zaikio/webhooks/configuration"
2
3
  require "zaikio/webhooks/event"
3
4
  require "zaikio/webhooks/event_serializer"
@@ -12,7 +12,7 @@ module Zaikio
12
12
  end
13
13
 
14
14
  def logger
15
- @logger ||= Logger.new(STDOUT)
15
+ @logger ||= Logger.new($stdout)
16
16
  end
17
17
 
18
18
  def register_client(name)
@@ -5,7 +5,8 @@ module Zaikio
5
5
  class Event
6
6
  extend Forwardable
7
7
  attr_reader :data
8
- def_delegators :data, :id, :name, :version, :payload, :link, :to_h
8
+
9
+ def_delegators :data, :id, :name, :version, :payload, :link, :client_name, :to_h
9
10
 
10
11
  def initialize(event_data)
11
12
  @data = OpenStruct.new(event_data)
@@ -1,5 +1,5 @@
1
1
  module Zaikio
2
2
  module Webhooks
3
- VERSION = "0.0.5".freeze
3
+ VERSION = "0.0.10".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,17 +1,37 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zaikio-webhooks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zaikio GmbH
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-30 00:00:00.000000000 Z
11
+ date: 2021-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rails
14
+ name: actionpack
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '6.0'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 6.0.2.2
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '6.0'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 6.0.2.2
33
+ - !ruby/object:Gem::Dependency
34
+ name: railties
15
35
  requirement: !ruby/object:Gem::Requirement
16
36
  requirements:
17
37
  - - "~>"
@@ -51,10 +71,12 @@ files:
51
71
  - lib/zaikio/webhooks/event.rb
52
72
  - lib/zaikio/webhooks/event_serializer.rb
53
73
  - lib/zaikio/webhooks/version.rb
54
- homepage: https://www.zaikio.com/
74
+ homepage: https://github.com/zaikio/zaikio-webhooks
55
75
  licenses:
56
76
  - MIT
57
- metadata: {}
77
+ metadata:
78
+ changelog_uri: https://github.com/zaikio/zaikio-webhooks/blob/main/CHANGELOG.md
79
+ source_code_uri: https://github.com/zaikio/zaikio-webhooks
58
80
  post_install_message:
59
81
  rdoc_options: []
60
82
  require_paths:
@@ -63,14 +85,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
63
85
  requirements:
64
86
  - - ">="
65
87
  - !ruby/object:Gem::Version
66
- version: '0'
88
+ version: 2.6.5
67
89
  required_rubygems_version: !ruby/object:Gem::Requirement
68
90
  requirements:
69
91
  - - ">="
70
92
  - !ruby/object:Gem::Version
71
93
  version: '0'
72
94
  requirements: []
73
- rubygems_version: 3.1.2
95
+ rubygems_version: 3.1.4
74
96
  signing_key:
75
97
  specification_version: 4
76
98
  summary: Handle incoming Zaikio loom webhooks