convoy.rb 0.1.9 → 0.3.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/README.md +64 -11
- data/convoy.gemspec +1 -1
- data/lib/convoy/api_operations/delete.rb +1 -1
- data/lib/convoy/api_operations/get.rb +1 -1
- data/lib/convoy/api_operations/list.rb +1 -1
- data/lib/convoy/api_operations/request.rb +0 -2
- data/lib/convoy/api_operations/save.rb +2 -2
- data/lib/convoy/api_resource.rb +14 -0
- data/lib/convoy/convoy_configuration.rb +2 -3
- data/lib/convoy/resources/api_key.rb +5 -5
- data/lib/convoy/resources/delivery_attempt.rb +6 -7
- data/lib/convoy/resources/endpoint.rb +12 -9
- data/lib/convoy/resources/event.rb +10 -5
- data/lib/convoy/resources/event_delivery.rb +15 -8
- data/lib/convoy/resources/{group.rb → portal_link.rb} +7 -8
- data/lib/convoy/resources/project.rb +25 -0
- data/lib/convoy/resources/source.rb +5 -5
- data/lib/convoy/resources/subscription.rb +5 -5
- data/lib/convoy/util.rb +15 -0
- data/lib/convoy/version.rb +1 -1
- data/lib/convoy/webhook.rb +92 -0
- data/lib/convoy.rb +1 -2
- metadata +11 -9
- data/lib/convoy/resources/application.rb +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d84ba6e548b79893bcad3e8deb0a86d80c591e4009f0d6a11d64011a7b918593
|
4
|
+
data.tar.gz: 2b5cf92c2939fb48e766928e86e63a0800ef99591a92a9472023a3f62d90e858
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30d0410db297a90f8a21243cf8aa477569865df8ae57af66159428f8745644f805f6900e18f0f0e022588ea2b0ee0b60ffa2bd961503ea625c21a9e791dfd14c
|
7
|
+
data.tar.gz: 939f323b06ff770b6f4b9d48a3c196fca4a4a99cc72889ae6876b1e8139497d09d2a3ede98091a4cd7b434629a1cad274d0759bf5eb68e166d62112fa5725ee0
|
data/README.md
CHANGED
@@ -1,15 +1,12 @@
|
|
1
1
|
# Convoy
|
2
|
-
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/convoy`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
2
|
+
This is the official Convoy Ruby SDK. This SDK contains methods for easily interacting with Convoy's API. Below are examples to get you started. For additional examples, please see our official documentation at (https://convoy.readme.io/reference)
|
6
3
|
|
7
4
|
## Installation
|
8
5
|
|
9
6
|
Add this line to your application's Gemfile:
|
10
7
|
|
11
8
|
```ruby
|
12
|
-
gem 'convoy'
|
9
|
+
gem 'convoy.rb'
|
13
10
|
```
|
14
11
|
|
15
12
|
And then execute:
|
@@ -18,11 +15,67 @@ And then execute:
|
|
18
15
|
|
19
16
|
Or install it yourself as:
|
20
17
|
|
21
|
-
$ gem install convoy
|
18
|
+
$ gem install convoy.rb
|
22
19
|
|
23
20
|
## Usage
|
24
21
|
|
25
|
-
|
22
|
+
### Setup Client
|
23
|
+
To configure your client, provide your `api_key` and `project_id`, see below:
|
24
|
+
```ruby
|
25
|
+
require 'convoy'
|
26
|
+
|
27
|
+
Convoy.ssl = true
|
28
|
+
Convoy.api_key = "CO.M0aBe..."
|
29
|
+
Convoy.project_id = "23b1..."
|
30
|
+
```
|
31
|
+
|
32
|
+
### Create Endpoint
|
33
|
+
An endpoint represents a target URL to receive webhook events. You should create one endpoint per user/business or whatever scope works well for you.
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
endpoint = Convoy::Endpoint.new(
|
37
|
+
data: {
|
38
|
+
"description": "Endpoint One",
|
39
|
+
"http_timeout": "1m",
|
40
|
+
"url": "https://webhook.site/73932854-a20e-4d04-a151-d5952e873abd"
|
41
|
+
}
|
42
|
+
)
|
43
|
+
|
44
|
+
endpoint_response = endpoint.save
|
45
|
+
```
|
46
|
+
|
47
|
+
### Subscribe For Events
|
48
|
+
After creating an endpoint, we need to susbcribe the endpoint to events.
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
subscription = Convoy::Subscription.new(
|
52
|
+
data: {
|
53
|
+
endpoint_id: endpoint_id,
|
54
|
+
name: 'ruby subscription'
|
55
|
+
}
|
56
|
+
)
|
57
|
+
|
58
|
+
subscription_response = subscription.save
|
59
|
+
```
|
60
|
+
|
61
|
+
### Send Event
|
62
|
+
To send an event, you'll need to pass the `uid` from the endpoint we created earlier.
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
event = Convoy::Event.new(
|
66
|
+
data: {
|
67
|
+
endpoint_id: endpoint_id,
|
68
|
+
event_type: "wallet.created",
|
69
|
+
data: {
|
70
|
+
status: "completed",
|
71
|
+
event_type: "wallet.created",
|
72
|
+
description: "transaction successful"
|
73
|
+
}
|
74
|
+
}
|
75
|
+
)
|
76
|
+
|
77
|
+
event_response = event.save
|
78
|
+
```
|
26
79
|
|
27
80
|
## Development
|
28
81
|
|
@@ -35,10 +88,10 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
35
88
|
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/convoy. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/convoy/blob/master/CODE_OF_CONDUCT.md).
|
36
89
|
|
37
90
|
|
38
|
-
##
|
91
|
+
## Credits
|
39
92
|
|
40
|
-
|
93
|
+
- [Frain](https://github.com/frain-dev)
|
41
94
|
|
42
|
-
##
|
95
|
+
## License
|
43
96
|
|
44
|
-
|
97
|
+
The MIT License (MIT). Please see [License File](LICENSE) for more information.
|
data/convoy.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.description = "Convoy ruby client to push webhook events from any ruby application."
|
11
11
|
spec.homepage = "https://getconvoy.io"
|
12
12
|
spec.license = "MIT"
|
13
|
-
spec.required_ruby_version = Gem::Requirement.new(">=
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 3.0.0")
|
14
14
|
|
15
15
|
spec.metadata["homepage_uri"] = spec.homepage
|
16
16
|
spec.metadata["source_code_uri"] = "https://github.com/frain-dev/convoy.rb"
|
@@ -12,12 +12,12 @@ module Convoy
|
|
12
12
|
|
13
13
|
def update(data = {})
|
14
14
|
@data = data unless data.empty?
|
15
|
-
send_request(
|
15
|
+
send_request(resource_uri, :put, data: @data, params: @params)
|
16
16
|
end
|
17
17
|
|
18
18
|
def save
|
19
19
|
method = @id.nil? ? :post : :put
|
20
|
-
send_request(
|
20
|
+
send_request(resource_uri, method, data: @data, params: @params)
|
21
21
|
end
|
22
22
|
|
23
23
|
def self.included(base)
|
data/lib/convoy/api_resource.rb
CHANGED
@@ -26,5 +26,19 @@ module Convoy
|
|
26
26
|
def_delegators :@data, :size, :map, :each
|
27
27
|
|
28
28
|
attr_reader :response
|
29
|
+
|
30
|
+
def initialize(**kwargs)
|
31
|
+
@params = kwargs[:params].nil? ? {} : kwargs[:params]
|
32
|
+
@query = kwargs[:query].nil? ? {} : kwargs[:query]
|
33
|
+
@data = kwargs[:data].nil? ? {} : kwargs[:data]
|
34
|
+
end
|
35
|
+
|
36
|
+
def project_base_uri
|
37
|
+
if @config.project_id.nil?
|
38
|
+
raise ArgumentError, "Project ID not supplied"
|
39
|
+
end
|
40
|
+
|
41
|
+
"#{@config.base_uri}/#{@config.path_version}/projects/#{@config.project_id}"
|
42
|
+
end
|
29
43
|
end
|
30
44
|
end
|
@@ -3,16 +3,15 @@ module Convoy
|
|
3
3
|
|
4
4
|
attr_accessor :ssl
|
5
5
|
attr_accessor :debug
|
6
|
-
attr_accessor :username
|
7
|
-
attr_accessor :password
|
8
6
|
attr_accessor :api_key
|
9
7
|
attr_accessor :base_uri
|
10
8
|
attr_accessor :path_version
|
11
9
|
attr_accessor :logger
|
12
10
|
attr_accessor :log_level
|
11
|
+
attr_accessor :project_id
|
13
12
|
|
14
13
|
def initialize
|
15
|
-
@base_uri = "https://dashboard.getconvoy.io"
|
14
|
+
@base_uri = "https://dashboard.getconvoy.io/api"
|
16
15
|
@path_version = "/v1"
|
17
16
|
@ssl = true
|
18
17
|
@debug = false
|
@@ -8,17 +8,17 @@ module Convoy
|
|
8
8
|
|
9
9
|
def initialize(id = nil, config = Convoy.config, **kwargs)
|
10
10
|
@id = id
|
11
|
-
@data = kwargs[:data].nil? ? {} : kwargs[:data]
|
12
|
-
@params = kwargs[:params].nil? ? {} : kwargs[:params]
|
13
11
|
@config = config
|
12
|
+
|
13
|
+
super(**kwargs)
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
16
|
+
def resource_uri
|
17
17
|
if @id.nil?
|
18
|
-
return "#{
|
18
|
+
return "#{project_base_uri}/security/keys"
|
19
19
|
end
|
20
20
|
|
21
|
-
"#{
|
21
|
+
"#{project_base_uri}/security/keys/#{@id}"
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -4,20 +4,19 @@ module Convoy
|
|
4
4
|
include ApiOperations::List
|
5
5
|
|
6
6
|
def initialize(eventId = nil, id = nil, config = Convoy.config, **kwargs)
|
7
|
-
@eventId = eventId
|
8
7
|
@id = id
|
9
|
-
@
|
8
|
+
@eventId = eventId
|
10
9
|
@config = config
|
10
|
+
|
11
|
+
super(**kwargs)
|
11
12
|
end
|
12
13
|
|
13
|
-
def
|
14
|
+
def resource_uri
|
14
15
|
if @id.nil?
|
15
|
-
return "#{
|
16
|
-
"/deliveryattempts"
|
16
|
+
return "#{project_base_uri}/events/#{@eventId}/deliveryattempts"
|
17
17
|
end
|
18
18
|
|
19
|
-
"#{
|
20
|
-
"/#{@id}"
|
19
|
+
"#{project_base_uri}/events/#{@eventId}/deliveryattempts/#{@id}"
|
21
20
|
end
|
22
21
|
end
|
23
22
|
end
|
@@ -6,21 +6,24 @@ module Convoy
|
|
6
6
|
include ApiOperations::List
|
7
7
|
extend ApiOperations::Create
|
8
8
|
|
9
|
-
def initialize(
|
10
|
-
@app_id = app_id
|
9
|
+
def initialize(id = nil, config = Convoy.config, **kwargs)
|
11
10
|
@id = id
|
12
|
-
@
|
13
|
-
|
14
|
-
|
11
|
+
@config = config
|
12
|
+
|
13
|
+
super(**kwargs)
|
15
14
|
end
|
16
15
|
|
17
|
-
def
|
16
|
+
def resource_uri
|
18
17
|
if @id.nil?
|
19
|
-
return "#{
|
18
|
+
return "#{project_base_uri}/endpoints"
|
20
19
|
end
|
21
20
|
|
22
|
-
"#{
|
23
|
-
|
21
|
+
"#{project_base_uri}/endpoints/#{@id}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def pause
|
25
|
+
pause_uri = "#{resource_uri}/pause"
|
26
|
+
send_request(pause_uri, :post, data: @data, params: @params)
|
24
27
|
end
|
25
28
|
end
|
26
29
|
end
|
@@ -8,17 +8,22 @@ module Convoy
|
|
8
8
|
|
9
9
|
def initialize(id = nil , config = Convoy.config, **kwargs)
|
10
10
|
@id = id
|
11
|
-
@data = kwargs[:data].nil? ? {} : kwargs[:data]
|
12
|
-
@params = kwargs[:params].nil? ? {} : kwargs[:params]
|
13
11
|
@config = config
|
12
|
+
|
13
|
+
super(**kwargs)
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
16
|
+
def resource_uri
|
17
17
|
if @id.nil?
|
18
|
-
return "#{
|
18
|
+
return "#{project_base_uri}/events"
|
19
19
|
end
|
20
20
|
|
21
|
-
"#{
|
21
|
+
"#{project_base_uri}/events/#{@id}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def fanout
|
25
|
+
fanout_uri = "#{resource_uri}/fanout"
|
26
|
+
send_request(fanout_uri, :post, data: @data, params: @params)
|
22
27
|
end
|
23
28
|
end
|
24
29
|
end
|
@@ -4,23 +4,30 @@ module Convoy
|
|
4
4
|
include ApiOperations::List
|
5
5
|
|
6
6
|
def intialize(eventId = nil, id = nil, config = Convoy.config, **kwargs)
|
7
|
-
@eventId = eventId
|
8
|
-
@params = kwargs[:params].nil? ? {} : kwargs[:params]
|
9
7
|
@id = id
|
8
|
+
@eventId = eventId
|
10
9
|
@config = config
|
10
|
+
|
11
|
+
super(**kwargs)
|
11
12
|
end
|
12
13
|
|
13
|
-
def
|
14
|
+
def resource_uri
|
14
15
|
if @id.nil?
|
15
|
-
return "#{
|
16
|
-
"/eventdelivery"
|
16
|
+
return "#{project_base_uri}/events/#{@eventId}/eventdelivery"
|
17
17
|
end
|
18
18
|
|
19
|
-
"#{
|
20
|
-
"/#{@id}"
|
19
|
+
"#{project_base_uri}/events/#{@eventId}/eventdelivery/#{@id}"
|
21
20
|
end
|
22
21
|
|
23
|
-
|
22
|
+
|
23
|
+
def retry
|
24
|
+
retry_uri = "#{resource_uri}/resend"
|
25
|
+
send_request(retry_uri, :put, data: @data, params: @params)
|
26
|
+
end
|
24
27
|
|
28
|
+
def force_retry
|
29
|
+
force_retry_uri = "#{resource_uri}/forceresend"
|
30
|
+
send_request(force_retry_uri, :post, data: @data, params: @params)
|
31
|
+
end
|
25
32
|
end
|
26
33
|
end
|
@@ -1,25 +1,24 @@
|
|
1
1
|
module Convoy
|
2
|
-
class
|
2
|
+
class PortalLink < ApiResource
|
3
3
|
include ApiOperations::Get
|
4
4
|
include ApiOperations::Save
|
5
|
-
include ApiOperations::Delete
|
6
5
|
include ApiOperations::List
|
6
|
+
include ApiOperations::Delete
|
7
7
|
extend ApiOperations::Create
|
8
8
|
|
9
9
|
def initialize(id = nil, config = Convoy.config, **kwargs)
|
10
10
|
@id = id
|
11
|
-
@data = kwargs[:data].nil? ? {} : kwargs[:data]
|
12
|
-
@params = kwargs[:params].nil? ? {} : kwargs[:params]
|
13
11
|
@config = config
|
12
|
+
|
13
|
+
super(**kwargs)
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
16
|
+
def resource_uri
|
17
17
|
if @id.nil?
|
18
|
-
return "#{
|
18
|
+
return "#{project_base_uri}/portal-links"
|
19
19
|
end
|
20
20
|
|
21
|
-
"#{
|
21
|
+
"#{project_base_uri}/portal-links/#{@id}"
|
22
22
|
end
|
23
|
-
|
24
23
|
end
|
25
24
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Convoy
|
2
|
+
class Project < ApiResource
|
3
|
+
include ApiOperations::Get
|
4
|
+
include ApiOperations::Save
|
5
|
+
include ApiOperations::Delete
|
6
|
+
include ApiOperations::List
|
7
|
+
extend ApiOperations::Create
|
8
|
+
|
9
|
+
def initialize(id = nil, config = Convoy.config, **kwargs)
|
10
|
+
@id = id
|
11
|
+
@config = config
|
12
|
+
|
13
|
+
super(**kwargs)
|
14
|
+
end
|
15
|
+
|
16
|
+
def resource_uri
|
17
|
+
if @id.nil?
|
18
|
+
return "#{@config.base_uri}/#{@config.path_version}/projects"
|
19
|
+
end
|
20
|
+
|
21
|
+
"#{@config.base_uri}/#{@config.path_version}/projects" + "/#{@id}"
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -7,17 +7,17 @@ module Convoy
|
|
7
7
|
|
8
8
|
def initialize(id = nil, config = Convoy.config, **kwargs)
|
9
9
|
@id = id
|
10
|
-
@data = kwargs[:data].nil? ? {} : kwargs[:data]
|
11
|
-
@params = kwargs[:params].nil? ? {} : kwargs[:params]
|
12
10
|
@config = config
|
11
|
+
|
12
|
+
super(**kwargs)
|
13
13
|
end
|
14
14
|
|
15
|
-
def
|
15
|
+
def resource_uri
|
16
16
|
if @id.nil?
|
17
|
-
return "#{
|
17
|
+
return "#{project_base_uri}/sources"
|
18
18
|
end
|
19
19
|
|
20
|
-
"#{
|
20
|
+
"#{project_base_uri}/sources/#{@id}"
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -7,17 +7,17 @@ module Convoy
|
|
7
7
|
|
8
8
|
def initialize(id = nil, config = Convoy.config, **kwargs)
|
9
9
|
@id = id
|
10
|
-
@data = kwargs[:data].nil? ? {} : kwargs[:data]
|
11
|
-
@params = kwargs[:params].nil? ? {} : kwargs[:params]
|
12
10
|
@config = config
|
11
|
+
|
12
|
+
super(**kwargs)
|
13
13
|
end
|
14
14
|
|
15
|
-
def
|
15
|
+
def resource_uri
|
16
16
|
if @id.nil?
|
17
|
-
return "#{
|
17
|
+
return "#{project_base_uri}/subscriptions"
|
18
18
|
end
|
19
19
|
|
20
|
-
"#{
|
20
|
+
"#{project_base_uri}/subscriptions/#{@id}"
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
data/lib/convoy/util.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
module Convoy
|
2
|
+
module Util
|
3
|
+
# Constant time string comparison to prevent timing attacks
|
4
|
+
# Code borrowed from ActiveSupport
|
5
|
+
def self.secure_compare(str_a, str_b)
|
6
|
+
return false unless str_a.bytesize == str_b.bytesize
|
7
|
+
|
8
|
+
l = str_a.unpack "C#{str_a.bytesize}"
|
9
|
+
|
10
|
+
res = 0
|
11
|
+
str_b.each_byte { |byte| res |= byte ^ l.shift }
|
12
|
+
res.zero?
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/convoy/version.rb
CHANGED
@@ -0,0 +1,92 @@
|
|
1
|
+
module Convoy
|
2
|
+
|
3
|
+
class SignatureVerificationError < StandardError
|
4
|
+
end
|
5
|
+
|
6
|
+
DEFAULT_TOLERANCE = 300
|
7
|
+
DEFAULT_ENCODING = "hex"
|
8
|
+
DEFAULT_HASH = "SHA256"
|
9
|
+
|
10
|
+
# webhook := Webhook.new(secret)
|
11
|
+
#
|
12
|
+
# With Tolerance
|
13
|
+
# webhook := Webhook.new(secret, tolerance: 500)
|
14
|
+
#
|
15
|
+
# with Encoding
|
16
|
+
# webhook = Webhook.new(secret, encoding: "base64")
|
17
|
+
#
|
18
|
+
# With Encoding and Tolerance
|
19
|
+
# webhook = Webhook.new(secret, encoding: "base64", tolerance: 900)
|
20
|
+
#
|
21
|
+
# Verify request
|
22
|
+
# webhook.verify(payload, headers)
|
23
|
+
|
24
|
+
class Webhook
|
25
|
+
def initialize(secret, encoding: DEFAULT_ENCODING, tolerance: DEFAULT_TOLERANCE, hash: DEFAULT_HASH)
|
26
|
+
@secret = secret
|
27
|
+
@encoding = encoding
|
28
|
+
@tolerance = tolerance
|
29
|
+
@hash = hash
|
30
|
+
end
|
31
|
+
|
32
|
+
def verify(payload, sig_header)
|
33
|
+
# 1. Detect Signature Type.
|
34
|
+
is_advanced = (sig_header.split(",")).length > 1
|
35
|
+
|
36
|
+
if is_advanced
|
37
|
+
verify_advanced_signature(payload, sig_header)
|
38
|
+
return
|
39
|
+
end
|
40
|
+
|
41
|
+
verify_simple_signature(payload, sig_header)
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def verify_simple_signature(payload, sig_header)
|
47
|
+
return Util.secure_compare(compute_signature(payload), sig_header)
|
48
|
+
end
|
49
|
+
|
50
|
+
def verify_advanced_signature(payload, sig_header)
|
51
|
+
timestamp_header, signatures = get_timestamp_and_signatures(sig_header)
|
52
|
+
payload = "{#{timestamp_header}},{#{payload}}"
|
53
|
+
|
54
|
+
verify_timestamp(timestamp_header)
|
55
|
+
|
56
|
+
unless signatures.any? { |s| Util.secure_compare(compute_signature(payload), s) }
|
57
|
+
raise SignatureVerificationError.new,
|
58
|
+
"No signatures found matching the expected signature for payload"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def verify_timestamp(timestamp_header)
|
63
|
+
begin
|
64
|
+
now = Integer(Time.now)
|
65
|
+
timestamp = Integer(timestamp_header)
|
66
|
+
rescue
|
67
|
+
raise SignatureVerificationError, "Could parse timestamp header"
|
68
|
+
end
|
69
|
+
|
70
|
+
if timestamp < (now - @tolerance)
|
71
|
+
raise SignatureVerificationError, "Message timestamp too old"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# return encoded string
|
76
|
+
def compute_signature(payload)
|
77
|
+
case @encoding
|
78
|
+
when "hex"
|
79
|
+
return OpenSSL::HMAC.hexdigest(@hash, @secret, payload)
|
80
|
+
when "base64"
|
81
|
+
hmac = OpenSSL::HMAC.digest(@hash, @secret, payload)
|
82
|
+
return Base64.encode64(hmac)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def get_timestamp_and_signatures(sig_header)
|
87
|
+
list_items = sig_header.split(/,\s*/).map { |i| i.split("=", 2) }
|
88
|
+
timestamp = Integer(list_items.select { |i| i[0] == "t" }[0][1])
|
89
|
+
[Time.at(timestamp), list_items[1]]
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
data/lib/convoy.rb
CHANGED
@@ -23,12 +23,11 @@ module Convoy
|
|
23
23
|
# Some of them have defaults
|
24
24
|
def_delegators :@config, :ssl, :ssl=
|
25
25
|
def_delegators :@config, :debug, :debug=
|
26
|
-
def_delegators :@config, :username, :username=
|
27
|
-
def_delegators :@config, :password, :password=
|
28
26
|
def_delegators :@config, :api_key, :api_key=
|
29
27
|
def_delegators :@config, :base_uri, :base_uri=
|
30
28
|
def_delegators :@config, :logger, :logger=
|
31
29
|
def_delegators :@config, :log_level, :log_level=
|
32
30
|
def_delegators :@config, :path_version, :path_version=
|
31
|
+
def_delegators :@config, :project_id, :project_id=
|
33
32
|
end
|
34
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: convoy.rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Subomi Oluwalana
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: zeitwerk
|
@@ -54,15 +54,17 @@ files:
|
|
54
54
|
- lib/convoy/errors.rb
|
55
55
|
- lib/convoy/instrumentation.rb
|
56
56
|
- lib/convoy/resources/api_key.rb
|
57
|
-
- lib/convoy/resources/application.rb
|
58
57
|
- lib/convoy/resources/delivery_attempt.rb
|
59
58
|
- lib/convoy/resources/endpoint.rb
|
60
59
|
- lib/convoy/resources/event.rb
|
61
60
|
- lib/convoy/resources/event_delivery.rb
|
62
|
-
- lib/convoy/resources/
|
61
|
+
- lib/convoy/resources/portal_link.rb
|
62
|
+
- lib/convoy/resources/project.rb
|
63
63
|
- lib/convoy/resources/source.rb
|
64
64
|
- lib/convoy/resources/subscription.rb
|
65
|
+
- lib/convoy/util.rb
|
65
66
|
- lib/convoy/version.rb
|
67
|
+
- lib/convoy/webhook.rb
|
66
68
|
homepage: https://getconvoy.io
|
67
69
|
licenses:
|
68
70
|
- MIT
|
@@ -70,7 +72,7 @@ metadata:
|
|
70
72
|
homepage_uri: https://getconvoy.io
|
71
73
|
source_code_uri: https://github.com/frain-dev/convoy.rb
|
72
74
|
changelog_uri: https://github.com/frain-dev/convoy.rb/blob/main/CHANGELOG
|
73
|
-
post_install_message:
|
75
|
+
post_install_message:
|
74
76
|
rdoc_options: []
|
75
77
|
require_paths:
|
76
78
|
- lib
|
@@ -78,15 +80,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
78
80
|
requirements:
|
79
81
|
- - ">="
|
80
82
|
- !ruby/object:Gem::Version
|
81
|
-
version:
|
83
|
+
version: 3.0.0
|
82
84
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
85
|
requirements:
|
84
86
|
- - ">="
|
85
87
|
- !ruby/object:Gem::Version
|
86
88
|
version: '0'
|
87
89
|
requirements: []
|
88
|
-
rubygems_version: 3.
|
89
|
-
signing_key:
|
90
|
+
rubygems_version: 3.3.7
|
91
|
+
signing_key:
|
90
92
|
specification_version: 4
|
91
93
|
summary: Convoy Ruby Client.
|
92
94
|
test_files: []
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module Convoy
|
2
|
-
class Application < ApiResource
|
3
|
-
include ApiOperations::Save
|
4
|
-
include ApiOperations::Delete
|
5
|
-
include ApiOperations::List
|
6
|
-
extend ApiOperations::Create
|
7
|
-
|
8
|
-
def initialize(id = nil, config = Convoy.config, **kwargs)
|
9
|
-
@id = id
|
10
|
-
@data = kwargs[:data].nil? ? {} : kwargs[:data]
|
11
|
-
@params = kwargs[:params].nil? ? {} : kwargs[:params]
|
12
|
-
@config = config
|
13
|
-
end
|
14
|
-
|
15
|
-
def resource_url
|
16
|
-
if @id.nil?
|
17
|
-
return "#{@config.base_uri}/#{@config.path_version}/applications"
|
18
|
-
end
|
19
|
-
|
20
|
-
"#{@config.base_uri}/#{@config.path_version}/applications" + "/#{@id}"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|