resend 0.8.1 → 0.10.0

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: 5ae724c793986df189b1a738270053248ad78f745e975a0f1a1e58528c6c8410
4
- data.tar.gz: 19742a50f1edaa6eafa82dbdcaec37251f633aff382015c3323dd879aa2bbd8d
3
+ metadata.gz: 35de3e6d5edf8d140f5fddb77a69d05dfefdea65dc12381cb5003803d3002f31
4
+ data.tar.gz: 9153eece684f2609927d3123090bbd114eea09f54c6a0e349c360fe0520a4d1b
5
5
  SHA512:
6
- metadata.gz: 7062c7c0b3ab835da568bb044ab34f0bb65e194fb078783d7ac29e922a827f1cbea09ef7c264a57c6ca0ad48727e9270470e4216bd449605c7cf8dd55e1762b5
7
- data.tar.gz: 618a35f3eb6b049bb3ae0d7b5d5cbda78d28a2d2c617f0718098ce41f030fd2a1c5023660366a2dad9cfafdb309ab77ae17bba0131419637637bd2687df13fca
6
+ metadata.gz: 56c8c0d8f4195508bf4b2c116bc8c03d6bfbbc1d81f78dab030e781250f2bd932ccb276101ae333ce76abefa492478cb7465d194e0df39904eb5730fb87303cf
7
+ data.tar.gz: fd271dc660f9c775a1d820798450ed8a24c1bddc57fdc32ddfedef2395e7d80cfe1e72cca2dc6d6cd1d4e81a8402177451d5ec90700e0fd1aceebe3e89251fd9
data/README.md CHANGED
@@ -68,7 +68,7 @@ config.action_mailer.delivery_method = :resend
68
68
  Create or update your mailer initializer file and replace the placeholder with your Resend API Key.
69
69
 
70
70
  ```rb
71
- # /app/initializers/mailer.rb
71
+ # /config/initializers/resend.rb
72
72
  Resend.api_key = "re_123456"
73
73
  ```
74
74
 
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "resend/request"
4
+ require "resend/errors"
5
+
6
+ module Resend
7
+ # Audiences api wrapper
8
+ module Audiences
9
+ class << self
10
+ # https://resend.com/docs/api-reference/audiences/create-audience
11
+ def create(params)
12
+ path = "audiences"
13
+ Resend::Request.new(path, params, "post").perform
14
+ end
15
+
16
+ # https://resend.com/docs/api-reference/audiences/get-audience
17
+ def get(audience_id = "")
18
+ path = "audiences/#{audience_id}"
19
+ Resend::Request.new(path, {}, "get").perform
20
+ end
21
+
22
+ # https://resend.com/docs/api-reference/audiences/list-audiences
23
+ def list
24
+ path = "audiences"
25
+ Resend::Request.new(path, {}, "get").perform
26
+ end
27
+
28
+ # https://resend.com/docs/api-reference/audiences/delete-audience
29
+ def remove(audience_id = "")
30
+ path = "audiences/#{audience_id}"
31
+ Resend::Request.new(path, {}, "delete").perform
32
+ end
33
+ end
34
+ end
35
+ end
data/lib/resend/client.rb CHANGED
@@ -4,6 +4,8 @@ require "resend/api_keys"
4
4
  require "resend/domains"
5
5
  require "resend/emails"
6
6
  require "resend/batch"
7
+ require "resend/audiences"
8
+ require "resend/contacts"
7
9
  require "httparty"
8
10
 
9
11
  module Resend
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "resend/request"
4
+ require "resend/errors"
5
+
6
+ module Resend
7
+ # Contacts api wrapper
8
+ module Contacts
9
+ class << self
10
+ # https://resend.com/docs/api-reference/contacts/create-contact
11
+ def create(params)
12
+ path = "audiences/#{params[:audience_id]}/contacts"
13
+ Resend::Request.new(path, params, "post").perform
14
+ end
15
+
16
+ # https://resend.com/docs/api-reference/contacts/get-contact
17
+ def get(audience_id, id)
18
+ path = "audiences/#{audience_id}/contacts/#{id}"
19
+ Resend::Request.new(path, {}, "get").perform
20
+ end
21
+
22
+ # https://resend.com/docs/api-reference/contacts/list-contacts
23
+ def list(audience_id)
24
+ path = "audiences/#{audience_id}/contacts"
25
+ Resend::Request.new(path, {}, "get").perform
26
+ end
27
+
28
+ #
29
+ # Remove a contact from an audience
30
+ #
31
+ # @param audience_id [String] the audience id
32
+ # @param contact_id [String] either the contact id or contact email
33
+ #
34
+ # see also: https://resend.com/docs/api-reference/contacts/delete-contact
35
+ def remove(audience_id, contact_id)
36
+ path = "audiences/#{audience_id}/contacts/#{contact_id}"
37
+ Resend::Request.new(path, {}, "delete").perform
38
+ end
39
+
40
+ # https://resend.com/docs/api-reference/contacts/update-contact
41
+ def update(params)
42
+ path = "audiences/#{params[:audience_id]}/contacts/#{params[:id]}"
43
+ Resend::Request.new(path, params, "patch").perform
44
+ end
45
+ end
46
+ end
47
+ end
@@ -8,7 +8,7 @@ module Resend
8
8
  # This class is responsible for making the appropriate HTTP calls
9
9
  # and raising the specific errors based on the response.
10
10
  class Request
11
- BASE_URL = "https://api.resend.com/"
11
+ BASE_URL = ENV["RESEND_BASE_URL"] || "https://api.resend.com/"
12
12
 
13
13
  attr_accessor :body, :verb
14
14
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Resend
4
- VERSION = "0.8.1"
4
+ VERSION = "0.10.0"
5
5
  end
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.8.1
4
+ version: 0.10.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: 2023-12-14 00:00:00.000000000 Z
11
+ date: 2024-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -47,8 +47,10 @@ files:
47
47
  - README.md
48
48
  - lib/resend.rb
49
49
  - lib/resend/api_keys.rb
50
+ - lib/resend/audiences.rb
50
51
  - lib/resend/batch.rb
51
52
  - lib/resend/client.rb
53
+ - lib/resend/contacts.rb
52
54
  - lib/resend/domains.rb
53
55
  - lib/resend/emails.rb
54
56
  - lib/resend/errors.rb
@@ -75,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
77
  - !ruby/object:Gem::Version
76
78
  version: '0'
77
79
  requirements: []
78
- rubygems_version: 3.3.7
80
+ rubygems_version: 3.4.10
79
81
  signing_key:
80
82
  specification_version: 4
81
83
  summary: The Ruby and Rails SDK for resend.com