send_with_us 4.0.1 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/CODEOWNERS +2 -0
- data/.github/SUPPORT.md +3 -0
- data/CHANGELOG.md +1 -0
- data/README.md +2 -1
- data/lib/send_with_us.rb +1 -0
- data/lib/send_with_us/api.rb +2 -9
- data/lib/send_with_us/attachment.rb +6 -1
- data/lib/send_with_us/file.rb +21 -0
- data/lib/send_with_us/version.rb +1 -1
- data/test/lib/send_with_us/api_request_test.rb +15 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: adf0511f6d96b06f896efdfa2ba12f100fbcb2d0
|
4
|
+
data.tar.gz: c22959469932e596740afb531066956c746914a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd6ad175bbbcc9a9b7c3260389a9bb2b95bf6aeaf0bc33dd0bfd831678481f376447487d1acacfef1d8f7954fe519caa732663513fe411a67e30f5cd48a6db83
|
7
|
+
data.tar.gz: 72c0733ab2c816a5e5dd5e58466b8488460015634dd2878b634ffc503fedd2a8c836efd18fcea2dce34017a3f3ce9cd53cc7e5e61febc03cd19059299f1ca274
|
data/.github/CODEOWNERS
ADDED
data/.github/SUPPORT.md
ADDED
@@ -0,0 +1,3 @@
|
|
1
|
+
Please only file issues that you believe represent actual bugs or feature requests for this API client.
|
2
|
+
|
3
|
+
If you are having issues with your Sendwithus integration, have questions about email, or have found a bug with Sendwithus’ API please reach out to support@sendwithus.com and our support team will be happy to help.
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -108,7 +108,8 @@ begin
|
|
108
108
|
'path/to/file.txt',
|
109
109
|
{ filename: 'customfilename.txt', attachment: 'path/to/file.txt' },
|
110
110
|
{ filename: 'anotherfile.txt', attachment: File.open('path/to/file.txt') },
|
111
|
-
{ filename: 'unpersistedattachment.txt', attachment: StringIO.new("raw data") }
|
111
|
+
{ filename: 'unpersistedattachment.txt', attachment: StringIO.new("raw data") },
|
112
|
+
{ id: "alreadyBase64EncodedFile", data: "aG9sYQ==\n" }
|
112
113
|
]
|
113
114
|
)
|
114
115
|
puts result
|
data/lib/send_with_us.rb
CHANGED
data/lib/send_with_us/api.rb
CHANGED
@@ -119,15 +119,8 @@ module SendWithUs
|
|
119
119
|
end
|
120
120
|
|
121
121
|
if options[:files] && options[:files].any?
|
122
|
-
payload[:files] = []
|
123
|
-
|
124
|
-
options[:files].each do |file_data|
|
125
|
-
if file_data.is_a?(String)
|
126
|
-
attachment = SendWithUs::Attachment.new(file_data)
|
127
|
-
else
|
128
|
-
attachment = SendWithUs::Attachment.new(file_data[:attachment], file_data[:filename])
|
129
|
-
end
|
130
|
-
payload[:files] << { id: attachment.filename, data: attachment.encoded_data }
|
122
|
+
payload[:files] = options[:files].map do |file_data|
|
123
|
+
SendWithUs::File.new(file_data).to_h
|
131
124
|
end
|
132
125
|
end
|
133
126
|
|
@@ -5,12 +5,17 @@ module SendWithUs
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def filename
|
8
|
-
@filename ||= @attachment.is_a?(String) ? File.basename(@attachment) : nil
|
8
|
+
@filename ||= @attachment.is_a?(String) ? ::File.basename(@attachment) : nil
|
9
9
|
end
|
10
10
|
|
11
11
|
def encoded_data
|
12
12
|
file_data = @attachment.respond_to?(:read) ? @attachment : open(@attachment)
|
13
13
|
Base64.encode64(file_data.read)
|
14
14
|
end
|
15
|
+
|
16
|
+
def to_h
|
17
|
+
{ id: filename,
|
18
|
+
data: encoded_data }
|
19
|
+
end
|
15
20
|
end
|
16
21
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module SendWithUs
|
2
|
+
class File
|
3
|
+
attr_accessor :attachment
|
4
|
+
|
5
|
+
def initialize(file_data, opts = {})
|
6
|
+
@attachment = if file_data.is_a?(String)
|
7
|
+
SendWithUs::Attachment.new(file_data)
|
8
|
+
else
|
9
|
+
if file_data[:data] and file_data[:id]
|
10
|
+
file_data
|
11
|
+
else
|
12
|
+
SendWithUs::Attachment.new(file_data[:attachment], file_data[:filename])
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_h
|
18
|
+
attachment.to_h
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/send_with_us/version.rb
CHANGED
@@ -86,6 +86,21 @@ class TestApiRequest < Minitest::Test
|
|
86
86
|
assert_instance_of( Net::HTTPOK, result )
|
87
87
|
end
|
88
88
|
|
89
|
+
def test_send_email_with_file
|
90
|
+
build_objects
|
91
|
+
result = @api.send_email(
|
92
|
+
@template[:id],
|
93
|
+
{name: 'Ruby Unit Test', address: 'matt@example.com'},
|
94
|
+
data: {data: 'I AM DATA'},
|
95
|
+
from: {name: 'sendwithus', address: 'matt@example.com'},
|
96
|
+
cc: [],
|
97
|
+
bcc: [],
|
98
|
+
files: [{data: Base64.encode64(open('README.md').read),
|
99
|
+
id: 'README.md'}]
|
100
|
+
)
|
101
|
+
assert_instance_of( Net::HTTPOK, result )
|
102
|
+
end
|
103
|
+
|
89
104
|
def test_send_with_with_version
|
90
105
|
build_objects
|
91
106
|
email_id = 'tem_9YvYsaLW2Mw4tmPiLcVvpC'
|
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: 4.0
|
4
|
+
version: 4.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Harris
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date:
|
15
|
+
date: 2018-02-22 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rake
|
@@ -63,8 +63,10 @@ executables: []
|
|
63
63
|
extensions: []
|
64
64
|
extra_rdoc_files: []
|
65
65
|
files:
|
66
|
+
- .github/CODEOWNERS
|
66
67
|
- .github/ISSUE_TEMPLATE
|
67
68
|
- .github/PULL_REQUEST_TEMPLATE
|
69
|
+
- .github/SUPPORT.md
|
68
70
|
- .gitignore
|
69
71
|
- .travis.yml
|
70
72
|
- CHANGELOG.md
|
@@ -79,6 +81,7 @@ files:
|
|
79
81
|
- lib/send_with_us/attachment.rb
|
80
82
|
- lib/send_with_us/config.rb
|
81
83
|
- lib/send_with_us/error.rb
|
84
|
+
- lib/send_with_us/file.rb
|
82
85
|
- lib/send_with_us/version.rb
|
83
86
|
- send_with_us.gemspec
|
84
87
|
- test/lib/send_with_us/api_request_test.rb
|