enveloop 0.1.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -1
- data/Gemfile.lock +1 -1
- data/README.md +15 -3
- data/lib/enveloop/client.rb +17 -3
- data/lib/enveloop/{response.rb → message_response.rb} +1 -4
- data/lib/enveloop/template_response.rb +21 -0
- data/lib/enveloop/version.rb +1 -1
- data/lib/enveloop.rb +2 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c04cdee8d0a0fc537a9270f9bbb29417eae1bb2c70edd2b6a9d9b985c50f91c
|
4
|
+
data.tar.gz: 730ad713a4258f0f418ed383006073f9a98e861258abd198b7c60ef5d15f5530
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80fe49dc8664b0317b9a7f6f81b603abcedbe38f89b3f8c444bc0cd73536ba06cc9740a02aa23b3e5b70c74af6dc3dc910c0d7a156f1f75841048f41eef90d24
|
7
|
+
data.tar.gz: db4ead56d96c4567ab983c99c34a65a7d659aff8b71ed8889631669e9a83e6372385fc93c43987dbb99345da415f608d0f20f3574c5705e2442a7ed4ac2d27e6
|
data/CHANGELOG.md
CHANGED
@@ -7,4 +7,12 @@
|
|
7
7
|
|
8
8
|
> ## Version 0.1.1
|
9
9
|
|
10
|
-
* Add Response class
|
10
|
+
* Add Response class
|
11
|
+
|
12
|
+
> ## Version 0.1.2
|
13
|
+
|
14
|
+
* add `template_info` to fetch the template body and see waht variables are defined on a template
|
15
|
+
|
16
|
+
> ## Version 0.1.3
|
17
|
+
|
18
|
+
* change `user_variables` to `template_variables` in API call
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -20,22 +20,34 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
+
Setup the client connection:
|
24
|
+
|
23
25
|
```ruby
|
24
26
|
require 'enveloop'
|
25
27
|
|
26
28
|
enveloop = Enveloop::Client.new(api_key: ENV['ENVELOOP_API_TOKEN'])
|
29
|
+
```
|
27
30
|
|
31
|
+
Send a message:
|
32
|
+
|
33
|
+
```ruby
|
28
34
|
enveloop.send_message(
|
29
35
|
template: 'welcome-email',
|
30
36
|
to: 'user@email.com',
|
31
37
|
from: 'welcome@myapp.com',
|
32
38
|
subject: 'Welcome to MyApp',
|
33
|
-
|
39
|
+
template_variables: {
|
34
40
|
first_name: 'John',
|
35
41
|
}
|
36
42
|
)
|
37
43
|
```
|
38
44
|
|
45
|
+
Get information about a template (variables and body html):
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
enveloop.template_info(template: 'welcome-email')
|
49
|
+
```
|
50
|
+
|
39
51
|
## Development
|
40
52
|
|
41
53
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -44,7 +56,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
44
56
|
|
45
57
|
## Contributing
|
46
58
|
|
47
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
59
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/enveloophq/enveloop-ruby. 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/enveloophq/enveloop-ruby/blob/master/CODE_OF_CONDUCT.md).
|
48
60
|
|
49
61
|
|
50
62
|
## License
|
@@ -53,4 +65,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
53
65
|
|
54
66
|
## Code of Conduct
|
55
67
|
|
56
|
-
Everyone interacting in the Enveloop project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
68
|
+
Everyone interacting in the Enveloop project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/enveloophq/enveloop-ruby/blob/master/CODE_OF_CONDUCT.md).
|
data/lib/enveloop/client.rb
CHANGED
@@ -5,12 +5,12 @@ module Enveloop
|
|
5
5
|
@api_key = api_key
|
6
6
|
end
|
7
7
|
|
8
|
-
def send_message(template:, to:, from:, subject:,
|
8
|
+
def send_message(template:, to:, from:, subject:, template_variables: {})
|
9
9
|
data = {
|
10
10
|
to: to,
|
11
11
|
from: from,
|
12
12
|
subject: subject,
|
13
|
-
|
13
|
+
templateVariables: template_variables
|
14
14
|
}
|
15
15
|
|
16
16
|
conn = Faraday.new(
|
@@ -25,7 +25,21 @@ module Enveloop
|
|
25
25
|
req.body = data.to_json
|
26
26
|
end
|
27
27
|
|
28
|
-
return
|
28
|
+
return MessageResponse.new(status: response.status, body: response.body)
|
29
|
+
end
|
30
|
+
|
31
|
+
def template_info(template:)
|
32
|
+
conn = Faraday.new(
|
33
|
+
url: @endpoint,
|
34
|
+
headers: {
|
35
|
+
"Content-Type" => "application/json",
|
36
|
+
"Authorization" => "token #{@api_key}"
|
37
|
+
}
|
38
|
+
)
|
39
|
+
|
40
|
+
response = conn.get("/templates/#{template}")
|
41
|
+
|
42
|
+
return TemplateResponse.new(status: response.status, body: response.body)
|
29
43
|
end
|
30
44
|
end
|
31
45
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Enveloop
|
2
|
-
class
|
2
|
+
class MessageResponse
|
3
3
|
attr_reader :status, :message, :error
|
4
4
|
|
5
5
|
def initialize(status: 200, body: nil)
|
@@ -7,12 +7,9 @@ module Enveloop
|
|
7
7
|
|
8
8
|
if status == 200
|
9
9
|
@message = JSON.parse(body)
|
10
|
-
@error = nil
|
11
10
|
elsif status == 500
|
12
|
-
@message = nil
|
13
11
|
@error = JSON.parse(body)['error']
|
14
12
|
else
|
15
|
-
@message = nil
|
16
13
|
@error = 'Unknown error'
|
17
14
|
end
|
18
15
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Enveloop
|
2
|
+
class TemplateResponse
|
3
|
+
attr_reader :status, :template, :error
|
4
|
+
|
5
|
+
def initialize(status: 200, body: nil)
|
6
|
+
@status = status
|
7
|
+
|
8
|
+
if status == 200
|
9
|
+
@template = JSON.parse(body)
|
10
|
+
elsif status == 500
|
11
|
+
@error = JSON.parse(body)['error']
|
12
|
+
else
|
13
|
+
@error = 'Unknown error'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def success?
|
18
|
+
@status == 200
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/enveloop/version.rb
CHANGED
data/lib/enveloop.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: enveloop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Wyrosdick
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
11
|
+
date: 2022-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -45,7 +45,8 @@ files:
|
|
45
45
|
- enveloop.gemspec
|
46
46
|
- lib/enveloop.rb
|
47
47
|
- lib/enveloop/client.rb
|
48
|
-
- lib/enveloop/
|
48
|
+
- lib/enveloop/message_response.rb
|
49
|
+
- lib/enveloop/template_response.rb
|
49
50
|
- lib/enveloop/version.rb
|
50
51
|
homepage: https://github.com/enveloophq/ruby_enveloop
|
51
52
|
licenses:
|