integromat 0.1.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 +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +42 -0
- data/LICENSE.txt +21 -0
- data/README.md +98 -0
- data/Rakefile +12 -0
- data/images/make-screenshot.png +0 -0
- data/integromat.gemspec +41 -0
- data/lib/integromat/base.rb +33 -0
- data/lib/integromat/config.rb +10 -0
- data/lib/integromat/exceptions.rb +4 -0
- data/lib/integromat/version.rb +5 -0
- data/lib/integromat/webhook.rb +21 -0
- data/lib/integromat.rb +20 -0
- metadata +90 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e0ca9bab3704f514b3c816a6cc35028464cda5bb8507d57a7712c7c1ea7ba13e
|
4
|
+
data.tar.gz: 64d6dd910bc9af12ccc9008206e8616a820a8e29a0de1d4af6591a6ea8df074a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8f02bc00aa7f294f029ad97637d01c9572e40443c10db403c52351a668bac7bb566c2eae8279b8703c8218a07a0dbf1201257e94472190b0b6743d6346c850bf
|
7
|
+
data.tar.gz: 348d398cb82ef41e15db7fcba68b46f4f3ca94029fe89c025c8e74e7a98493ef14f73994f95ce4cbadd887daecce44e720356c31247e51b235b99bf77641e33e
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
Layout/FirstHashElementIndentation:
|
2
|
+
Enabled: false
|
3
|
+
Layout/ArgumentAlignment:
|
4
|
+
Enabled: false
|
5
|
+
Layout/HashAlignment:
|
6
|
+
Enabled: false
|
7
|
+
Style/Documentation:
|
8
|
+
Enabled: false
|
9
|
+
Style/FrozenStringLiteralComment:
|
10
|
+
Enabled: false
|
11
|
+
Style/OptionalBooleanParameter:
|
12
|
+
Enabled: false
|
13
|
+
Style/MethodDefParentheses:
|
14
|
+
Enabled: true
|
15
|
+
Style/StringLiterals:
|
16
|
+
EnforcedStyle: double_quotes
|
17
|
+
Style/RescueStandardError:
|
18
|
+
EnforcedStyle: implicit
|
19
|
+
Naming/VariableNumber:
|
20
|
+
CheckSymbols: false
|
21
|
+
Style/VariableNumber:
|
22
|
+
Enabled: false
|
23
|
+
Style/HashSyntax:
|
24
|
+
EnforcedShorthandSyntax: never
|
25
|
+
Gemspec/RequiredRubyVersion:
|
26
|
+
Enabled: false
|
27
|
+
Style/WordArray:
|
28
|
+
Enabled: false
|
29
|
+
Style/SymbolArray:
|
30
|
+
Enabled: false
|
31
|
+
Lint/Debugger:
|
32
|
+
Enabled: false
|
33
|
+
Layout/MultilineMethodCallIndentation:
|
34
|
+
Enabled: false
|
35
|
+
Style/TrailingCommaInArguments:
|
36
|
+
EnforcedStyleForMultiline: comma
|
37
|
+
Layout/ArrayAlignment:
|
38
|
+
EnforcedStyle: with_fixed_indentation
|
39
|
+
Style/ClassVars:
|
40
|
+
Enabled: false
|
41
|
+
Metrics/BlockLength:
|
42
|
+
Max: 2000
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2023 Nathan Lopez
|
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,98 @@
|
|
1
|
+
# Integromat (Make) Ruby
|
2
|
+
|
3
|
+
<span>[](https://rubygems.org/gems/integromat-ruby)</span> <span>
|
4
|
+
[](https://github.com/andrewdsilva/integromat-ruby)</span> <span>
|
5
|
+
</span> <span>
|
6
|
+
[](http://opensource.org/licenses/MIT)</span> <span>
|
7
|
+
</span>
|
8
|
+
|
9
|
+
Integromat is a powerful automation platform that enables you to connect and automate various applications and services. One of the key features of Integromat is the ability to utilize webhooks, which allow you to send data to Integromat over HTTP. Webhooks act as instant triggers, allowing you to execute scenarios immediately upon receiving a request at the webhook URL.
|
10
|
+
|
11
|
+
Integromat-Ruby is a lightweight Ruby gem that simplifies the process of triggering Integromat webhooks from any Ruby application. With just a few lines of code, you can seamlessly integrate your Ruby app with Integromat and automate various tasks.
|
12
|
+
|
13
|
+
To start using Integromat-Ruby, you'll need an Integromat account and a created webhook. If you're new to Integromat, don't worry – setting up an account and creating a webhook is straightforward and well-documented on the Integromat website (https://make.com). Once you have your Integromat account and webhook ready, you're all set to integrate it with your Ruby application.
|
14
|
+
|
15
|
+
- [Sign up for Integromat (Make)](https://www.make.com/en/register)
|
16
|
+
- [Webhooks Documentation](https://www.integromat.com/en/help/app/webhooks)
|
17
|
+
|
18
|
+
## Installation
|
19
|
+
|
20
|
+
To install the gem add it into a Gemfile (Bundler):
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
gem "integromat"
|
24
|
+
```
|
25
|
+
|
26
|
+
And then execute:
|
27
|
+
|
28
|
+
```
|
29
|
+
bundle install
|
30
|
+
```
|
31
|
+
|
32
|
+
## Usage
|
33
|
+
|
34
|
+
To use integromat, start by configuring it with a hash of the webhooks you want to integrate. You can also customize the base URI.
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
require "integromat"
|
38
|
+
|
39
|
+
Integromat.configure do |c|
|
40
|
+
c.web_hooks = { user_register: "webhook_id" }
|
41
|
+
|
42
|
+
# Override the base URI
|
43
|
+
c.base_uri = "https://hook.eu2.make.com"
|
44
|
+
end
|
45
|
+
```
|
46
|
+
|
47
|
+
To obtain the base URL and hook ID, please look at the webhook URL you created in the Integromat application (Make).
|
48
|
+
|
49
|
+

|
50
|
+
|
51
|
+
Create an instance of `Webhook` for the desired hook, and use the `trigger` method to send a hash of parameters to the Integromat (Make) webhook. The `trigger` method returns `true` if the hook is successfully posted.
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
hook = Integromat::Webhook.new(:user_register)
|
55
|
+
|
56
|
+
if hook.trigger({ username: "andrewdsilva" })
|
57
|
+
pp "Hook triggered !"
|
58
|
+
else
|
59
|
+
pp "Hook not triggered !"
|
60
|
+
end
|
61
|
+
```
|
62
|
+
|
63
|
+
## Use Integromat on your Rails application
|
64
|
+
|
65
|
+
If you are using Integromat with Rails, I recommend creating an initializer file (e.g., `config/initializers/integromat.rb`) and adding the following code:
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
Integromat.configure do |c|
|
69
|
+
c.web_hooks = { user_register: "webhook_id" }
|
70
|
+
|
71
|
+
# Override the base URI
|
72
|
+
c.base_uri = "https://hook.eu2.make.com"
|
73
|
+
end
|
74
|
+
```
|
75
|
+
|
76
|
+
### Example
|
77
|
+
|
78
|
+
Suppose you want to call the webhook every time a user signs up for your application. You can use the `trigger` method from the Integromat gem within a callback on your `User` model.
|
79
|
+
|
80
|
+
```ruby
|
81
|
+
class User < ApplicationRecord
|
82
|
+
after_create :notify_registration
|
83
|
+
|
84
|
+
def notify_registration
|
85
|
+
Integromat::Webhook.new(:user_registration).trigger(email: email)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
```
|
89
|
+
|
90
|
+
This code sets up an `after_create` callback on the `User` model, which calls the `notify_registration` method. Inside this method, the `Integromat::Webhook.new(:user_registration)` creates a new webhook instance for the "user_registration" hook. The `trigger` method is then used to ping the webhook.
|
91
|
+
|
92
|
+
## Contributing
|
93
|
+
|
94
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/andrewdsilva/integromat-ruby.
|
95
|
+
|
96
|
+
## License
|
97
|
+
|
98
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
Binary file
|
data/integromat.gemspec
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/integromat/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "integromat"
|
7
|
+
spec.version = Integromat::VERSION
|
8
|
+
spec.authors = ["Nathan Lopez"]
|
9
|
+
spec.email = ["nathan.lopez042@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "A simple solution for integrating Integromat (Make) webhooks into your Ruby applications."
|
12
|
+
spec.description = "Integromat is a powerful automation platform that enables you to connect and automate various " \
|
13
|
+
"applications and services. One of the key features of Integromat is the ability to utilize webhooks, which " \
|
14
|
+
"allow you to send data to Integromat over HTTP. Webhooks act as instant triggers, allowing you to execute " \
|
15
|
+
"scenarios immediately upon receiving a request at the webhook URL.\n\n" \
|
16
|
+
"Integromat-Ruby is a lightweight Ruby gem that simplifies the process of triggering Integromat webhooks from " \
|
17
|
+
"any Ruby application. With just a few lines of code, you can seamlessly integrate your Ruby app with Integromat " \
|
18
|
+
"and automate various tasks."
|
19
|
+
spec.homepage = "https://github.com/andrewdsilva/integromat-ruby"
|
20
|
+
spec.license = "MIT"
|
21
|
+
spec.required_ruby_version = ">= 2.6.0"
|
22
|
+
|
23
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
24
|
+
spec.metadata["source_code_uri"] = "https://github.com/andrewdsilva/integromat-ruby"
|
25
|
+
|
26
|
+
# Specify which files should be added to the gem when it is released.
|
27
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
28
|
+
spec.files = Dir.chdir(__dir__) do
|
29
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
30
|
+
(File.expand_path(f) == __FILE__) ||
|
31
|
+
f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor Gemfile])
|
32
|
+
end
|
33
|
+
end
|
34
|
+
spec.bindir = "exe"
|
35
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
36
|
+
spec.require_paths = ["lib"]
|
37
|
+
|
38
|
+
spec.add_dependency "faraday"
|
39
|
+
|
40
|
+
spec.add_development_dependency "webmock"
|
41
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "faraday"
|
2
|
+
|
3
|
+
module Integromat
|
4
|
+
class Base
|
5
|
+
def post_hook(data)
|
6
|
+
api.post(hook_path, data)
|
7
|
+
end
|
8
|
+
|
9
|
+
def web_hook_id
|
10
|
+
@web_hook_id ||= config.web_hooks[hook_ref]
|
11
|
+
end
|
12
|
+
|
13
|
+
def api
|
14
|
+
@api ||= ::Faraday.new(url: api_url) do |faraday|
|
15
|
+
faraday.request :json
|
16
|
+
faraday.response :logger, ::Logger.new($stdout), bodies: true
|
17
|
+
faraday.adapter ::Faraday.default_adapter
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def api_url
|
22
|
+
config.base_uri.to_s
|
23
|
+
end
|
24
|
+
|
25
|
+
def hook_path
|
26
|
+
"/#{web_hook_id}"
|
27
|
+
end
|
28
|
+
|
29
|
+
def config
|
30
|
+
Integromat.config
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Integromat
|
2
|
+
class Webhook < Base
|
3
|
+
attr_accessor :hook_ref
|
4
|
+
|
5
|
+
def initialize(hook_ref, hook_id = nil)
|
6
|
+
super()
|
7
|
+
|
8
|
+
self.hook_ref = hook_ref
|
9
|
+
|
10
|
+
@web_hook_id = hook_id if hook_id
|
11
|
+
end
|
12
|
+
|
13
|
+
def trigger(data = {})
|
14
|
+
unless web_hook_id
|
15
|
+
raise IntegromatMisConfiguration, "No hook configured for #{hook_ref}. Configured hooks: #{config.web_hooks}"
|
16
|
+
end
|
17
|
+
|
18
|
+
post_hook(data)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/integromat.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "integromat/version"
|
4
|
+
require "integromat/exceptions"
|
5
|
+
require "integromat/config"
|
6
|
+
require "integromat/base"
|
7
|
+
require "integromat/webhook"
|
8
|
+
|
9
|
+
module Integromat
|
10
|
+
class << self
|
11
|
+
attr_accessor :config
|
12
|
+
end
|
13
|
+
|
14
|
+
class Error < StandardError; end
|
15
|
+
|
16
|
+
def self.configure
|
17
|
+
self.config ||= Integromat::Config.new
|
18
|
+
yield(config) if block_given?
|
19
|
+
end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: integromat
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nathan Lopez
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-06-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: webmock
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: |-
|
42
|
+
Integromat is a powerful automation platform that enables you to connect and automate various applications and services. One of the key features of Integromat is the ability to utilize webhooks, which allow you to send data to Integromat over HTTP. Webhooks act as instant triggers, allowing you to execute scenarios immediately upon receiving a request at the webhook URL.
|
43
|
+
|
44
|
+
Integromat-Ruby is a lightweight Ruby gem that simplifies the process of triggering Integromat webhooks from any Ruby application. With just a few lines of code, you can seamlessly integrate your Ruby app with Integromat and automate various tasks.
|
45
|
+
email:
|
46
|
+
- nathan.lopez042@gmail.com
|
47
|
+
executables: []
|
48
|
+
extensions: []
|
49
|
+
extra_rdoc_files: []
|
50
|
+
files:
|
51
|
+
- ".rspec"
|
52
|
+
- ".rubocop.yml"
|
53
|
+
- LICENSE.txt
|
54
|
+
- README.md
|
55
|
+
- Rakefile
|
56
|
+
- images/make-screenshot.png
|
57
|
+
- integromat.gemspec
|
58
|
+
- lib/integromat.rb
|
59
|
+
- lib/integromat/base.rb
|
60
|
+
- lib/integromat/config.rb
|
61
|
+
- lib/integromat/exceptions.rb
|
62
|
+
- lib/integromat/version.rb
|
63
|
+
- lib/integromat/webhook.rb
|
64
|
+
homepage: https://github.com/andrewdsilva/integromat-ruby
|
65
|
+
licenses:
|
66
|
+
- MIT
|
67
|
+
metadata:
|
68
|
+
homepage_uri: https://github.com/andrewdsilva/integromat-ruby
|
69
|
+
source_code_uri: https://github.com/andrewdsilva/integromat-ruby
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options: []
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 2.6.0
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
requirements: []
|
85
|
+
rubygems_version: 3.4.14
|
86
|
+
signing_key:
|
87
|
+
specification_version: 4
|
88
|
+
summary: A simple solution for integrating Integromat (Make) webhooks into your Ruby
|
89
|
+
applications.
|
90
|
+
test_files: []
|