send_with_us 1.0.0 → 1.0.1
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 +4 -4
- data/README.md +82 -37
- data/lib/send_with_us/api.rb +13 -4
- data/lib/send_with_us/api_request.rb +2 -0
- data/lib/send_with_us/config.rb +4 -1
- data/lib/send_with_us/version.rb +1 -1
- data/send_with_us.gemspec +1 -1
- metadata +12 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a57e3e4b0f5abe4f4cabc867fbc17337be2ba10c
|
4
|
+
data.tar.gz: 17a35935697a76d5d537172ac6038c50565078b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 046333ff32245579376b1710560c53da4a69376516f62db4580311489d0eb48584982c13cfa2adcfc1663e510f2bbed343aaff2cd012cd5d468e5adc08180bdd
|
7
|
+
data.tar.gz: d36dca29256262b28888455194397b411d3ed93de23557a3c3164e311a11e75ea9cface3e69a74d39efa96a6efa002099e17f55a418e8c69d5ea6031aae39ea9
|
data/README.md
CHANGED
@@ -8,68 +8,113 @@ Ruby bindings for sending email via the sendwithus API.
|
|
8
8
|
|
9
9
|
## Installation
|
10
10
|
|
11
|
-
|
11
|
+
```bash
|
12
|
+
gem install send_with_us
|
13
|
+
```
|
12
14
|
|
13
15
|
or with Bundler:
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
+
```bash
|
18
|
+
gem 'send_with_us'
|
19
|
+
bundle install
|
20
|
+
```
|
17
21
|
|
18
22
|
## Usage
|
19
23
|
|
20
24
|
### General
|
21
25
|
|
22
26
|
For any Ruby project:
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
```ruby
|
28
|
+
require 'rubygems'
|
29
|
+
require 'send_with_us'
|
30
|
+
|
31
|
+
begin
|
32
|
+
obj = SendWithUs::Api.new( api_key: 'YOUR API KEY', debug: true )
|
33
|
+
|
34
|
+
# only required params
|
35
|
+
result = obj.send_with(
|
36
|
+
'EMAIL_ID',
|
37
|
+
{ address: "user@email.com" })
|
38
|
+
puts result
|
39
|
+
|
40
|
+
# with all optional params
|
41
|
+
result = obj.send_with(
|
32
42
|
'email_id',
|
33
|
-
{ address:
|
34
|
-
{ company_name: 'TestCo' }
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
43
|
+
{ name: 'Matt', address: 'recipient@testco.com' },
|
44
|
+
{ company_name: 'TestCo' },
|
45
|
+
{ name: 'Company',
|
46
|
+
address: 'company@testco.com',
|
47
|
+
reply_to: 'info@testco.com' })
|
48
|
+
puts result
|
49
|
+
|
50
|
+
# COMING SOON
|
51
|
+
# cc/bb support is coming soon, here's a taste test
|
52
|
+
result = obj.send_with(
|
39
53
|
'email_id',
|
40
54
|
{ name: 'Matt', address: 'recipient@testco.com' },
|
41
55
|
{ company_name: 'TestCo' },
|
42
56
|
{ name: 'Company',
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
57
|
+
address: 'company@testco.com',
|
58
|
+
reply_to: 'info@testco.com' },
|
59
|
+
[
|
60
|
+
{ name: 'CC',
|
61
|
+
address: 'cc@testco.com' }
|
62
|
+
],
|
63
|
+
[
|
64
|
+
{ name: 'BCC',
|
65
|
+
address: 'bcc@testco.com' },
|
66
|
+
{ name: 'BCC2',
|
67
|
+
address: 'bcc2@test.com' }
|
68
|
+
])
|
69
|
+
puts result
|
70
|
+
rescue Exception => e
|
71
|
+
puts "Error - #{e.class.name}: #{e.message}"
|
72
|
+
end
|
73
|
+
```
|
49
74
|
|
50
75
|
### Rails
|
51
76
|
|
52
77
|
For a Rails app, create `send_with_us.rb` in `/config/initializers/`
|
53
78
|
with the following:
|
54
79
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
80
|
+
```ruby
|
81
|
+
SendWithUs::Api.configure do |config|
|
82
|
+
config.api_key = 'YOUR API KEY'
|
83
|
+
config.debug = true
|
84
|
+
end
|
85
|
+
```
|
59
86
|
|
60
87
|
In your application code where you want to send an email:
|
61
88
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
89
|
+
```ruby
|
90
|
+
begin
|
91
|
+
result = SendWithUs::Api.new.send_with('email_id', { address: 'recipient@testco.com' }, { company_name: 'TestCo' })
|
92
|
+
puts result
|
93
|
+
rescue Exception => e
|
94
|
+
puts "Error - #{e.class.name}: #{e.message}"
|
95
|
+
end
|
96
|
+
```
|
68
97
|
|
69
98
|
## Errors
|
70
99
|
|
71
100
|
The following errors may be generated:
|
72
101
|
|
73
|
-
|
74
|
-
|
75
|
-
|
102
|
+
```ruby
|
103
|
+
SendWithUs::ApiInvalidEndpoint - the target URI is probably incorrect or email_id is invalid
|
104
|
+
SendWithUs::ApiConnectionRefused - the target URI is probably incorrect
|
105
|
+
SendWithUs::ApiUnknownError - an unhandled HTTP error occurred
|
106
|
+
```
|
107
|
+
|
108
|
+
## Internal
|
109
|
+
Build gem with
|
110
|
+
|
111
|
+
```bash
|
112
|
+
gem build send_with_us.gemspec
|
113
|
+
```
|
114
|
+
|
115
|
+
Publish gem with
|
116
|
+
|
117
|
+
```bash
|
118
|
+
gem publish send_with_us-VERSION.gem
|
119
|
+
```
|
120
|
+
|
data/lib/send_with_us/api.rb
CHANGED
@@ -20,12 +20,21 @@ module SendWithUs
|
|
20
20
|
@configuration = SendWithUs::Config.new(settings)
|
21
21
|
end
|
22
22
|
|
23
|
-
def send_with(email_id, to, data = {}, from = {})
|
23
|
+
def send_with(email_id, to, data = {}, from = {}, cc={}, bcc={})
|
24
|
+
payload = { email_id: email_id, recipient: to,
|
25
|
+
email_data: data }
|
26
|
+
|
24
27
|
if from.any?
|
25
|
-
payload =
|
26
|
-
|
27
|
-
|
28
|
+
payload[:sender] = from
|
29
|
+
end
|
30
|
+
if cc.any?
|
31
|
+
payload[:cc] = cc
|
28
32
|
end
|
33
|
+
if bcc.any?
|
34
|
+
payload[:bcc] = bcc
|
35
|
+
end
|
36
|
+
|
37
|
+
payload = payload.to_json
|
29
38
|
SendWithUs::ApiRequest.new(@configuration).send_with(payload)
|
30
39
|
end
|
31
40
|
|
@@ -14,6 +14,7 @@ module SendWithUs
|
|
14
14
|
path = request_path(:send)
|
15
15
|
request = Net::HTTP::Post.new(path, initheader = {'Content-Type' =>'application/json'})
|
16
16
|
request.add_field('X-SWU-API-KEY', @configuration.api_key)
|
17
|
+
request.add_field('X-SWU-API-CLIENT', @configuration.client_stub)
|
17
18
|
|
18
19
|
http = Net::HTTP.new(@configuration.host, @configuration.port)
|
19
20
|
http.use_ssl = use_ssl?
|
@@ -38,6 +39,7 @@ module SendWithUs
|
|
38
39
|
path = request_path(endpoint)
|
39
40
|
request = Net::HTTP::Get.new(path, initheader = {'Content-Type' =>'application/json'})
|
40
41
|
request.add_field('X-SWU-API-KEY', @configuration.api_key)
|
42
|
+
request.add_field('X-SWU-API-CLIENT', @configuration.client_stub)
|
41
43
|
|
42
44
|
http = Net::HTTP.new(@configuration.host, @configuration.port)
|
43
45
|
http.use_ssl = use_ssl?
|
data/lib/send_with_us/config.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require_relative 'version'
|
2
|
+
|
1
3
|
module SendWithUs
|
2
4
|
class Config
|
3
5
|
attr_accessor :settings
|
@@ -15,7 +17,8 @@ module SendWithUs
|
|
15
17
|
host: source.host,
|
16
18
|
port: source.port,
|
17
19
|
api_version: '1_0',
|
18
|
-
debug: true
|
20
|
+
debug: true,
|
21
|
+
client_stub: "ruby-#{VERSION}"
|
19
22
|
}
|
20
23
|
end
|
21
24
|
|
data/lib/send_with_us/version.rb
CHANGED
data/send_with_us.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |gem|
|
|
11
11
|
gem.email = ["us@sendwithus.com"]
|
12
12
|
gem.description = %q{SendWithUs.com Ruby Client}
|
13
13
|
gem.summary = %q{SendWithUs.com Ruby Client}
|
14
|
-
gem.homepage = "
|
14
|
+
gem.homepage = "https://github.com/sendwithus/sendwithus_ruby"
|
15
15
|
|
16
16
|
gem.files = `git ls-files`.split($/)
|
17
17
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: send_with_us
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Harris
|
@@ -9,48 +9,48 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-09-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - '>='
|
18
|
+
- - ! '>='
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '0'
|
21
21
|
type: :development
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - '>='
|
25
|
+
- - ! '>='
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: shoulda
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- - '>='
|
32
|
+
- - ! '>='
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '0'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- - '>='
|
39
|
+
- - ! '>='
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: mocha
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - '>='
|
46
|
+
- - ! '>='
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '0'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- - '>='
|
53
|
+
- - ! '>='
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
description: SendWithUs.com Ruby Client
|
@@ -79,7 +79,7 @@ files:
|
|
79
79
|
- test/lib/send_with_us/config_test.rb
|
80
80
|
- test/lib/send_with_us/version_test.rb
|
81
81
|
- test/test_helper.rb
|
82
|
-
homepage:
|
82
|
+
homepage: https://github.com/sendwithus/sendwithus_ruby
|
83
83
|
licenses: []
|
84
84
|
metadata: {}
|
85
85
|
post_install_message:
|
@@ -88,17 +88,17 @@ require_paths:
|
|
88
88
|
- lib
|
89
89
|
required_ruby_version: !ruby/object:Gem::Requirement
|
90
90
|
requirements:
|
91
|
-
- - '>='
|
91
|
+
- - ! '>='
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: '0'
|
94
94
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
95
|
requirements:
|
96
|
-
- - '>='
|
96
|
+
- - ! '>='
|
97
97
|
- !ruby/object:Gem::Version
|
98
98
|
version: '0'
|
99
99
|
requirements: []
|
100
100
|
rubyforge_project:
|
101
|
-
rubygems_version: 2.0.
|
101
|
+
rubygems_version: 2.0.7
|
102
102
|
signing_key:
|
103
103
|
specification_version: 4
|
104
104
|
summary: SendWithUs.com Ruby Client
|