render25 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +93 -0
- data/lib/render25.rb +113 -0
- metadata +51 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: e3aa2a20fe0a39dbfe8decc4ee300dff6e1e35db6905e9aaad4dc54964b6a4bb
|
|
4
|
+
data.tar.gz: '082b5319a6c14b8ff592c4b865c236bdfc8f251987bb9bd53da493e06c6b9dfa'
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 5c6d6d7138ce4675f8f85ac181918ce6a721d2e9815770a942a94d7fea9cae4fb1f6c6aaa9920e50c43fec072243beb62f6cc265754481413b8779c648a2954e
|
|
7
|
+
data.tar.gz: 063d367281300d42bfe2772d79b9a7668e38838c77f85811400efa45fe483affab4bcc8fc7b6ee3f6491df949ab92333a4b57a80a63efc1650db8b63b66b83d4
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Render25
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Render25 Ruby SDK
|
|
2
|
+
|
|
3
|
+
The official Ruby gem for the [Render25](https://render25.com) transactional email platform.
|
|
4
|
+
|
|
5
|
+
[](https://badge.fury.io/rb/render25)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
Add this line to your application's `Gemfile`:
|
|
11
|
+
|
|
12
|
+
```ruby
|
|
13
|
+
gem 'render25'
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
And then execute:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
bundle install
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Or install it yourself as:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
gem install render25
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Quickstart
|
|
29
|
+
|
|
30
|
+
```ruby
|
|
31
|
+
require 'render25'
|
|
32
|
+
|
|
33
|
+
# Automatically loads RENDER25_API_KEY from environment
|
|
34
|
+
client = Render25.new
|
|
35
|
+
|
|
36
|
+
# Or pass explicitly: client = Render25.new('re_live_...')
|
|
37
|
+
|
|
38
|
+
response = client.emails.send(
|
|
39
|
+
from: 'support@yourdomain.com',
|
|
40
|
+
to: 'user@example.com',
|
|
41
|
+
subject: 'Welcome to Render25!',
|
|
42
|
+
html: '<h1>Welcome aboard!</h1><p>Transactional email delivered via Ruby.</p>',
|
|
43
|
+
text: 'Welcome aboard! Transactional email delivered via Ruby.'
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
puts "Dispatched ID: #{response['id']}"
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Advanced: CC, BCC, Reply-To & Attachments
|
|
50
|
+
|
|
51
|
+
```ruby
|
|
52
|
+
require 'render25'
|
|
53
|
+
|
|
54
|
+
client = Render25.new
|
|
55
|
+
|
|
56
|
+
response = client.emails.send(
|
|
57
|
+
from: 'support@yourdomain.com',
|
|
58
|
+
to: ['client@example.com'],
|
|
59
|
+
cc: ['accounting@example.com'],
|
|
60
|
+
bcc: ['archive@example.com'],
|
|
61
|
+
reply_to: 'helpdesk@yourdomain.com',
|
|
62
|
+
subject: 'Your Invoice #1042',
|
|
63
|
+
html: '<p>Please find your receipt and invoice attached.</p>',
|
|
64
|
+
attachments: [
|
|
65
|
+
{
|
|
66
|
+
filename: 'invoice_1042.pdf',
|
|
67
|
+
content: File.binread('invoice.pdf'), # Pass binary string or file path
|
|
68
|
+
content_type: 'application/pdf'
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Ruby on Rails Integration
|
|
75
|
+
|
|
76
|
+
In `config/environments/production.rb`:
|
|
77
|
+
|
|
78
|
+
```ruby
|
|
79
|
+
# Using ActionMailer with SMTP relay
|
|
80
|
+
config.action_mailer.delivery_method = :smtp
|
|
81
|
+
config.action_mailer.smtp_settings = {
|
|
82
|
+
address: 'smtp.render25.com',
|
|
83
|
+
port: 587,
|
|
84
|
+
user_name: ENV['RENDER25_USERNAME'],
|
|
85
|
+
password: ENV['RENDER25_API_KEY'],
|
|
86
|
+
authentication: :plain,
|
|
87
|
+
enable_starttls_auto: true
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## License
|
|
92
|
+
|
|
93
|
+
MIT © [Render25](https://render25.com)
|
data/lib/render25.rb
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
require 'net/http'
|
|
2
|
+
require 'uri'
|
|
3
|
+
require 'json'
|
|
4
|
+
require 'base64'
|
|
5
|
+
|
|
6
|
+
module Render25
|
|
7
|
+
class Error < StandardError; end
|
|
8
|
+
|
|
9
|
+
def self.new(api_key = nil, options = {})
|
|
10
|
+
Client.new(api_key, options)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
class Client
|
|
14
|
+
attr_reader :api_key, :base_url, :emails
|
|
15
|
+
|
|
16
|
+
def initialize(api_key = nil, options = {})
|
|
17
|
+
@api_key = api_key || ENV['RENDER25_API_KEY']
|
|
18
|
+
raise ArgumentError, "Render25: API Key is required. Pass it to Render25.new(api_key) or set RENDER25_API_KEY environment variable." if @api_key.nil? || @api_key.empty?
|
|
19
|
+
|
|
20
|
+
@base_url = (options[:base_url] || ENV['RENDER25_BASE_URL'] || "https://api.render25.com").sub(/\/+$/, '')
|
|
21
|
+
@emails = EmailsService.new(self)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
class EmailsService
|
|
26
|
+
def initialize(client)
|
|
27
|
+
@client = client
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def send(options = {})
|
|
31
|
+
sender = options[:from] || options[:from_address]
|
|
32
|
+
raise ArgumentError, "Render25: :from address is required" unless sender
|
|
33
|
+
|
|
34
|
+
to = options[:to]
|
|
35
|
+
raise ArgumentError, "Render25: :to must contain at least one recipient" unless to
|
|
36
|
+
to = [to] if to.is_a?(String)
|
|
37
|
+
|
|
38
|
+
raise ArgumentError, "Render25: :subject is required" unless options[:subject]
|
|
39
|
+
|
|
40
|
+
payload = {
|
|
41
|
+
from: sender,
|
|
42
|
+
to: to,
|
|
43
|
+
subject: options[:subject],
|
|
44
|
+
text: options[:text] || '',
|
|
45
|
+
html: options[:html] || ''
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if options[:cc]
|
|
49
|
+
payload[:cc] = options[:cc].is_a?(Array) ? options[:cc] : [options[:cc]]
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
if options[:bcc]
|
|
53
|
+
payload[:bcc] = options[:bcc].is_a?(Array) ? options[:bcc] : [options[:bcc]]
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
reply_to = options[:reply_to] || options[:replyTo]
|
|
57
|
+
payload[:reply_to] = reply_to if reply_to
|
|
58
|
+
|
|
59
|
+
if options[:attachments] && options[:attachments].is_a?(Array)
|
|
60
|
+
payload[:attachments] = options[:attachments].map do |att|
|
|
61
|
+
filename = att[:filename] || 'attachment.bin'
|
|
62
|
+
content = att[:content]
|
|
63
|
+
content_type = att[:content_type] || att[:contentType] || 'application/octet-stream'
|
|
64
|
+
|
|
65
|
+
b64_content = if content.is_a?(String) && File.exist?(content)
|
|
66
|
+
Base64.strict_encode64(File.binread(content))
|
|
67
|
+
elsif content.is_a?(String)
|
|
68
|
+
# If already base64 or plain string
|
|
69
|
+
begin
|
|
70
|
+
Base64.strict_decode64(content)
|
|
71
|
+
content
|
|
72
|
+
rescue
|
|
73
|
+
Base64.strict_encode64(content)
|
|
74
|
+
end
|
|
75
|
+
else
|
|
76
|
+
Base64.strict_encode64(content.to_s)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
{
|
|
80
|
+
filename: filename,
|
|
81
|
+
content: b64_content,
|
|
82
|
+
content_type: content_type
|
|
83
|
+
}
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
uri = URI.parse("#{@client.base_url}/api/send")
|
|
88
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
89
|
+
http.use_ssl = (uri.scheme == 'https')
|
|
90
|
+
http.open_timeout = 10
|
|
91
|
+
http.read_timeout = 30
|
|
92
|
+
|
|
93
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
|
94
|
+
request['Authorization'] = "Bearer #{@client.api_key}"
|
|
95
|
+
request['Content-Type'] = 'application/json'
|
|
96
|
+
request['User-Agent'] = 'render25-ruby/1.0.0'
|
|
97
|
+
request.body = payload.to_json
|
|
98
|
+
|
|
99
|
+
begin
|
|
100
|
+
response = http.request(request)
|
|
101
|
+
parsed = JSON.parse(response.body) rescue { "error" => response.body }
|
|
102
|
+
|
|
103
|
+
if response.code.to_i >= 200 && response.code.to_i < 300
|
|
104
|
+
parsed
|
|
105
|
+
else
|
|
106
|
+
raise Error, "Render25 Error (#{response.code}): #{parsed['error'] || 'Unknown REST API error'}"
|
|
107
|
+
end
|
|
108
|
+
rescue StandardError => e
|
|
109
|
+
raise Error, "Render25 Error: #{e.message}"
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: render25
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Render25 Team
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2026-08-11 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: Send high-deliverability transactional emails with Render25 using Ruby
|
|
14
|
+
and Ruby on Rails.
|
|
15
|
+
email:
|
|
16
|
+
- support@render25.com
|
|
17
|
+
executables: []
|
|
18
|
+
extensions: []
|
|
19
|
+
extra_rdoc_files: []
|
|
20
|
+
files:
|
|
21
|
+
- LICENSE
|
|
22
|
+
- README.md
|
|
23
|
+
- lib/render25.rb
|
|
24
|
+
homepage: https://render25.com
|
|
25
|
+
licenses:
|
|
26
|
+
- MIT
|
|
27
|
+
metadata:
|
|
28
|
+
homepage_uri: https://render25.com
|
|
29
|
+
documentation_uri: https://render25.com/docs
|
|
30
|
+
source_code_uri: https://github.com/Render-25/ruby-sdk
|
|
31
|
+
bug_tracker_uri: https://github.com/Render-25/ruby-sdk/issues
|
|
32
|
+
post_install_message:
|
|
33
|
+
rdoc_options: []
|
|
34
|
+
require_paths:
|
|
35
|
+
- lib
|
|
36
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: 2.5.0
|
|
41
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
42
|
+
requirements:
|
|
43
|
+
- - ">="
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: '0'
|
|
46
|
+
requirements: []
|
|
47
|
+
rubygems_version: 3.0.3.1
|
|
48
|
+
signing_key:
|
|
49
|
+
specification_version: 4
|
|
50
|
+
summary: Official Ruby SDK for Render25 transactional email service
|
|
51
|
+
test_files: []
|