convoy.rb 0.2.0 → 0.3.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: 0bb0d6490ecbfd2a8bbef2429e9057ee9861dd7504d182c58e4bb68b9be929f1
4
- data.tar.gz: e1e2a181c570f0d04af0a07ade86e9fef2839c3528ab1132fdb535fa8d209bb4
3
+ metadata.gz: d84ba6e548b79893bcad3e8deb0a86d80c591e4009f0d6a11d64011a7b918593
4
+ data.tar.gz: 2b5cf92c2939fb48e766928e86e63a0800ef99591a92a9472023a3f62d90e858
5
5
  SHA512:
6
- metadata.gz: 2e16c445680e2290940c5d23eb712c26b2b1d893f3e254940fecdb77b0dc1413eb5ed9bfd66b0e52476a14924d86f3b08937d1510ce8c663f6e6105901eb5ef4
7
- data.tar.gz: 6a0db61a950f75867be10eae911c15812f6b5987957d514f362445b52eb9558f994712283590d01bbf042688a6aa608e9e6f6b87722bf3f754902dbb6e9eef67
6
+ metadata.gz: 30d0410db297a90f8a21243cf8aa477569865df8ae57af66159428f8745644f805f6900e18f0f0e022588ea2b0ee0b60ffa2bd961503ea625c21a9e791dfd14c
7
+ data.tar.gz: 939f323b06ff770b6f4b9d48a3c196fca4a4a99cc72889ae6876b1e8139497d09d2a3ede98091a4cd7b434629a1cad274d0759bf5eb68e166d62112fa5725ee0
data/README.md CHANGED
@@ -20,39 +20,20 @@ Or install it yourself as:
20
20
  ## Usage
21
21
 
22
22
  ### Setup Client
23
-
23
+ To configure your client, provide your `api_key` and `project_id`, see below:
24
24
  ```ruby
25
25
  require 'convoy'
26
26
 
27
27
  Convoy.ssl = true
28
28
  Convoy.api_key = "CO.M0aBe..."
29
- Convoy.path_version = "v1"
30
- Convoy.base_uri = "https://dashboard.getconvoy.io/api"
31
-
32
- ```
33
-
34
- ### Creating an application
35
- An application represents a user's application trying to receive webhooks. Once you create an application, you'll receive a `uid` as part of the response that you should save and supply in subsequent API calls to perform other requests such as creating an event.
36
-
37
- ```ruby
38
- app = Convoy::Application.new(
39
- params: {
40
- groupID: "c3637195-53cd-4eba-b9df-e7ba9479fbb2"
41
- },
42
- data: {
43
- name: "Integration One"
44
- }
45
- )
46
-
47
- app_response = app.save
29
+ Convoy.project_id = "23b1..."
48
30
  ```
49
31
 
50
- ### Add an Endpoint to Application
51
- After creating an application, you'll need to add an endpoint to the application you just created. An endpoint represents a target URL to receive events.
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.
52
34
 
53
35
  ```ruby
54
36
  endpoint = Convoy::Endpoint.new(
55
- app_id,
56
37
  data: {
57
38
  "description": "Endpoint One",
58
39
  "http_timeout": "1m",
@@ -69,25 +50,21 @@ After creating an endpoint, we need to susbcribe the endpoint to events.
69
50
  ```ruby
70
51
  subscription = Convoy::Subscription.new(
71
52
  data: {
72
- app_id: app_id,
73
53
  endpoint_id: endpoint_id,
74
- name: 'ruby subscription',
75
- filter_config: {
76
- event_types: [ "*" ]
77
- }
54
+ name: 'ruby subscription'
78
55
  }
79
56
  )
80
57
 
81
58
  subscription_response = subscription.save
82
59
  ```
83
60
 
84
- ### Publish an Event
85
- Now let's publish an event.
61
+ ### Send Event
62
+ To send an event, you'll need to pass the `uid` from the endpoint we created earlier.
86
63
 
87
64
  ```ruby
88
65
  event = Convoy::Event.new(
89
66
  data: {
90
- app_id: app_id,
67
+ endpoint_id: endpoint_id,
91
68
  event_type: "wallet.created",
92
69
  data: {
93
70
  status: "completed",
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(">= 2.3.0")
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"
@@ -10,7 +10,7 @@ module Convoy
10
10
  @id = id
11
11
  @config = config
12
12
 
13
- super(kwargs)
13
+ super(**kwargs)
14
14
  end
15
15
 
16
16
  def resource_uri
@@ -8,7 +8,7 @@ module Convoy
8
8
  @eventId = eventId
9
9
  @config = config
10
10
 
11
- super(kwargs)
11
+ super(**kwargs)
12
12
  end
13
13
 
14
14
  def resource_uri
@@ -10,7 +10,7 @@ module Convoy
10
10
  @id = id
11
11
  @config = config
12
12
 
13
- super(kwargs)
13
+ super(**kwargs)
14
14
  end
15
15
 
16
16
  def resource_uri
@@ -20,5 +20,10 @@ module Convoy
20
20
 
21
21
  "#{project_base_uri}/endpoints/#{@id}"
22
22
  end
23
+
24
+ def pause
25
+ pause_uri = "#{resource_uri}/pause"
26
+ send_request(pause_uri, :post, data: @data, params: @params)
27
+ end
23
28
  end
24
29
  end
@@ -10,7 +10,7 @@ module Convoy
10
10
  @id = id
11
11
  @config = config
12
12
 
13
- super(kwargs)
13
+ super(**kwargs)
14
14
  end
15
15
 
16
16
  def resource_uri
@@ -20,5 +20,10 @@ module Convoy
20
20
 
21
21
  "#{project_base_uri}/events/#{@id}"
22
22
  end
23
+
24
+ def fanout
25
+ fanout_uri = "#{resource_uri}/fanout"
26
+ send_request(fanout_uri, :post, data: @data, params: @params)
27
+ end
23
28
  end
24
29
  end
@@ -8,7 +8,7 @@ module Convoy
8
8
  @eventId = eventId
9
9
  @config = config
10
10
 
11
- super(kwargs)
11
+ super(**kwargs)
12
12
  end
13
13
 
14
14
  def resource_uri
@@ -19,7 +19,15 @@ module Convoy
19
19
  "#{project_base_uri}/events/#{@eventId}/eventdelivery/#{@id}"
20
20
  end
21
21
 
22
- # TODO: resend event delivery.
22
+
23
+ def retry
24
+ retry_uri = "#{resource_uri}/resend"
25
+ send_request(retry_uri, :put, data: @data, params: @params)
26
+ end
23
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
24
32
  end
25
33
  end
@@ -0,0 +1,24 @@
1
+ module Convoy
2
+ class PortalLink < ApiResource
3
+ include ApiOperations::Get
4
+ include ApiOperations::Save
5
+ include ApiOperations::List
6
+ include ApiOperations::Delete
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 "#{project_base_uri}/portal-links"
19
+ end
20
+
21
+ "#{project_base_uri}/portal-links/#{@id}"
22
+ end
23
+ end
24
+ end
@@ -10,7 +10,7 @@ module Convoy
10
10
  @id = id
11
11
  @config = config
12
12
 
13
- super(kwargs)
13
+ super(**kwargs)
14
14
  end
15
15
 
16
16
  def resource_uri
@@ -9,7 +9,7 @@ module Convoy
9
9
  @id = id
10
10
  @config = config
11
11
 
12
- super(kwargs)
12
+ super(**kwargs)
13
13
  end
14
14
 
15
15
  def resource_uri
@@ -9,7 +9,7 @@ module Convoy
9
9
  @id = id
10
10
  @config = config
11
11
 
12
- super(kwargs)
12
+ super(**kwargs)
13
13
  end
14
14
 
15
15
  def resource_uri
@@ -1,3 +1,3 @@
1
1
  module Convoy
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -47,12 +47,13 @@ module Convoy
47
47
  return Util.secure_compare(compute_signature(payload), sig_header)
48
48
  end
49
49
 
50
- def verify_advanced_signature
50
+ def verify_advanced_signature(payload, sig_header)
51
51
  timestamp_header, signatures = get_timestamp_and_signatures(sig_header)
52
+ payload = "{#{timestamp_header}},{#{payload}}"
52
53
 
53
54
  verify_timestamp(timestamp_header)
54
55
 
55
- unless signatures.any? { |s| Util.secure_compare(expected_sig, s) }
56
+ unless signatures.any? { |s| Util.secure_compare(compute_signature(payload), s) }
56
57
  raise SignatureVerificationError.new,
57
58
  "No signatures found matching the expected signature for payload"
58
59
  end
@@ -74,9 +75,9 @@ module Convoy
74
75
  # return encoded string
75
76
  def compute_signature(payload)
76
77
  case @encoding
77
- when "hex":
78
+ when "hex"
78
79
  return OpenSSL::HMAC.hexdigest(@hash, @secret, payload)
79
- when "base64":
80
+ when "base64"
80
81
  hmac = OpenSSL::HMAC.digest(@hash, @secret, payload)
81
82
  return Base64.encode64(hmac)
82
83
  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.2.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: 2022-11-24 00:00:00.000000000 Z
11
+ date: 2023-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk
@@ -58,6 +58,7 @@ files:
58
58
  - lib/convoy/resources/endpoint.rb
59
59
  - lib/convoy/resources/event.rb
60
60
  - lib/convoy/resources/event_delivery.rb
61
+ - lib/convoy/resources/portal_link.rb
61
62
  - lib/convoy/resources/project.rb
62
63
  - lib/convoy/resources/source.rb
63
64
  - lib/convoy/resources/subscription.rb
@@ -71,7 +72,7 @@ metadata:
71
72
  homepage_uri: https://getconvoy.io
72
73
  source_code_uri: https://github.com/frain-dev/convoy.rb
73
74
  changelog_uri: https://github.com/frain-dev/convoy.rb/blob/main/CHANGELOG
74
- post_install_message:
75
+ post_install_message:
75
76
  rdoc_options: []
76
77
  require_paths:
77
78
  - lib
@@ -79,15 +80,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
79
80
  requirements:
80
81
  - - ">="
81
82
  - !ruby/object:Gem::Version
82
- version: 2.3.0
83
+ version: 3.0.0
83
84
  required_rubygems_version: !ruby/object:Gem::Requirement
84
85
  requirements:
85
86
  - - ">="
86
87
  - !ruby/object:Gem::Version
87
88
  version: '0'
88
89
  requirements: []
89
- rubygems_version: 3.1.4
90
- signing_key:
90
+ rubygems_version: 3.3.7
91
+ signing_key:
91
92
  specification_version: 4
92
93
  summary: Convoy Ruby Client.
93
94
  test_files: []