enveloop 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 94446b08f6c486bdbc018ee236d7a6df30e2fb2bbbaac772a28234378c993153
4
- data.tar.gz: d389312fe9a5adf7f2beb313501ada0fc80b42ef3b6c98e36b4b2a93c61bb28a
3
+ metadata.gz: 596fdbbb2ebc6cc7b533c13225b7d3b9230dcf272a075348c845e8c57326dc33
4
+ data.tar.gz: 950931ce5bbc9c41b4ed9cea7551b33af8ddef4b4d13886163a5cb2f99208520
5
5
  SHA512:
6
- metadata.gz: 20034589bd1a305bcfc42a5938ed4c9d35fc8fc246fed35e7616a30c49a3f7e1f65213aaccbd16cce5d85ce46fa02bb9ab587e34391734c0a5dc0a6d8f3aa09a
7
- data.tar.gz: 9060749ef67da1136deefcac4e95692048b98633dce81450be293338c107729af7f58c59abdb410defa6803954b50e35030ff64c9105570af63c2b8319597d9c
6
+ metadata.gz: 8168eb794ad27972124baf57e0f0d68041a01f640b2a3477aef89aa05aa4ee3838aab33ddd99a37f29c03679476b30fcf42fa2d992ba470acf6ecc24deadb720
7
+ data.tar.gz: b84e89cec6e6dcc54411a6bbf090274b6e1fbd7471a3a820aaa4be496946a41877144b92e7026f7655baac42019d11d00dc6b877b2993b994bbd8a359378e88b
data/CHANGELOG.md CHANGED
@@ -3,4 +3,12 @@
3
3
  > ## Version 0.1.0
4
4
  > Initial Release.
5
5
 
6
- * Adds support for sending emails
6
+ * Adds support for sending emails
7
+
8
+ > ## Version 0.1.1
9
+
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
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- enveloop (0.1.0)
4
+ enveloop (0.1.2)
5
5
  faraday
6
6
 
7
7
  GEM
@@ -26,7 +26,7 @@ GEM
26
26
  diff-lcs (>= 1.2.0, < 2.0)
27
27
  rspec-support (~> 3.10.0)
28
28
  rspec-support (3.10.2)
29
- ruby2_keywords (0.0.2)
29
+ ruby2_keywords (0.0.4)
30
30
 
31
31
  PLATFORMS
32
32
  ruby
data/README.md CHANGED
@@ -20,6 +20,8 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
+ SEnd a message:
24
+
23
25
  ```ruby
24
26
  require 'enveloop'
25
27
 
@@ -36,6 +38,16 @@ enveloop.send_message(
36
38
  )
37
39
  ```
38
40
 
41
+ Get information about a template (variables and body html):
42
+
43
+ ```ruby
44
+ require 'enveloop'
45
+
46
+ enveloop = Enveloop::Client.new(api_key: ENV['ENVELOOP_API_TOKEN'])
47
+
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/[USERNAME]/enveloop. 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]/enveloop/blob/master/CODE_OF_CONDUCT.md).
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/[USERNAME]/enveloop/blob/master/CODE_OF_CONDUCT.md).
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).
@@ -21,9 +21,25 @@ module Enveloop
21
21
  }
22
22
  )
23
23
 
24
- conn.post("/templates/#{template}") do |req|
24
+ response = conn.post("/templates/#{template}") do |req|
25
25
  req.body = data.to_json
26
26
  end
27
+
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)
27
43
  end
28
44
  end
29
45
  end
@@ -0,0 +1,21 @@
1
+ module Enveloop
2
+ class MessageResponse
3
+ attr_reader :status, :message, :error
4
+
5
+ def initialize(status: 200, body: nil)
6
+ @status = status
7
+
8
+ if status == 200
9
+ @message = 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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Enveloop
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/enveloop.rb CHANGED
@@ -1,9 +1,10 @@
1
- require "enveloop/version"
2
-
3
1
  require "faraday"
4
2
  require "json"
5
3
 
4
+ require "enveloop/version"
6
5
  require 'enveloop/client'
6
+ require 'enveloop/message_response'
7
+ require 'enveloop/template_response'
7
8
 
8
9
  module Enveloop
9
10
  class Error < StandardError; end
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.0
4
+ version: 0.1.2
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-06 00:00:00.000000000 Z
11
+ date: 2022-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -45,6 +45,8 @@ files:
45
45
  - enveloop.gemspec
46
46
  - lib/enveloop.rb
47
47
  - lib/enveloop/client.rb
48
+ - lib/enveloop/message_response.rb
49
+ - lib/enveloop/template_response.rb
48
50
  - lib/enveloop/version.rb
49
51
  homepage: https://github.com/enveloophq/ruby_enveloop
50
52
  licenses: