dashamail_transactional 0.1.2 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ed5da2d563f592a2d9378f0408972f16ed502b5cf4a588378e5bba414a508bbe
4
- data.tar.gz: 8dce85754b7f2879970201bdb700f532d1d19e123e382026bcd10735d4e4f6e1
3
+ metadata.gz: f4c7efdfd6a4d83f0ac24ba8ac1680fe9741d7d1ff7993da27a51f52ead69946
4
+ data.tar.gz: 22d593e75096ea5262f00cba2d0532732ce1a15c184d42c2acd5148381d03255
5
5
  SHA512:
6
- metadata.gz: 69a1773cb820776261e3513f0f9b5c3d1986c35361f4f2d1645ee7bfda1ec8d42606ab88e22414c95481f49ae77eeafc48ece38cf4b2651167009c57bf41577e
7
- data.tar.gz: edb9065fa33ce2aa8c27f3840c29b0f95e5b39eb258eea3de58b1e8e33868e4de1bb1bf0b350450fca3c201dd35c848ed68eacd0c2096ef066f742bf6fad5c21
6
+ metadata.gz: fa575e92b016a1ad1f81472e868acccdef5e951c532f291c9da7c7d1a990abd5494c2a85111684cc96bd108a549af652ce463e244f7b5b3b48b5430209ccca0b
7
+ data.tar.gz: e2a2d9ccb63991343fb68fa37632aced40ae857386a5d81bab9a5ac18e402a4eb8dd31eb3a01ec45e8cc8f0466da4dbdee60aff5f01c64005acdf203a5daf548
data/Gemfile CHANGED
@@ -10,3 +10,4 @@ gem 'rake', '~> 13.2.1'
10
10
  gem 'minitest', '~> 5.25.4'
11
11
 
12
12
  gem 'rubocop', '~> 1.69.2'
13
+ gem 'webmock'
data/Gemfile.lock CHANGED
@@ -1,13 +1,20 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dashamail_transactional (0.1.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 'dashamail', git: 'https://github.com/creadone/dashamail'
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/creadone/dashamail.
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
+ [![Логотип проекта](images/21s.png)](https://21-school.ru/)
Binary file
@@ -92,6 +92,10 @@ module DashamailTransactional
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
@@ -92,8 +92,6 @@ module DashamailTransactional
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
@@ -26,12 +26,14 @@ module DashamailTransactional
26
26
  }.merge!(options)
27
27
  end
28
28
 
29
- def get(path, options = {})
30
- execute(path, :get, options)
29
+ def reset_headers
30
+ @headers = base_headers
31
31
  end
32
32
 
33
- def post(path, options = {})
34
- execute(path, :post, options)
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
@@ -5,30 +5,48 @@ require 'mime-types'
5
5
 
6
6
  module DashamailTransactional
7
7
  class Utils
8
- def self.build_attachment(file_path)
9
- raise StandardError, 'File not exist' unless File.exist?(file_path)
8
+ MAX_FILENAME_LENGTH = 255
10
9
 
11
- file_name = File.basename(file_path)
12
- file_body = File.open(file_path, 'rb') do |io|
13
- Base64.strict_encode64(io.read)
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
- def self.build_inline(file_path, cid)
19
- raise StandardError, 'File not exist' unless File.exist?(file_path)
42
+ def truncate_filename(filename)
43
+ return filename if filename.bytesize <= MAX_FILENAME_LENGTH
20
44
 
21
- file_name = File.basename(file_path)
22
- mime_type = MIME::Types.type_for(file_path)[0].to_s
23
- file_body = File.open(file_path, 'rb') do |io|
24
- Base64.strict_encode64(io.read)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DashamailTransactional
4
- VERSION = '0.1.2'
4
+ VERSION = "0.1.3.1"
5
5
  end
metadata CHANGED
@@ -1,10 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dashamail_transactional
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
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: []
@@ -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