zapier_ruby 0.0.5 → 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 +5 -13
- data/README.md +6 -5
- data/lib/zapier_ruby/exceptions.rb +4 -0
- data/lib/zapier_ruby/version.rb +1 -1
- data/lib/zapier_ruby/zapper.rb +8 -18
- data/lib/zapier_ruby.rb +1 -0
- metadata +14 -13
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
YmI4NjM1MDZmZTY2ZmQ4ZDZlNGI2NmFmZDQzYTk4YjQ2MDUwMzI2ZQ==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 64ee8a52462c391b2ae4e762c1eb48142bde9a25
|
4
|
+
data.tar.gz: acad89ed413fd4c5d22424a634903643b14bcf87
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
Yzk0ODY1NTQ5YWQyNjM0YmI1NzhjZTYyMWM4MjNkZjk0NGZkMDQyODljY2Iw
|
11
|
-
ZjUwZWE3NmFjZGJlNGVjN2E2ZjE4MDU4NTBlZmMyMmZlM2U3ZWM=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
Njc1NzNkZDQ1MDJlODRlNTczYjMwMDU2NjlmNzQ4ODZhMzk0Y2ZhYjFhZWM2
|
14
|
-
YmIxNGQ0Yjg1YzJiNzM4NTM4YWE2MzUwNjAwMDQ4NTFkMGM5Y2U2NDlmYzQ0
|
15
|
-
ODU0N2ZhNTFiMjU5YTg4NzkxNTZhODIyN2JlMzQ1ZWJkY2FlYzE=
|
6
|
+
metadata.gz: cc852fac149dc930ff418d65c5d93569fa7935073d1cf396a93b80377ad4183d6ef6809e25a1854e6f01df12af00484f7319b7c4af3491002519f12e84c4468e
|
7
|
+
data.tar.gz: ad2b35483dade455b2cda12b7db419b70b339cd0feffa6e3b6e9a045ff25ea21ec0a6b9237077e617e055f1ea9e1a7e3ddaadb0e1673e50a994caf27bbf79b5a
|
data/README.md
CHANGED
@@ -25,7 +25,7 @@ Or install it yourself as:
|
|
25
25
|
### General Usage
|
26
26
|
First, configure ZapierRuby. Pass a hash of each of your zap webhooks you would like to integrate, you can also change the uri we post to or disable logging. Next, Instantiate a Zapper for the webhook to hit. Then, use the `zap` method with hash of params and send it to the Zapier web hook. `zap` returns true if it is able to successfully post the zap.
|
27
27
|
|
28
|
-
```
|
28
|
+
```ruby
|
29
29
|
require 'rubygems'
|
30
30
|
require 'zapier_ruby'
|
31
31
|
|
@@ -53,7 +53,7 @@ Each param you send can be used by Zapier, so include all of the information req
|
|
53
53
|
### Rails Usage
|
54
54
|
If you are using ZapierRuby with Rails, I'd recommend using creating an initializer (ex. config/intializers/zapier_ruby.rb) and with the following:
|
55
55
|
|
56
|
-
```
|
56
|
+
```ruby
|
57
57
|
ZapierRuby.configure do |c|
|
58
58
|
c.web_hooks = {example_zap: "zap_webhook_id"}
|
59
59
|
end
|
@@ -62,7 +62,7 @@ end
|
|
62
62
|
### Command Line Usage ###
|
63
63
|
To use this gem from the command line, you can leverage the `bin/zap` Ruby executable. In order to use this gem via command line, you must execute the gem in a folder which has a `.zapier_ruby.yml` file to configure your zaps. An example `.zapier_ruby.yml` file follows:
|
64
64
|
|
65
|
-
```
|
65
|
+
```yaml
|
66
66
|
web_hooks:
|
67
67
|
:example_zap: "xxxxxx"
|
68
68
|
enable_logging: false
|
@@ -78,7 +78,8 @@ Which will post {Message: "Hello, world"} to your web hook. The zap name must be
|
|
78
78
|
#### Example Usage
|
79
79
|
|
80
80
|
If you do not have email configured for you application, you could send an email via a Zap to notify a new user that their account has been created.
|
81
|
-
|
81
|
+
|
82
|
+
```ruby
|
82
83
|
class User < ActiveRecord::Base
|
83
84
|
after_create :welcome_new_user
|
84
85
|
|
@@ -91,7 +92,7 @@ end
|
|
91
92
|
|
92
93
|
## Contributing
|
93
94
|
|
94
|
-
1. Fork it ( https://github.com/
|
95
|
+
1. Fork it ( https://github.com/pete2786/zapier_ruby/fork )
|
95
96
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
96
97
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
97
98
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/lib/zapier_ruby/version.rb
CHANGED
data/lib/zapier_ruby/zapper.rb
CHANGED
@@ -10,34 +10,27 @@ module ZapierRuby
|
|
10
10
|
|
11
11
|
def zap(params={})
|
12
12
|
unless zap_web_hook_id
|
13
|
-
|
14
|
-
return false
|
13
|
+
raise ZapierMisConfiguration, "No zap configured for #{zap_name}. Configured webhooks: #{config.web_hooks.to_s}"
|
15
14
|
end
|
16
15
|
|
17
|
-
logger.
|
16
|
+
logger.debug "Zapping #{zap_name} with params: #{params.to_s}"
|
18
17
|
post_zap(params)
|
19
18
|
end
|
20
19
|
|
20
|
+
private
|
21
|
+
|
21
22
|
def post_zap(params)
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
rescue StandardError => e
|
26
|
-
logger.error "Unable to post to Zapier url: #{zap_url} with params: #{params.to_s}. Error: #{e.message}"
|
27
|
-
false
|
28
|
-
end
|
23
|
+
rest_client.post(params, zap_headers)
|
24
|
+
rescue RestClient::ExceptionWithResponse => err
|
25
|
+
raise ZapierServerError, err
|
29
26
|
end
|
30
|
-
private :post_zap
|
31
27
|
|
32
28
|
def rest_client
|
33
29
|
@rest_client ||= RestClient::Resource.new(zap_url, ssl_version: 'TLSv1')
|
34
30
|
end
|
35
|
-
private :rest_client
|
36
31
|
|
37
32
|
def zap_web_hook_id
|
38
|
-
|
39
|
-
|
40
|
-
@zap_web_hook = config.web_hooks[zap_name]
|
33
|
+
@zap_web_hook ||= config.web_hooks[zap_name]
|
41
34
|
end
|
42
35
|
private :zap_web_hook_id
|
43
36
|
|
@@ -47,16 +40,13 @@ module ZapierRuby
|
|
47
40
|
"Content-Type" => "application/json"
|
48
41
|
}
|
49
42
|
end
|
50
|
-
private :zap_headers
|
51
43
|
|
52
44
|
def zap_url
|
53
45
|
"#{config.base_uri}#{zap_web_hook_id}/"
|
54
46
|
end
|
55
|
-
private :zap_url
|
56
47
|
|
57
48
|
def config
|
58
49
|
ZapierRuby.config
|
59
50
|
end
|
60
|
-
private :config
|
61
51
|
end
|
62
52
|
end
|
data/lib/zapier_ruby.rb
CHANGED
metadata
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zapier_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Peterson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.7'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.7'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '10.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '10.0'
|
55
55
|
description: Simple gem to integrate Zapier webhooks with a Ruby project.
|
@@ -60,8 +60,8 @@ executables:
|
|
60
60
|
extensions: []
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
|
-
- .gitignore
|
64
|
-
- .zapier_ruby.yml.example
|
63
|
+
- ".gitignore"
|
64
|
+
- ".zapier_ruby.yml.example"
|
65
65
|
- Gemfile
|
66
66
|
- LICENSE.txt
|
67
67
|
- README.md
|
@@ -69,6 +69,7 @@ files:
|
|
69
69
|
- bin/zap
|
70
70
|
- lib/zapier_ruby.rb
|
71
71
|
- lib/zapier_ruby/config.rb
|
72
|
+
- lib/zapier_ruby/exceptions.rb
|
72
73
|
- lib/zapier_ruby/logger_decorator.rb
|
73
74
|
- lib/zapier_ruby/version.rb
|
74
75
|
- lib/zapier_ruby/zapper.rb
|
@@ -83,17 +84,17 @@ require_paths:
|
|
83
84
|
- lib
|
84
85
|
required_ruby_version: !ruby/object:Gem::Requirement
|
85
86
|
requirements:
|
86
|
-
- -
|
87
|
+
- - ">="
|
87
88
|
- !ruby/object:Gem::Version
|
88
89
|
version: '0'
|
89
90
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
91
|
requirements:
|
91
|
-
- -
|
92
|
+
- - ">="
|
92
93
|
- !ruby/object:Gem::Version
|
93
94
|
version: '0'
|
94
95
|
requirements: []
|
95
96
|
rubyforge_project:
|
96
|
-
rubygems_version: 2.
|
97
|
+
rubygems_version: 2.4.8
|
97
98
|
signing_key:
|
98
99
|
specification_version: 4
|
99
100
|
summary: Simple gem to integrate Zapier webhooks with a Ruby project.
|