mailclerk 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.md +20 -0
- data/README.md +133 -0
- data/lib/mailclerk.rb +76 -0
- metadata +147 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0746f6e459e89ebf5c23c33c940f10f4639d7b92e9bffbb7bb0f0c217608d8e9
|
4
|
+
data.tar.gz: 12c12b1846326a577d6423dd7b20ecf77156c50d4e3ab084327b72224a4b8023
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1867bff480e230a049d3ec3f14221ca83ace81ed745cbefd1b3b7ef7ec6d6d561f7b8f9fe37b9d0d83d178f50ed28061bf6f35768f806dd4e9d27997a7f6c289
|
7
|
+
data.tar.gz: 5aa6071e289c6194fe43abfba94ed141200b1c385c42ac897e4c09dd0b0bf722f079f7e69b0d96d767deac7273a47a5475b31d60aac3160575dfb431e0006ffa
|
data/LICENSE.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2021 [Mailclerk](https://mailclerk.app/).
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
<p align="center">
|
2
|
+
<img src="mailcerk.png" alt="Mailclerk Logo"/>
|
3
|
+
</p>
|
4
|
+
|
5
|
+
# Mailclerk
|
6
|
+
|
7
|
+
[![Gem Version](https://badge.fury.io/rb/mailclerk.svg)](http://badge.fury.io/rb/mailclerk)
|
8
|
+
|
9
|
+
Mailclerk helps anyone on your team design great emails, improve their performance, and free up developer time. [Learn more](https://mailclerk.app/)
|
10
|
+
|
11
|
+
<!-- Tocer[start]: Auto-generated, don't remove. -->
|
12
|
+
|
13
|
+
## Table of Contents
|
14
|
+
|
15
|
+
- [Requirements](#requirements)
|
16
|
+
- [Setup](#setup)
|
17
|
+
- [API Key & URL](#api-key--url)
|
18
|
+
- [Usage](#usage)
|
19
|
+
- [Varying API Keys](#varying-api-keys)
|
20
|
+
- [Tests](#tests)
|
21
|
+
- [Versioning](#versioning)
|
22
|
+
- [Code of Conduct](#code-of-conduct)
|
23
|
+
- [Contributions](#contributions)
|
24
|
+
- [License](#license)
|
25
|
+
- [History](#history)
|
26
|
+
|
27
|
+
<!-- Tocer[finish]: Auto-generated, don't remove. -->
|
28
|
+
|
29
|
+
## Requirements
|
30
|
+
|
31
|
+
1. [Ruby 2.7.0](https://www.ruby-lang.org)
|
32
|
+
|
33
|
+
## Setup
|
34
|
+
|
35
|
+
To install, run:
|
36
|
+
|
37
|
+
```
|
38
|
+
gem install mailclerk
|
39
|
+
```
|
40
|
+
|
41
|
+
Add the following to your Gemfile:
|
42
|
+
|
43
|
+
```
|
44
|
+
gem "mailclerk"
|
45
|
+
```
|
46
|
+
|
47
|
+
## API Key & URL
|
48
|
+
|
49
|
+
To set the Mailclerk API Key (begins with `mc_`), you can provide it as an
|
50
|
+
environmental variable: `MAILCLERK_API_KEY`. Alternatively, you can
|
51
|
+
set it directly on the Mailclerk module:
|
52
|
+
|
53
|
+
```
|
54
|
+
# config/initializers/mailcerk.rb
|
55
|
+
Mailclerk.api_key = "mc_yourprivatekey"
|
56
|
+
```
|
57
|
+
|
58
|
+
_If you are using version control like git, we strongly recommend storing your
|
59
|
+
production API keys in environmental variables_.
|
60
|
+
|
61
|
+
The default API endpoint is `https://api.mailcerk.app`. To change this, you
|
62
|
+
can provide a `MAILCLERK_API_URL` ENV variable or set `Mailclerk.mailcerk_url`.
|
63
|
+
|
64
|
+
## Usage
|
65
|
+
|
66
|
+
You'll need an active account and at least one template (in the example `welcome-email`).
|
67
|
+
|
68
|
+
To send an email to "alice@example.com":
|
69
|
+
|
70
|
+
```
|
71
|
+
Mailclerk.deliver("welcome-email", "alice@example.com")
|
72
|
+
```
|
73
|
+
|
74
|
+
If the template has any dynamic data, you can include it in the third parameter
|
75
|
+
as a hash:
|
76
|
+
|
77
|
+
```
|
78
|
+
Mailclerk.deliver("welcome-email", "alice@example.com", { name: "Alice" })
|
79
|
+
```
|
80
|
+
|
81
|
+
See [Mailclerk documentation](https://dashboard.mailclerk.app/docs) for more details.
|
82
|
+
|
83
|
+
## Varying API Keys
|
84
|
+
|
85
|
+
If you need to use multiple API keys, you can also initialize `Mailclerk::Client`
|
86
|
+
instances with different keys. This:
|
87
|
+
|
88
|
+
```
|
89
|
+
mc_client = Mailclerk.new("mc_yourprivatekey")
|
90
|
+
mc_client.deliver("welcome-email", "bob@example.com")
|
91
|
+
```
|
92
|
+
|
93
|
+
Is equivalent to this:
|
94
|
+
|
95
|
+
```
|
96
|
+
Mailclerk.api_key = "mc_yourprivatekey"
|
97
|
+
Mailclerk.deliver("welcome-email", "bob@example.com")
|
98
|
+
```
|
99
|
+
|
100
|
+
## Tests
|
101
|
+
|
102
|
+
Tests aren't current implemented. When they are, to test, run:
|
103
|
+
|
104
|
+
```
|
105
|
+
bundle exec rake
|
106
|
+
```
|
107
|
+
|
108
|
+
## Versioning
|
109
|
+
|
110
|
+
Read [Semantic Versioning](https://semver.org) for details. Briefly, it means:
|
111
|
+
|
112
|
+
- Major (X.y.z) - Incremented for any backwards incompatible public API changes.
|
113
|
+
- Minor (x.Y.z) - Incremented for new, backwards compatible, public API enhancements/fixes.
|
114
|
+
- Patch (x.y.Z) - Incremented for small, backwards compatible, bug fixes.
|
115
|
+
|
116
|
+
## Code of Conduct
|
117
|
+
|
118
|
+
Please note that this project is released with a [CODE OF CONDUCT](CODE_OF_CONDUCT.md). By
|
119
|
+
participating in this project you agree to abide by its terms.
|
120
|
+
|
121
|
+
## Contributions
|
122
|
+
|
123
|
+
Read [CONTRIBUTING](CONTRIBUTING.md) for details.
|
124
|
+
|
125
|
+
## License
|
126
|
+
|
127
|
+
Copyright 2021 [Mailclerk](https://mailclerk.app/).
|
128
|
+
Read [LICENSE](LICENSE.md) for details.
|
129
|
+
|
130
|
+
## History
|
131
|
+
|
132
|
+
Read [CHANGES](CHANGES.md) for details.
|
133
|
+
Built with [Gemsmith](https://github.com/bkuhlmann/gemsmith).
|
data/lib/mailclerk.rb
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'faraday'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
module Mailclerk
|
7
|
+
DEFAULT_API_URL = "https://api.mailclerk.app"
|
8
|
+
|
9
|
+
class << self
|
10
|
+
attr_accessor :api_key
|
11
|
+
attr_accessor :api_url
|
12
|
+
end
|
13
|
+
|
14
|
+
# Gem identity information.
|
15
|
+
module Identity
|
16
|
+
def self.name
|
17
|
+
"mailclerk"
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.label
|
21
|
+
"Mailclerk Ruby"
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.version
|
25
|
+
"0.1.1"
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.version_label
|
29
|
+
"#{ label } #{ version }"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class MailclerkError < StandardError
|
34
|
+
end
|
35
|
+
|
36
|
+
class Client
|
37
|
+
def initialize(api_key, api_url=nil)
|
38
|
+
@api_key = api_key
|
39
|
+
@api_url = api_url || ENV['MAILCLERK_API_URL'] || DEFAULT_API_URL
|
40
|
+
|
41
|
+
if @api_key.nil?
|
42
|
+
raise MailclerkError.new "No Mailclerk API Key provided. Set `Mailclerk.api_key`"
|
43
|
+
end
|
44
|
+
|
45
|
+
if @api_url.nil? || @api_url.empty?
|
46
|
+
raise MailclerkError.new "Mailclerk API URL empty"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def deliver(template, recipient, data={}, options={})
|
51
|
+
conn = Faraday.new(url: @api_url)
|
52
|
+
conn.basic_auth(@api_key, '')
|
53
|
+
|
54
|
+
resp = conn.post('deliver', {
|
55
|
+
'template' => template,
|
56
|
+
'recipient' => recipient,
|
57
|
+
'data' => data,
|
58
|
+
'options' => options
|
59
|
+
}.to_json, {
|
60
|
+
'Content-Type' => 'application/json',
|
61
|
+
'X-Client-Version' => Identity.version_label
|
62
|
+
})
|
63
|
+
|
64
|
+
return resp
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# Syntax intended to emulate ActionMailer
|
69
|
+
def self.deliver(*args)
|
70
|
+
api_key = self.api_key || ENV['MAILCLERK_API_KEY']
|
71
|
+
|
72
|
+
client = Client.new(api_key, self.api_url)
|
73
|
+
return client.deliver(*args)
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
metadata
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mailclerk
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Noah Litvin
|
8
|
+
- Greg Sherri
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2021-01-28 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: faraday
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: bundler-audit
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0.6'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0.6'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: gemsmith
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '14.0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '14.0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: guard-rspec
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '4.7'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '4.7'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: pry
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0.12'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0.12'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: rake
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '13.0'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '13.0'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: rspec
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '3.9'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '3.9'
|
112
|
+
description:
|
113
|
+
email:
|
114
|
+
- developers@mailclerk.app
|
115
|
+
executables: []
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files:
|
118
|
+
- README.md
|
119
|
+
- LICENSE.md
|
120
|
+
files:
|
121
|
+
- LICENSE.md
|
122
|
+
- README.md
|
123
|
+
- lib/mailclerk.rb
|
124
|
+
homepage: https://github.com/mailclerk/mailclerk-ruby
|
125
|
+
licenses:
|
126
|
+
- MIT
|
127
|
+
metadata: {}
|
128
|
+
post_install_message:
|
129
|
+
rdoc_options: []
|
130
|
+
require_paths:
|
131
|
+
- lib
|
132
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - "~>"
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '2.7'
|
137
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
requirements: []
|
143
|
+
rubygems_version: 3.1.2
|
144
|
+
signing_key:
|
145
|
+
specification_version: 4
|
146
|
+
summary: Official Mailclerk ruby gem
|
147
|
+
test_files: []
|