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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 20f559ce008e420040ec7b495e4f47f7a3ae76b2
4
- data.tar.gz: 73d4a26a72a2b0d072d6398b5377d63fef7370e6
3
+ metadata.gz: adf0511f6d96b06f896efdfa2ba12f100fbcb2d0
4
+ data.tar.gz: c22959469932e596740afb531066956c746914a5
5
5
  SHA512:
6
- metadata.gz: 202796e78c60bdf82ecb6c624b5f0148a10f9c46f8e9a83f81e56df709ea97f5fe3b846e585de4dc7134487e14e2532e274b61cca00c93663926363ea9e66fbd
7
- data.tar.gz: c19407602ab50efa1600d97580baccd97101af0fdb1bee19c0898149e58390aae5ad2e40dc5118bb76c06f1dc3ba47fd492f26e919be897e1b8d9d7e5541ad6f
6
+ metadata.gz: fd6ad175bbbcc9a9b7c3260389a9bb2b95bf6aeaf0bc33dd0bfd831678481f376447487d1acacfef1d8f7954fe519caa732663513fe411a67e30f5cd48a6db83
7
+ data.tar.gz: 72c0733ab2c816a5e5dd5e58466b8488460015634dd2878b634ffc503fedd2a8c836efd18fcea2dce34017a3f3ce9cd53cc7e5e61febc03cd19059299f1ca274
@@ -0,0 +1,2 @@
1
+ # Auto tag Sendwithus employees on new Issues/Pull Requests
2
+ * @demoore @FlipCodes @Bean0B
@@ -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.
@@ -1,3 +1,4 @@
1
+ 4.1.0 - `send_email` now supports already encoded files
1
2
  4.0.1 - Remove unused methods
2
3
  4.0.0 - Deprecate Logs List API endpoint
3
4
  3.1.0 - Add `strict` option to the render call
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
@@ -8,6 +8,7 @@ require 'uri'
8
8
  require 'json'
9
9
 
10
10
  require 'send_with_us/attachment'
11
+ require 'send_with_us/file'
11
12
  require 'send_with_us/api'
12
13
  require 'send_with_us/api_request'
13
14
  require 'send_with_us/config'
@@ -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
@@ -1,3 +1,3 @@
1
1
  module SendWithUs
2
- VERSION = '4.0.1'
2
+ VERSION = '4.1.0'
3
3
  end
@@ -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.1
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: 2017-08-04 00:00:00.000000000 Z
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