resend 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -14
- data/lib/resend/errors.rb +4 -1
- data/lib/resend/mailer.rb +2 -4
- data/lib/resend/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 154948a83edaf33d2c541d663519984ce81c88de1dfdce855d6a57b495841e19
|
4
|
+
data.tar.gz: 77ff14940114642d5099134f4c9ea7eb6a504f9c2f088f208b3492df0238d481
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e4b18829fce8858425ed271eb6608e72ee00e66391d2530e868503389c66e05acb4f65d92f0ca0454abb01c40e2d58742907d628d230bc47d37f0da863290cf
|
7
|
+
data.tar.gz: ddc74f6a84b63ffc26914d1230b697d04759cea952c14d3e7ec6a8743267850532303eb8260fa7db19e215bc8253b1dfa93f57a8e693e4d8121953721e8e7734
|
data/README.md
CHANGED
@@ -16,7 +16,7 @@ gem install resend
|
|
16
16
|
|
17
17
|
Via Gemfile:
|
18
18
|
```
|
19
|
-
gem 'resend'
|
19
|
+
gem 'resend'
|
20
20
|
```
|
21
21
|
|
22
22
|
## Setup
|
@@ -59,13 +59,17 @@ You can view all the examples in the [examples folder](https://github.com/drish/
|
|
59
59
|
|
60
60
|
# Rails and ActiveMailer support
|
61
61
|
|
62
|
-
This gem can be used as an ActionMailer delivery method, add this to your `config/environments/environment.rb` file
|
62
|
+
This gem can be used as an ActionMailer delivery method, add this to your `config/environments/environment.rb` file.
|
63
63
|
|
64
64
|
```ruby
|
65
65
|
config.action_mailer.delivery_method = :resend
|
66
|
-
|
67
|
-
|
68
|
-
|
66
|
+
```
|
67
|
+
|
68
|
+
Create or update your mailer initializer file and replace the placeholder with your Resend API Key.
|
69
|
+
|
70
|
+
```rb
|
71
|
+
# /app/initializers/mailer.rb
|
72
|
+
Resend.api_key = "re_123456"
|
69
73
|
```
|
70
74
|
|
71
75
|
After that you can deliver_now!, example below:
|
@@ -87,12 +91,3 @@ mailer = UserMailer.with(user: u).welcome_email
|
|
87
91
|
mailer.deliver_now!
|
88
92
|
# => {:id=>"b8f94710-0d84-429c-925a-22d3d8f86916", from: 'you@yourdomain.io', to: ["example2@mail.com", "example1@mail.com"]}
|
89
93
|
```
|
90
|
-
|
91
|
-
This gem can also be initialized with a Rails initializer file, example below:
|
92
|
-
|
93
|
-
```ruby
|
94
|
-
# /app/initializers/mailer.rb
|
95
|
-
Resend.configure do |config|
|
96
|
-
config.api_key = 'resend_api_key'
|
97
|
-
end
|
98
|
-
```
|
data/lib/resend/errors.rb
CHANGED
@@ -4,7 +4,6 @@ module Resend
|
|
4
4
|
# Errors wrapper class
|
5
5
|
# For more info: https://resend.com/docs/api-reference/error-codes
|
6
6
|
class Error < StandardError
|
7
|
-
|
8
7
|
# 4xx HTTP status code
|
9
8
|
ClientError = Class.new(self)
|
10
9
|
|
@@ -17,6 +16,9 @@ module Resend
|
|
17
16
|
# code 422
|
18
17
|
InvalidRequestError = Class.new(ServerError)
|
19
18
|
|
19
|
+
# code 429
|
20
|
+
RateLimitExceededError = Class.new(ServerError)
|
21
|
+
|
20
22
|
# code 404
|
21
23
|
NotFoundError = Class.new(ServerError)
|
22
24
|
|
@@ -24,6 +26,7 @@ module Resend
|
|
24
26
|
401 => Resend::Error::InvalidRequestError,
|
25
27
|
404 => Resend::Error::InvalidRequestError,
|
26
28
|
422 => Resend::Error::InvalidRequestError,
|
29
|
+
429 => Resend::Error::RateLimitExceededError,
|
27
30
|
400 => Resend::Error::InvalidRequestError,
|
28
31
|
500 => Resend::Error::InternalServerError
|
29
32
|
}.freeze
|
data/lib/resend/mailer.rb
CHANGED
@@ -5,13 +5,11 @@ require "resend"
|
|
5
5
|
module Resend
|
6
6
|
# Mailer class used by railtie
|
7
7
|
class Mailer
|
8
|
-
attr_accessor :config
|
8
|
+
attr_accessor :config
|
9
9
|
|
10
10
|
def initialize(config)
|
11
11
|
@config = config
|
12
|
-
raise Resend::
|
13
|
-
|
14
|
-
@settings = { return_response: true } # avoids NilError exception
|
12
|
+
raise Resend::Error.new("Make sure your api is set", @config) unless Resend.api_key
|
15
13
|
end
|
16
14
|
|
17
15
|
def deliver!(mail)
|
data/lib/resend/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resend
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Derich Pacheco
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05
|
11
|
+
date: 2023-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -38,7 +38,7 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
description:
|
41
|
+
description:
|
42
42
|
email: carlosderich@gmail.com
|
43
43
|
executables: []
|
44
44
|
extensions: []
|
@@ -59,7 +59,7 @@ homepage: https://github.com/resendlabs/resend-ruby
|
|
59
59
|
licenses:
|
60
60
|
- MIT
|
61
61
|
metadata: {}
|
62
|
-
post_install_message:
|
62
|
+
post_install_message:
|
63
63
|
rdoc_options: []
|
64
64
|
require_paths:
|
65
65
|
- lib
|
@@ -74,8 +74,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
requirements: []
|
77
|
-
rubygems_version: 3.
|
78
|
-
signing_key:
|
77
|
+
rubygems_version: 3.0.3.1
|
78
|
+
signing_key:
|
79
79
|
specification_version: 4
|
80
80
|
summary: The Ruby and Rails SDK for resend.com
|
81
81
|
test_files: []
|