convoy.rb 0.1.7 → 0.1.9

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: e4859252007849854b7c45c72d7d2e9a32eb2e8f627bc1a7c85e098bb1e37b38
4
- data.tar.gz: e2dfa339703c652c9df8bf901c084898435debbac17d8d6d4c62f5fdd965b3ea
3
+ metadata.gz: f33937f312b1c892facfce7d871bb972fd0f18ccd4fd0480697e91cd7a8b1662
4
+ data.tar.gz: 8f8335fc9c3257ad80d68c07fda93fe3066792a0acdb55b1e9c3c9c89da73521
5
5
  SHA512:
6
- metadata.gz: 220f5231cc5f405c781d3ef147125c1b967769183e7532751f2803cdd04597d15d729e0084696bf03e67e4e48e23104eab10202b2a1808717dad0bb20e540eb1
7
- data.tar.gz: 4eff66338f0f6ee4c00a519d278b5d173c6742dc369ec26038a31c2a60076f84046e7ec24b698db41d03e37a0eacd3fa7c421b1da428abb489a4bbd66ef9988e
6
+ metadata.gz: 6efa47b6410966a4ee0fd8d254210a5e1e201634544725585739e7b2f80b562b82d5c8ee621bb4890095da43f755f15e410aa2ef77e6e0495e4089c5848e321a
7
+ data.tar.gz: 680f6f45ab3fc28ea5ef4236d0b8a26676566ba927d4a9f352c0921af03c4a32735fbce7ce9fc75c37733b4dae65f6c5597c7724ba52afdeee1c3d78ab457d02
@@ -11,7 +11,7 @@ module Convoy
11
11
  end
12
12
 
13
13
  def delete
14
- send_request(resource_url, :delete)
14
+ send_request(resource_url, :delete, params: @params)
15
15
  end
16
16
 
17
17
  def self.included(base)
@@ -11,7 +11,7 @@ module Convoy
11
11
  end
12
12
 
13
13
  def get
14
- send_request(resource_url, :get)
14
+ send_request(resource_url, :get, params: @params)
15
15
  @data = @response['data']
16
16
  end
17
17
 
@@ -13,7 +13,7 @@ module Convoy
13
13
  end
14
14
 
15
15
  def list
16
- send_request(resource_url, :get)
16
+ send_request(resource_url, :get, params: @params)
17
17
  @data = @response['data']
18
18
  end
19
19
 
@@ -32,8 +32,11 @@ module Convoy
32
32
  req
33
33
  end
34
34
 
35
- request.basic_auth config.username, config.password
36
-
35
+ if !config.api_key.nil?
36
+ request['Authorization'] = "Bearer #{config.api_key}"
37
+ else
38
+ request.basic_auth config.username, config.password
39
+ end
37
40
 
38
41
  # Build HTTP Client.
39
42
  client = Net::HTTP.new(uri.host, uri.port)
@@ -5,13 +5,14 @@ module Convoy
5
5
  attr_accessor :debug
6
6
  attr_accessor :username
7
7
  attr_accessor :password
8
+ attr_accessor :api_key
8
9
  attr_accessor :base_uri
9
10
  attr_accessor :path_version
10
11
  attr_accessor :logger
11
12
  attr_accessor :log_level
12
13
 
13
14
  def initialize
14
- @base_uri = "https://cloud.getconvoy.io"
15
+ @base_uri = "https://dashboard.getconvoy.io"
15
16
  @path_version = "/v1"
16
17
  @ssl = true
17
18
  @debug = false
@@ -3,9 +3,10 @@ module Convoy
3
3
  include ApiOperations::Get
4
4
  include ApiOperations::List
5
5
 
6
- def initialize(eventId = nil, id = nil, config = Convoy.config)
6
+ def initialize(eventId = nil, id = nil, config = Convoy.config, **kwargs)
7
7
  @eventId = eventId
8
8
  @id = id
9
+ @params = kwargs[:params].nil? ? {} : kwargs[:params]
9
10
  @config = config
10
11
  end
11
12
 
@@ -10,6 +10,7 @@ module Convoy
10
10
  @app_id = app_id
11
11
  @id = id
12
12
  @data = kwargs[:data].nil? ? {} : kwargs[:data]
13
+ @params = kwargs[:params].nil? ? {} : kwargs[:params]
13
14
  @config = config
14
15
  end
15
16
 
@@ -3,8 +3,9 @@ module Convoy
3
3
  include ApiOperations::Get
4
4
  include ApiOperations::List
5
5
 
6
- def intialize(eventId = nil, id = nil, config = Convoy.config)
6
+ def intialize(eventId = nil, id = nil, config = Convoy.config, **kwargs)
7
7
  @eventId = eventId
8
+ @params = kwargs[:params].nil? ? {} : kwargs[:params]
8
9
  @id = id
9
10
  @config = config
10
11
  end
@@ -0,0 +1,23 @@
1
+ module Convoy
2
+ class Source < 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}/sources"
18
+ end
19
+
20
+ "#{@config.base_uri}/#{@config.path_version}/sources" + "/#{@id}"
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ module Convoy
2
+ class Subscription < 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}/subscriptions"
18
+ end
19
+
20
+ "#{@config.base_uri}/#{@config.path_version}/subscriptions" + "/#{@id}"
21
+ end
22
+ end
23
+ end
@@ -1,3 +1,3 @@
1
1
  module Convoy
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.9"
3
3
  end
data/lib/convoy.rb CHANGED
@@ -20,10 +20,12 @@ module Convoy
20
20
  attr_reader :config
21
21
 
22
22
  # User configurable options
23
+ # Some of them have defaults
23
24
  def_delegators :@config, :ssl, :ssl=
24
25
  def_delegators :@config, :debug, :debug=
25
26
  def_delegators :@config, :username, :username=
26
27
  def_delegators :@config, :password, :password=
28
+ def_delegators :@config, :api_key, :api_key=
27
29
  def_delegators :@config, :base_uri, :base_uri=
28
30
  def_delegators :@config, :logger, :logger=
29
31
  def_delegators :@config, :log_level, :log_level=
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.1.7
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Subomi Oluwalana
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-01 00:00:00.000000000 Z
11
+ date: 2022-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk
@@ -60,6 +60,8 @@ files:
60
60
  - lib/convoy/resources/event.rb
61
61
  - lib/convoy/resources/event_delivery.rb
62
62
  - lib/convoy/resources/group.rb
63
+ - lib/convoy/resources/source.rb
64
+ - lib/convoy/resources/subscription.rb
63
65
  - lib/convoy/version.rb
64
66
  homepage: https://getconvoy.io
65
67
  licenses: