dashamail_transactional 0.1.1 → 0.1.3.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/Gemfile +1 -0
- data/Gemfile.lock +15 -1
- data/README.md +8 -3
- data/dashamail_transactional-0.1.3.gem +0 -0
- data/lib/dashamail/composer.rb +5 -1
- data/lib/dashamail/configuration.rb +1 -3
- data/lib/dashamail/http.rb +7 -5
- data/lib/dashamail/mailer.rb +1 -1
- data/lib/dashamail/request.rb +1 -1
- data/lib/dashamail/response.rb +1 -1
- data/lib/dashamail/utils.rb +38 -20
- data/lib/dashamail/version.rb +2 -2
- data/lib/dashamail.rb +1 -18
- data/lib/dashamail_transactional.rb +22 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4c7efdfd6a4d83f0ac24ba8ac1680fe9741d7d1ff7993da27a51f52ead69946
|
4
|
+
data.tar.gz: 22d593e75096ea5262f00cba2d0532732ce1a15c184d42c2acd5148381d03255
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa575e92b016a1ad1f81472e868acccdef5e951c532f291c9da7c7d1a990abd5494c2a85111684cc96bd108a549af652ce463e244f7b5b3b48b5430209ccca0b
|
7
|
+
data.tar.gz: e2a2d9ccb63991343fb68fa37632aced40ae857386a5d81bab9a5ac18e402a4eb8dd31eb3a01ec45e8cc8f0466da4dbdee60aff5f01c64005acdf203a5daf548
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,13 +1,20 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
dashamail_transactional (0.1.
|
4
|
+
dashamail_transactional (0.1.3)
|
5
5
|
mime-types (>= 3.4.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
+
addressable (2.8.7)
|
11
|
+
public_suffix (>= 2.0.2, < 7.0)
|
10
12
|
ast (2.4.2)
|
13
|
+
bigdecimal (3.1.8)
|
14
|
+
crack (1.0.0)
|
15
|
+
bigdecimal
|
16
|
+
rexml
|
17
|
+
hashdiff (1.1.2)
|
11
18
|
json (2.9.0)
|
12
19
|
language_server-protocol (3.17.0.3)
|
13
20
|
logger (1.6.2)
|
@@ -20,10 +27,12 @@ GEM
|
|
20
27
|
parser (3.3.6.0)
|
21
28
|
ast (~> 2.4.1)
|
22
29
|
racc
|
30
|
+
public_suffix (6.0.1)
|
23
31
|
racc (1.8.1)
|
24
32
|
rainbow (3.1.1)
|
25
33
|
rake (13.2.1)
|
26
34
|
regexp_parser (2.9.3)
|
35
|
+
rexml (3.3.9)
|
27
36
|
rubocop (1.69.2)
|
28
37
|
json (~> 2.3)
|
29
38
|
language_server-protocol (>= 3.17.0)
|
@@ -40,6 +49,10 @@ GEM
|
|
40
49
|
unicode-display_width (3.1.2)
|
41
50
|
unicode-emoji (~> 4.0, >= 4.0.4)
|
42
51
|
unicode-emoji (4.0.4)
|
52
|
+
webmock (3.24.0)
|
53
|
+
addressable (>= 2.8.0)
|
54
|
+
crack (>= 0.3.2)
|
55
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
43
56
|
|
44
57
|
PLATFORMS
|
45
58
|
arm64-darwin-23
|
@@ -50,6 +63,7 @@ DEPENDENCIES
|
|
50
63
|
minitest (~> 5.25.4)
|
51
64
|
rake (~> 13.2.1)
|
52
65
|
rubocop (~> 1.69.2)
|
66
|
+
webmock
|
53
67
|
|
54
68
|
BUNDLED WITH
|
55
69
|
2.5.11
|
data/README.md
CHANGED
@@ -11,10 +11,11 @@
|
|
11
11
|
|
12
12
|
## Установка
|
13
13
|
|
14
|
-
|
14
|
+
|
15
|
+
Добавьте в Gemfile:
|
15
16
|
|
16
17
|
```sh
|
17
|
-
gem '
|
18
|
+
gem 'dashamail_transactional'
|
18
19
|
```
|
19
20
|
Затем установите с помощью Bundler
|
20
21
|
|
@@ -79,8 +80,12 @@ pp response.data
|
|
79
80
|
|
80
81
|
## Contributing
|
81
82
|
|
82
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
83
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/83312d/dashamail_transactional.
|
83
84
|
|
84
85
|
## License
|
85
86
|
|
86
87
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
88
|
+
|
89
|
+
## Sponsored by
|
90
|
+
|
91
|
+
[](https://21-school.ru/)
|
Binary file
|
data/lib/dashamail/composer.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
3
|
+
module DashamailTransactional
|
4
4
|
class Composer
|
5
5
|
def initialize
|
6
6
|
@config = DashaMail.config
|
@@ -92,6 +92,10 @@ module DashaMail
|
|
92
92
|
@container[:ignore_delivery_policy] = ignore_delivery_policy
|
93
93
|
end
|
94
94
|
|
95
|
+
def campaign_id=(campaign_id)
|
96
|
+
@container[:campaign_id] = campaign_id
|
97
|
+
end
|
98
|
+
|
95
99
|
def call
|
96
100
|
@container
|
97
101
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
3
|
+
module DashamailTransactional
|
4
4
|
module Configuration
|
5
5
|
def self.api_key
|
6
6
|
@api_key
|
@@ -92,8 +92,6 @@ module DashaMail
|
|
92
92
|
|
93
93
|
DEFAULT = {
|
94
94
|
end_point: 'https://api.dashamail.ru',
|
95
|
-
no_track_opens: true,
|
96
|
-
no_track_clicks: true,
|
97
95
|
response_format: 'JSON',
|
98
96
|
ignore_delivery_policy: false
|
99
97
|
}.freeze
|
data/lib/dashamail/http.rb
CHANGED
@@ -4,7 +4,7 @@ require 'uri'
|
|
4
4
|
require 'json'
|
5
5
|
require 'net/http'
|
6
6
|
|
7
|
-
module
|
7
|
+
module DashamailTransactional
|
8
8
|
class HTTP
|
9
9
|
VERBS = {
|
10
10
|
get: Net::HTTP::Get,
|
@@ -26,12 +26,14 @@ module DashaMail
|
|
26
26
|
}.merge!(options)
|
27
27
|
end
|
28
28
|
|
29
|
-
def
|
30
|
-
|
29
|
+
def reset_headers
|
30
|
+
@headers = base_headers
|
31
31
|
end
|
32
32
|
|
33
|
-
|
34
|
-
|
33
|
+
VERBS.each_key do |method|
|
34
|
+
define_method(method) do |path, options = {}|
|
35
|
+
execute(path, method, options)
|
36
|
+
end
|
35
37
|
end
|
36
38
|
|
37
39
|
private
|
data/lib/dashamail/mailer.rb
CHANGED
data/lib/dashamail/request.rb
CHANGED
data/lib/dashamail/response.rb
CHANGED
data/lib/dashamail/utils.rb
CHANGED
@@ -3,32 +3,50 @@
|
|
3
3
|
require 'base64'
|
4
4
|
require 'mime-types'
|
5
5
|
|
6
|
-
module
|
6
|
+
module DashamailTransactional
|
7
7
|
class Utils
|
8
|
-
|
9
|
-
raise StandardError, 'File not exist' unless File.exist?(file_path)
|
8
|
+
MAX_FILENAME_LENGTH = 255
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
class << self
|
11
|
+
def build_attachment(file_path)
|
12
|
+
validate_and_read_file(file_path) do |file_name, file_content|
|
13
|
+
{
|
14
|
+
name: truncate_filename(file_name),
|
15
|
+
filebody: Base64.strict_encode64(file_content)
|
16
|
+
}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def build_inline(file_path, cid)
|
21
|
+
validate_and_read_file(file_path) do |file_name, file_content|
|
22
|
+
{
|
23
|
+
mime_type: MIME::Types.type_for(file_path).first&.to_s || 'application/octet-stream',
|
24
|
+
filename: truncate_filename(file_name),
|
25
|
+
body: Base64.strict_encode64(file_content),
|
26
|
+
cid: cid
|
27
|
+
}
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def validate_and_read_file(file_path)
|
34
|
+
raise StandardError, 'File not exist' unless File.exist?(file_path)
|
35
|
+
|
36
|
+
file_name = File.basename(file_path)
|
37
|
+
file_content = File.open(file_path, 'rb', &:read)
|
38
|
+
|
39
|
+
yield(file_name, file_content)
|
14
40
|
end
|
15
|
-
{ name: file_name, filebody: file_body }
|
16
|
-
end
|
17
41
|
|
18
|
-
|
19
|
-
|
42
|
+
def truncate_filename(filename)
|
43
|
+
return filename if filename.bytesize <= MAX_FILENAME_LENGTH
|
20
44
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
45
|
+
extension = File.extname(filename)
|
46
|
+
basename = File.basename(filename, extension)
|
47
|
+
max_basename_length = MAX_FILENAME_LENGTH - extension.bytesize
|
48
|
+
"#{basename.byteslice(0, max_basename_length)}#{extension}"
|
25
49
|
end
|
26
|
-
{
|
27
|
-
mime_type: mime_type,
|
28
|
-
filename: file_name,
|
29
|
-
body: file_body,
|
30
|
-
cid: cid
|
31
|
-
}
|
32
50
|
end
|
33
51
|
end
|
34
52
|
end
|
data/lib/dashamail/version.rb
CHANGED
data/lib/dashamail.rb
CHANGED
@@ -1,20 +1,3 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
4
|
-
require 'dashamail/configuration'
|
5
|
-
require 'dashamail/utils'
|
6
|
-
require 'dashamail/http'
|
7
|
-
require 'dashamail/composer'
|
8
|
-
require 'dashamail/mailer'
|
9
|
-
require 'dashamail/response'
|
10
|
-
require 'dashamail/request'
|
11
|
-
|
12
|
-
module DashaMail
|
13
|
-
def self.configure
|
14
|
-
yield DashaMail::Configuration
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.config
|
18
|
-
DashaMail::Configuration
|
19
|
-
end
|
20
|
-
end
|
3
|
+
require 'dashamail_transactional'
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'dashamail/version'
|
4
|
+
require 'dashamail/configuration'
|
5
|
+
require 'dashamail/utils'
|
6
|
+
require 'dashamail/http'
|
7
|
+
require 'dashamail/composer'
|
8
|
+
require 'dashamail/mailer'
|
9
|
+
require 'dashamail/response'
|
10
|
+
require 'dashamail/request'
|
11
|
+
|
12
|
+
module DashamailTransactional
|
13
|
+
def self.configure
|
14
|
+
yield DashamailTransactional::Configuration
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.config
|
18
|
+
DashamailTransactional::Configuration
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
DashaMail = DashamailTransactional
|
metadata
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dashamail_transactional
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.1
|
4
|
+
version: 0.1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergey Fedorov
|
8
|
+
- Dave Maksimovskiy
|
9
|
+
- Alexander Bondarenko
|
8
10
|
autorequire:
|
9
11
|
bindir: exe
|
10
12
|
cert_chain: []
|
11
|
-
date: 2024-12-
|
13
|
+
date: 2024-12-13 00:00:00.000000000 Z
|
12
14
|
dependencies:
|
13
15
|
- !ruby/object:Gem::Dependency
|
14
16
|
name: mime-types
|
@@ -26,6 +28,7 @@ dependencies:
|
|
26
28
|
version: 3.4.0
|
27
29
|
description: Ruby client DashaMail for transactional API
|
28
30
|
email:
|
31
|
+
- 83312d@gmail.com
|
29
32
|
- creadone@gmail.com
|
30
33
|
executables: []
|
31
34
|
extensions: []
|
@@ -37,6 +40,7 @@ files:
|
|
37
40
|
- LICENSE.txt
|
38
41
|
- README.md
|
39
42
|
- Rakefile
|
43
|
+
- dashamail_transactional-0.1.3.gem
|
40
44
|
- lib/dashamail.rb
|
41
45
|
- lib/dashamail/composer.rb
|
42
46
|
- lib/dashamail/configuration.rb
|
@@ -46,6 +50,7 @@ files:
|
|
46
50
|
- lib/dashamail/response.rb
|
47
51
|
- lib/dashamail/utils.rb
|
48
52
|
- lib/dashamail/version.rb
|
53
|
+
- lib/dashamail_transactional.rb
|
49
54
|
homepage:
|
50
55
|
licenses:
|
51
56
|
- MIT
|