convoy.rb 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.travis.yml +6 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +41 -0
- data/LICENSE.txt +21 -0
- data/README.md +44 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/convoy.gemspec +30 -0
- data/lib/convoy/api_operations/create.rb +12 -0
- data/lib/convoy/api_operations/delete.rb +24 -0
- data/lib/convoy/api_operations/get.rb +26 -0
- data/lib/convoy/api_operations/list.rb +28 -0
- data/lib/convoy/api_operations/request.rb +57 -0
- data/lib/convoy/api_operations/save.rb +29 -0
- data/lib/convoy/api_resource.rb +30 -0
- data/lib/convoy/convoy_configuration.rb +19 -0
- data/lib/convoy/errors.rb +0 -0
- data/lib/convoy/instrumentation.rb +0 -0
- data/lib/convoy/resources/api_key.rb +0 -0
- data/lib/convoy/resources/application.rb +24 -0
- data/lib/convoy/resources/delivery_attempt.rb +22 -0
- data/lib/convoy/resources/endpoint.rb +25 -0
- data/lib/convoy/resources/event.rb +24 -0
- data/lib/convoy/resources/event_delivery.rb +25 -0
- data/lib/convoy/resources/group.rb +25 -0
- data/lib/convoy/version.rb +3 -0
- data/lib/convoy.rb +31 -0
- metadata +90 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2b2db40edf32d5f9ee26eba53c217d12d2bcc07d64b23cf52f43818b837213a7
|
4
|
+
data.tar.gz: 965df72a16bd02ddf9a57fa3bc3affd0da45fa23a6c1503ae5915fba98328017
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8b811b6c577486c5ed57242fd5285220d6835009475e7c6a57692999bc107e1c5c2fadb71bcb1578536121cf5e9a2fe3c50d03a9e76da082fecc270f3f152598
|
7
|
+
data.tar.gz: 7fe6e38d4d1d3687821e73c88c0d7a243b40362f02ea210da7e641cd9d048b6f50a39e994b46f4f7ba17a81901864f6395a2929440aa329030c58fdd0fca6536
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at subomioluwalana71@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [https://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: https://contributor-covenant.org
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in convoy.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
gem "rake", "~> 12.0"
|
7
|
+
|
8
|
+
group :development do
|
9
|
+
gem 'webmock', '>= 3.8.0'
|
10
|
+
end
|
11
|
+
|
12
|
+
group :test do
|
13
|
+
gem 'pry'
|
14
|
+
gem "minitest", "~> 5.0"
|
15
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
convoy (0.1.0)
|
5
|
+
zeitwerk (~> 2.5)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
addressable (2.8.0)
|
11
|
+
public_suffix (>= 2.0.2, < 5.0)
|
12
|
+
coderay (1.1.3)
|
13
|
+
crack (0.4.5)
|
14
|
+
rexml
|
15
|
+
hashdiff (1.0.1)
|
16
|
+
method_source (1.0.0)
|
17
|
+
minitest (5.15.0)
|
18
|
+
pry (0.14.1)
|
19
|
+
coderay (~> 1.1)
|
20
|
+
method_source (~> 1.0)
|
21
|
+
public_suffix (4.0.6)
|
22
|
+
rake (12.3.3)
|
23
|
+
rexml (3.2.5)
|
24
|
+
webmock (3.14.0)
|
25
|
+
addressable (>= 2.8.0)
|
26
|
+
crack (>= 0.3.2)
|
27
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
28
|
+
zeitwerk (2.5.3)
|
29
|
+
|
30
|
+
PLATFORMS
|
31
|
+
ruby
|
32
|
+
|
33
|
+
DEPENDENCIES
|
34
|
+
convoy!
|
35
|
+
minitest (~> 5.0)
|
36
|
+
pry
|
37
|
+
rake (~> 12.0)
|
38
|
+
webmock (>= 3.8.0)
|
39
|
+
|
40
|
+
BUNDLED WITH
|
41
|
+
2.1.4
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021 Subomi Oluwalana
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
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
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'convoy'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install convoy
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
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
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
41
|
+
|
42
|
+
## Code of Conduct
|
43
|
+
|
44
|
+
Everyone interacting in the Convoy project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/convoy/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "convoy"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/convoy.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require_relative 'lib/convoy/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "convoy.rb"
|
5
|
+
spec.version = Convoy::VERSION
|
6
|
+
spec.authors = ["Subomi Oluwalana"]
|
7
|
+
spec.email = ["subomioluwalana71@gmail.com"]
|
8
|
+
|
9
|
+
spec.summary = "Convoy Ruby Client."
|
10
|
+
spec.description = "Convoy ruby client to push webhook events from any ruby application."
|
11
|
+
spec.homepage = "https://getconvoy.io"
|
12
|
+
spec.license = "MIT"
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
14
|
+
|
15
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
16
|
+
spec.metadata["source_code_uri"] = "https://github.com/frain-dev/convoy.rb"
|
17
|
+
spec.metadata["changelog_uri"] = "https://github.com/frain-dev/convoy.rb/blob/main/CHANGELOG"
|
18
|
+
|
19
|
+
spec.add_runtime_dependency 'zeitwerk', '~> 2.5'
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
end
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Convoy
|
2
|
+
module ApiOperations
|
3
|
+
module Delete
|
4
|
+
module ClassMethods
|
5
|
+
def delete(id)
|
6
|
+
resource = self.new(id)
|
7
|
+
resource.delete
|
8
|
+
|
9
|
+
resource
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def delete
|
14
|
+
send_request(resource_url, :delete)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.included(base)
|
18
|
+
# Setup helper methods on Class.
|
19
|
+
base.extend(ClassMethods)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Convoy
|
2
|
+
module ApiOperations
|
3
|
+
module Get
|
4
|
+
module ClassMethods
|
5
|
+
def self.get(id)
|
6
|
+
resource = self.new(id)
|
7
|
+
resource.get
|
8
|
+
|
9
|
+
resource
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def get
|
14
|
+
response = send_request(resource_url, :get)
|
15
|
+
|
16
|
+
data = JSON.parse(response.body)["data"]
|
17
|
+
@data = data
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.included(base)
|
21
|
+
# Setup helper methods on Class.
|
22
|
+
base.extend(ClassMethods)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "json"
|
2
|
+
|
3
|
+
module Convoy
|
4
|
+
module ApiOperations
|
5
|
+
module List
|
6
|
+
module ClassMethods
|
7
|
+
def list(**kwargs)
|
8
|
+
resource = self.new(**kwargs)
|
9
|
+
resource.list
|
10
|
+
|
11
|
+
resource
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def list
|
16
|
+
response = send_request(resource_url, :get)
|
17
|
+
|
18
|
+
data = JSON.parse(response.body)["data"]
|
19
|
+
@data = data
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.included(base)
|
23
|
+
# Setup helper methods on Class.
|
24
|
+
base.extend(ClassMethods)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require "net/http"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
module Convoy
|
5
|
+
module ApiOperations
|
6
|
+
module Request
|
7
|
+
def send_request(uri, method, config = Convoy.config, **kwargs)
|
8
|
+
# Determine URL.
|
9
|
+
uri = URI(uri)
|
10
|
+
params = kwargs[:params].nil? ? {} : kwargs[:params]
|
11
|
+
uri.query = URI.encode_www_form(params) unless params.empty?
|
12
|
+
|
13
|
+
# Build Request.
|
14
|
+
request = case method.downcase.to_sym
|
15
|
+
when :post
|
16
|
+
req = Net::HTTP::Post.new(uri.request_uri)
|
17
|
+
data = kwargs[:data].nil? ? {} : kwargs[:data]
|
18
|
+
req['Content-Type'] = 'application/json'
|
19
|
+
req.body = JSON.dump(data)
|
20
|
+
|
21
|
+
req
|
22
|
+
when :get
|
23
|
+
Net::HTTP::Get.new(uri.request_uri)
|
24
|
+
when :delete
|
25
|
+
Net::HTTP::Delete.new(uri.request_uri)
|
26
|
+
when :put
|
27
|
+
req = Net::HTTP::Put.new(uri.request_uri)
|
28
|
+
data = kwargs[:data].nil? ? {} : kwargs[:data]
|
29
|
+
req['Content-Type'] = 'application/json'
|
30
|
+
req.body = JSON.dump(data)
|
31
|
+
|
32
|
+
req
|
33
|
+
end
|
34
|
+
|
35
|
+
request.basic_auth config.username, config.password
|
36
|
+
|
37
|
+
|
38
|
+
# Build HTTP Client.
|
39
|
+
client = Net::HTTP.new(uri.host, uri.port)
|
40
|
+
client.use_ssl = config.ssl
|
41
|
+
client.open_timeout = 10
|
42
|
+
client.read_timeout = 10
|
43
|
+
client.continue_timeout = 10
|
44
|
+
client.ssl_timeout = 10
|
45
|
+
|
46
|
+
# TODO: Make this configurable
|
47
|
+
client.set_debug_output $stderr
|
48
|
+
|
49
|
+
# Make request.
|
50
|
+
http_response = client.request(request)
|
51
|
+
@response = JSON.parse(http_response.body)
|
52
|
+
|
53
|
+
# TODO: Perform err checks.
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Convoy
|
2
|
+
module ApiOperations
|
3
|
+
module Save
|
4
|
+
module ClassMethods
|
5
|
+
def update(id, **kwargs)
|
6
|
+
resource = self.new(id, **kwargs)
|
7
|
+
resource.update
|
8
|
+
|
9
|
+
resource
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def update(data = {})
|
14
|
+
@data = data unless data.empty?
|
15
|
+
send_request(resource_url, :put, data: @data, params: @params)
|
16
|
+
end
|
17
|
+
|
18
|
+
def save
|
19
|
+
method = @id.nil? ? :post : :put
|
20
|
+
send_request(resource_url, method, data: @data, params: @params)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.included(base)
|
24
|
+
# Setup helper methods on Class.
|
25
|
+
base.extend(ClassMethods)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'forwardable'
|
2
|
+
|
3
|
+
module Convoy
|
4
|
+
|
5
|
+
# USAGE
|
6
|
+
# resource = Convoy::Resource.create(args)
|
7
|
+
# OR
|
8
|
+
# resource = Convoy::Resource.new(args)
|
9
|
+
# resource.save
|
10
|
+
#
|
11
|
+
# Class methods - get, list, create, update, delete. These methods exist
|
12
|
+
# as helper methods.
|
13
|
+
# Instance methods - get, list, save, delete, update. Core methods class
|
14
|
+
# methods rely on.
|
15
|
+
class ApiResource
|
16
|
+
extend Forwardable
|
17
|
+
include Convoy::ApiOperations::Request
|
18
|
+
|
19
|
+
# You must either use this or the list resource but cannot use object on
|
20
|
+
# the same instance. Each resource is either a container with one record
|
21
|
+
# or a list of records.
|
22
|
+
def_delegator :@data, :[], :get_data
|
23
|
+
def_delegator :@data, :[]=, :set_data
|
24
|
+
|
25
|
+
# For list resources
|
26
|
+
def_delegators :@data, :size, :map, :each
|
27
|
+
|
28
|
+
attr_reader :response
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Convoy
|
2
|
+
class ConvoyConfiguration
|
3
|
+
|
4
|
+
attr_accessor :ssl
|
5
|
+
attr_accessor :username
|
6
|
+
attr_accessor :password
|
7
|
+
attr_accessor :base_uri
|
8
|
+
attr_accessor :path_version
|
9
|
+
attr_accessor :logger
|
10
|
+
attr_accessor :log_level
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
@base_uri = "https://cloud.getconvoy.io"
|
14
|
+
@path_version = "/v1"
|
15
|
+
@ssl = true
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,24 @@
|
|
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
|
+
|
16
|
+
def resource_url
|
17
|
+
if @id.nil?
|
18
|
+
return "#{@config.base_uri}/#{@config.path_version}/applications"
|
19
|
+
end
|
20
|
+
|
21
|
+
"#{@config.base_uri}/#{@config.path_version}/applications" + "/#{@id}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Convoy
|
2
|
+
class DeliveryAttempt < ApiResource
|
3
|
+
include ApiOperations::Get
|
4
|
+
include ApiOperations::List
|
5
|
+
|
6
|
+
def initialize(eventId = nil, id = nil, config = Convoy.config)
|
7
|
+
@eventId = eventId
|
8
|
+
@id = id
|
9
|
+
@config = config
|
10
|
+
end
|
11
|
+
|
12
|
+
def resource_url
|
13
|
+
if @id.nil?
|
14
|
+
return "#{@config.base_uri}/#{@config.path_version}/events/#{@eventId}" +
|
15
|
+
"/deliveryattempts"
|
16
|
+
end
|
17
|
+
|
18
|
+
"#{@config.base_uri}/#{@config.path_version}/events/#{@eventId}/deliveryattempts" +
|
19
|
+
"/#{@id}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Convoy
|
2
|
+
class Endpoint < 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(app_id = nil, id = nil, config = Convoy.config, **kwargs)
|
10
|
+
@app_id = app_id
|
11
|
+
@id = id
|
12
|
+
@data = kwargs[:data].nil? ? {} : kwargs[:data]
|
13
|
+
@config = config
|
14
|
+
end
|
15
|
+
|
16
|
+
def resource_url
|
17
|
+
if @id.nil?
|
18
|
+
return "#{@config.base_uri}/#{@config.path_version}/applications/#{@app_id}/endpoints"
|
19
|
+
end
|
20
|
+
|
21
|
+
"#{@config.base_uri}/#{@config.path_version}/applications/#{@app_id}/endpoints" +
|
22
|
+
"/#{@id}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Convoy
|
2
|
+
class Event < 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
|
+
@data = kwargs[:data].nil? ? {} : kwargs[:data]
|
12
|
+
@params = kwargs[:params].nil? ? {} : kwargs[:params]
|
13
|
+
@config = config
|
14
|
+
end
|
15
|
+
|
16
|
+
def resource_url
|
17
|
+
if @id.nil?
|
18
|
+
return "#{@config.base_uri}/#{@config.path_version}/events"
|
19
|
+
end
|
20
|
+
|
21
|
+
"#{@config.base_uri}/#{@config.path_version}/events/#{@id}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Convoy
|
2
|
+
class EventDelivery < ApiResource
|
3
|
+
include ApiOperations::Get
|
4
|
+
include ApiOperations::List
|
5
|
+
|
6
|
+
def intialize(eventId = nil, id = nil, config = Convoy.config)
|
7
|
+
@eventId = eventId
|
8
|
+
@id = id
|
9
|
+
@config = config
|
10
|
+
end
|
11
|
+
|
12
|
+
def resource_url
|
13
|
+
if @id.nil?
|
14
|
+
return "#{@config.base_uri}/#{@config.path_version}/events/#{@eventId}" +
|
15
|
+
"/eventdelivery"
|
16
|
+
end
|
17
|
+
|
18
|
+
"#{@config.base_uri}/#{@config.path_version}/events/#{@eventId}/eventdelivery" +
|
19
|
+
"/#{@id}"
|
20
|
+
end
|
21
|
+
|
22
|
+
# TODO: resend event delivery.
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Convoy
|
2
|
+
class Group < 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
|
+
@data = kwargs[:data].nil? ? {} : kwargs[:data]
|
12
|
+
@params = kwargs[:params].nil? ? {} : kwargs[:params]
|
13
|
+
@config = config
|
14
|
+
end
|
15
|
+
|
16
|
+
def resource_url
|
17
|
+
if @id.nil?
|
18
|
+
return "#{@config.base_uri}/#{@config.path_version}/groups"
|
19
|
+
end
|
20
|
+
|
21
|
+
"#{@config.base_uri}/#{@config.path_version}/groups" + "/#{@id}"
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
data/lib/convoy.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require "convoy/version"
|
2
|
+
require "zeitwerk"
|
3
|
+
require "forwardable"
|
4
|
+
|
5
|
+
loader = Zeitwerk::Loader.for_gem
|
6
|
+
loader.enable_reloading
|
7
|
+
|
8
|
+
# Collapse resource directory
|
9
|
+
resources_dir = "#{__dir__}/convoy/resources"
|
10
|
+
loader.collapse(resources_dir)
|
11
|
+
loader.setup
|
12
|
+
|
13
|
+
module Convoy
|
14
|
+
|
15
|
+
@config = ConvoyConfiguration.new
|
16
|
+
|
17
|
+
class << self
|
18
|
+
extend Forwardable
|
19
|
+
|
20
|
+
attr_reader :config
|
21
|
+
|
22
|
+
# User configurable options
|
23
|
+
def_delegators :@config, :ssl, :ssl=
|
24
|
+
def_delegators :@config, :username, :username=
|
25
|
+
def_delegators :@config, :password, :password=
|
26
|
+
def_delegators :@config, :base_uri, :base_uri=
|
27
|
+
def_delegators :@config, :logger, :logger=
|
28
|
+
def_delegators :@config, :log_level, :log_level=
|
29
|
+
def_delegators :@config, :path_version, :path_version=
|
30
|
+
end
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: convoy.rb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Subomi Oluwalana
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-01-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: zeitwerk
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.5'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.5'
|
27
|
+
description: Convoy ruby client to push webhook events from any ruby application.
|
28
|
+
email:
|
29
|
+
- subomioluwalana71@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".gitignore"
|
35
|
+
- ".travis.yml"
|
36
|
+
- CODE_OF_CONDUCT.md
|
37
|
+
- Gemfile
|
38
|
+
- Gemfile.lock
|
39
|
+
- LICENSE.txt
|
40
|
+
- README.md
|
41
|
+
- Rakefile
|
42
|
+
- bin/console
|
43
|
+
- bin/setup
|
44
|
+
- convoy.gemspec
|
45
|
+
- lib/convoy.rb
|
46
|
+
- lib/convoy/api_operations/create.rb
|
47
|
+
- lib/convoy/api_operations/delete.rb
|
48
|
+
- lib/convoy/api_operations/get.rb
|
49
|
+
- lib/convoy/api_operations/list.rb
|
50
|
+
- lib/convoy/api_operations/request.rb
|
51
|
+
- lib/convoy/api_operations/save.rb
|
52
|
+
- lib/convoy/api_resource.rb
|
53
|
+
- lib/convoy/convoy_configuration.rb
|
54
|
+
- lib/convoy/errors.rb
|
55
|
+
- lib/convoy/instrumentation.rb
|
56
|
+
- lib/convoy/resources/api_key.rb
|
57
|
+
- lib/convoy/resources/application.rb
|
58
|
+
- lib/convoy/resources/delivery_attempt.rb
|
59
|
+
- lib/convoy/resources/endpoint.rb
|
60
|
+
- lib/convoy/resources/event.rb
|
61
|
+
- lib/convoy/resources/event_delivery.rb
|
62
|
+
- lib/convoy/resources/group.rb
|
63
|
+
- lib/convoy/version.rb
|
64
|
+
homepage: https://getconvoy.io
|
65
|
+
licenses:
|
66
|
+
- MIT
|
67
|
+
metadata:
|
68
|
+
homepage_uri: https://getconvoy.io
|
69
|
+
source_code_uri: https://github.com/frain-dev/convoy.rb
|
70
|
+
changelog_uri: https://github.com/frain-dev/convoy.rb/blob/main/CHANGELOG
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options: []
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: 2.3.0
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
requirements: []
|
86
|
+
rubygems_version: 3.1.4
|
87
|
+
signing_key:
|
88
|
+
specification_version: 4
|
89
|
+
summary: Convoy Ruby Client.
|
90
|
+
test_files: []
|