resend 0.15.0 → 0.16.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 +16 -1
- data/lib/resend/broadcasts.rb +41 -0
- data/lib/resend/client.rb +4 -3
- data/lib/resend/request.rb +4 -2
- data/lib/resend/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67fb549176718ac10025dad2b41cba2519de04a0890631950c4f2d022e6106f8
|
4
|
+
data.tar.gz: de3d5e59326e9ae9fdd1e5d4d0b507a147ecc95aa3ed6db918e4a5f40894d782
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77ae6d4b92169173fef0d18661de7e873fdb6c2e33291a0676a5a2ef622845bec3bfff815e63fda76ec6c5f8fb5f267df60b64fa62812544e100ceaa79bd916b
|
7
|
+
data.tar.gz: a2dbe3619bf9958234a96299909937de98a752fe61678fb8d0082d83ba845828ca12fdc593b92c52fffbf98dd9139db9283957a45659aa8b4aba2d4ae5582c9b
|
data/README.md
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
|
4
4
|
![Build](https://github.com/drish/resend-ruby/actions/workflows/build.yml/badge.svg)
|
5
5
|
[![Gem Version](https://badge.fury.io/rb/resend.svg)](https://badge.fury.io/rb/resend)
|
6
|
+
|
6
7
|
---
|
7
8
|
|
8
9
|
## Installation
|
@@ -10,11 +11,13 @@
|
|
10
11
|
To install Resend Ruby and Rails SDK, simply execute the following command in a terminal:
|
11
12
|
|
12
13
|
Via RubyGems:
|
14
|
+
|
13
15
|
```
|
14
16
|
gem install resend
|
15
17
|
```
|
16
18
|
|
17
19
|
Via Gemfile:
|
20
|
+
|
18
21
|
```
|
19
22
|
gem 'resend'
|
20
23
|
```
|
@@ -37,6 +40,19 @@ Resend.configure do |config|
|
|
37
40
|
end
|
38
41
|
```
|
39
42
|
|
43
|
+
The `#api_key` method also accepts a block without arguments, which can be useful for lazy or dynamic loading of API keys.
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
require "resend"
|
47
|
+
Resend.api_key = -> { ENV["RESEND_API_KEY"] }
|
48
|
+
```
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
Resend.configure do |config|
|
52
|
+
config.api_key = -> { Current.user.resend_api_key } # Assumes the user has a `resend_api_key` attribute.
|
53
|
+
end
|
54
|
+
```
|
55
|
+
|
40
56
|
## Example
|
41
57
|
|
42
58
|
```rb
|
@@ -56,7 +72,6 @@ puts r
|
|
56
72
|
|
57
73
|
You can view all the examples in the [examples folder](https://github.com/drish/resend-ruby/tree/main/examples)
|
58
74
|
|
59
|
-
|
60
75
|
# Rails and ActiveMailer support
|
61
76
|
|
62
77
|
This gem can be used as an ActionMailer delivery method, add this to your `config/environments/environment.rb` file.
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "resend/request"
|
4
|
+
require "resend/errors"
|
5
|
+
|
6
|
+
module Resend
|
7
|
+
# broadcasts api wrapper
|
8
|
+
module Broadcasts
|
9
|
+
class << self
|
10
|
+
# https://resend.com/docs/api-reference/broadcasts/create-broadcast
|
11
|
+
def create(params = {})
|
12
|
+
path = "broadcasts"
|
13
|
+
Resend::Request.new(path, params, "post").perform
|
14
|
+
end
|
15
|
+
|
16
|
+
# https://resend.com/docs/api-reference/broadcasts/send-broadcast
|
17
|
+
def send(params = {})
|
18
|
+
path = "broadcasts/#{params[:broadcast_id]}/send"
|
19
|
+
Resend::Request.new(path, params, "post").perform
|
20
|
+
end
|
21
|
+
|
22
|
+
# https://resend.com/docs/api-reference/broadcasts/list-broadcasts
|
23
|
+
def list
|
24
|
+
path = "broadcasts"
|
25
|
+
Resend::Request.new(path, {}, "get").perform
|
26
|
+
end
|
27
|
+
|
28
|
+
# https://resend.com/docs/api-reference/broadcasts/delete-broadcast
|
29
|
+
def remove(broadcast_id = "")
|
30
|
+
path = "broadcasts/#{broadcast_id}"
|
31
|
+
Resend::Request.new(path, {}, "delete").perform
|
32
|
+
end
|
33
|
+
|
34
|
+
# https://resend.com/docs/api-reference/broadcasts/get-broadcast
|
35
|
+
def get(broadcast_id = "")
|
36
|
+
path = "broadcasts/#{broadcast_id}"
|
37
|
+
Resend::Request.new(path, {}, "get").perform
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/resend/client.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "resend/audiences"
|
3
4
|
require "resend/api_keys"
|
4
|
-
require "resend/
|
5
|
-
require "resend/emails"
|
5
|
+
require "resend/broadcasts"
|
6
6
|
require "resend/batch"
|
7
|
-
require "resend/audiences"
|
8
7
|
require "resend/contacts"
|
8
|
+
require "resend/domains"
|
9
|
+
require "resend/emails"
|
9
10
|
require "httparty"
|
10
11
|
|
11
12
|
module Resend
|
data/lib/resend/request.rb
CHANGED
@@ -13,7 +13,9 @@ module Resend
|
|
13
13
|
attr_accessor :body, :verb
|
14
14
|
|
15
15
|
def initialize(path = "", body = {}, verb = "POST")
|
16
|
-
raise if Resend.api_key.nil?
|
16
|
+
raise if (api_key = Resend.api_key).nil?
|
17
|
+
|
18
|
+
api_key = api_key.call if api_key.is_a?(Proc)
|
17
19
|
|
18
20
|
@path = path
|
19
21
|
@body = body
|
@@ -22,7 +24,7 @@ module Resend
|
|
22
24
|
"Content-Type" => "application/json",
|
23
25
|
"Accept" => "application/json",
|
24
26
|
"User-Agent" => "resend-ruby:#{Resend::VERSION}",
|
25
|
-
"Authorization" => "Bearer #{
|
27
|
+
"Authorization" => "Bearer #{api_key}"
|
26
28
|
}
|
27
29
|
end
|
28
30
|
|
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.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Derich Pacheco
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-12-
|
11
|
+
date: 2024-12-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -49,6 +49,7 @@ files:
|
|
49
49
|
- lib/resend/api_keys.rb
|
50
50
|
- lib/resend/audiences.rb
|
51
51
|
- lib/resend/batch.rb
|
52
|
+
- lib/resend/broadcasts.rb
|
52
53
|
- lib/resend/client.rb
|
53
54
|
- lib/resend/contacts.rb
|
54
55
|
- lib/resend/domains.rb
|