socketlabs-injectionapi 1.2.1 → 1.4.2

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.
@@ -20,11 +20,11 @@ module SocketLabs
20
20
  # (Optional) Either TextBody or HtmlBody must be used with the AmpBody or use a ApiTemplate
21
21
  attr_accessor :api_template
22
22
  # the custom MailingId for the message.
23
- # See https://www.injectionapi.com/blog/best-practices-for-using-custom-mailingids-and-messageids/
23
+ # See https://www.socketlabs.com/blog/best-practices-for-using-custom-mailingids-and-messageids/
24
24
  # for more information.
25
25
  attr_accessor :mailing_id
26
26
  # the custom MessageId for the message.
27
- # See https://www.injectionapi.com/blog/best-practices-for-using-custom-mailingids-and-messageids/
27
+ # See https://www.socketlabs.com/blog/best-practices-for-using-custom-mailingids-and-messageids/
28
28
  # for more information.
29
29
  attr_accessor :message_id
30
30
  # the optional character set. Default is UTF-8
@@ -77,6 +77,8 @@ module SocketLabs
77
77
 
78
78
  @attachments = Array.new
79
79
  @custom_headers = Array.new
80
+ @metadata = Array.new
81
+ @tags = Array.new
80
82
 
81
83
  end
82
84
 
@@ -140,6 +142,7 @@ module SocketLabs
140
142
  def custom_headers
141
143
  @custom_headers
142
144
  end
145
+
143
146
  # Set the list of custom message headers added to the message.
144
147
  def custom_headers=(value)
145
148
  @custom_headers = Array.new
@@ -153,6 +156,7 @@ module SocketLabs
153
156
  end
154
157
  end
155
158
  end
159
+
156
160
  # Add a CustomHeader to the message.
157
161
  # @param [String/CustomHeader] name
158
162
  # @param [String] value
@@ -168,6 +172,68 @@ module SocketLabs
168
172
 
169
173
  end
170
174
 
175
+ # Get the list of metadata added to the message.
176
+ def metadata
177
+ @metadata
178
+ end
179
+
180
+ # Set the list of metadata added to the message.
181
+ def metadata=(value)
182
+ @metadata = Array.new
183
+ unless value.nil? || value.empty?
184
+ value.each do |v1|
185
+ if v1.instance_of? Metadata
186
+ @metadata.push(v1)
187
+ else
188
+ raise StandardError("Invalid type for metadata, type of 'Metadata' was expected")
189
+ end
190
+ end
191
+ end
192
+ end
193
+
194
+ # Add a Metadata to the message.
195
+ # @param [String/Metadata] key
196
+ # @param [String] value
197
+ def add_metadata(key, value = nil)
198
+
199
+ if key.kind_of? Metadata
200
+ @metadata.push(key)
201
+
202
+ elsif key.kind_of? String
203
+ @metadata.push(Metadata.new(key, value))
204
+
205
+ end
206
+
207
+ end
208
+
209
+ # Get the list of tags added to the message.
210
+ def tags
211
+ @tags
212
+ end
213
+
214
+ # Set the list of tags added to the message.
215
+ def tags=(value)
216
+ @tags = Array.new
217
+ unless value.nil? || value.empty?
218
+ value.each do |v1|
219
+ if v1.kind_of? String
220
+ @tags.push(v1)
221
+ else
222
+ raise StandardError("Invalid type for tag, type of 'String' was expected")
223
+ end
224
+ end
225
+ end
226
+ end
227
+
228
+ # Add a Tag to the message.
229
+ # @param [String] value
230
+ def add_tag(value = nil)
231
+
232
+ if value.kind_of? String
233
+ @tags.push(value)
234
+ end
235
+
236
+ end
171
237
 
172
238
 
173
239
  end
@@ -0,0 +1,52 @@
1
+ require_relative '../core/string_extension.rb'
2
+
3
+ module SocketLabs
4
+ module InjectionApi
5
+ module Message
6
+
7
+ # Represents metadata as a key-value pair.
8
+ # Example:
9
+ #
10
+ # metadata1 = Metadata.new
11
+ # metadata1.key = "key1"
12
+ # metadata1.value = "value1"
13
+ #
14
+ # metadata2 = Metadata.new("key2", "value2")
15
+
16
+ class Metadata
17
+
18
+ # the key of the metadata item
19
+ attr_accessor :key
20
+ # the value of the metadata item
21
+ attr_accessor :value
22
+
23
+ # Initializes a new instance of the Metadata class
24
+ # @param [String] key
25
+ # @param [String] value
26
+ def initialize(
27
+ key = nil,
28
+ value = nil
29
+ )
30
+ @key = key
31
+ @value = value
32
+ end
33
+
34
+ # Determines if the Metadata is valid.
35
+ # @return [Boolean]
36
+ def is_valid
37
+ valid_key = !(@key.nil? || @key.empty?)
38
+ valid_value = !(@value.nil? || @value.empty?)
39
+
40
+ valid_key && valid_value
41
+ end
42
+
43
+ # Represents the Metadata key-value pair as a String
44
+ # @return [String]
45
+ def to_s
46
+ "#{@key}, #{@value}"
47
+ end
48
+
49
+ end
50
+ end
51
+ end
52
+ end
@@ -308,6 +308,14 @@ module SocketLabs
308
308
  :value =>37,
309
309
  :message =>"SDK Validation Error: Expected messageType of basic or bulk"
310
310
 
311
+ },
312
+
313
+ # SDK Validation Error: Message contains invalid metadata
314
+ "MessageValidationInvalidMetadata" =>
315
+ {
316
+ :name =>"MessageValidationInvalidMetadata",
317
+ :value =>38,
318
+ :message =>"SDK Validation Error: Message contains invalid metadata"
311
319
  }
312
320
 
313
321
  }
@@ -93,14 +93,29 @@ module SocketLabs
93
93
  debug_json = request_hash.to_json
94
94
  @request_json = debug_json
95
95
 
96
- http_request = HttpRequest.new(http_method, { :http_endpoint => @endpoint, :proxy => @proxy, :timeout => @request_timeout })
96
+ apiKeyParser = ApiKeyParser.new()
97
+ parseResult = apiKeyParser.parse(@api_key);
98
+
99
+ httpArguments = {
100
+ :http_endpoint => @endpoint,
101
+ :proxy => @proxy,
102
+ :timeout => @request_timeout,
103
+ :authorization => ''
104
+ }
105
+ if parseResult == ApiKeyParseResult.enum["Success"]
106
+ httpArguments[:authorization] = @api_key
107
+ request.api_key = ''
108
+ end
109
+
110
+ http_request = HttpRequest.new(http_method, httpArguments)
111
+
97
112
  retry_handler = RetryHandler.new(http_request, @endpoint, RetrySettings.new(@number_of_retries))
98
113
  response = retry_handler.send(request)
99
114
 
100
115
  parser = InjectionResponseParser.new
101
- parser.parse(response)
116
+ result = parser.parse(response)
102
117
 
103
- @response_json = parser.to_json
118
+ @response_json = result.to_json
104
119
 
105
120
  end
106
121
 
@@ -127,9 +142,9 @@ module SocketLabs
127
142
  response = retry_handler.send(request)
128
143
 
129
144
  parser = InjectionResponseParser.new
130
- parser.parse(response)
145
+ result = parser.parse(response)
131
146
 
132
- @response_json = parser.to_json
147
+ @response_json = result.to_json
133
148
 
134
149
  end
135
150
 
@@ -1,5 +1,5 @@
1
1
  module SocketLabs
2
2
  module InjectionApi
3
- VERSION = '1.2.1'
3
+ VERSION = '1.4.2'
4
4
  end
5
5
  end
@@ -1,3 +1,5 @@
1
+ require 'json'
2
+
1
3
  require_relative 'socketlabs/injectionapi/core/send_validator'
2
4
  require_relative 'socketlabs/injectionapi/core/string_extension'
3
5
  require_relative 'socketlabs/injectionapi/address_result'
@@ -14,6 +16,8 @@ require_relative 'socketlabs/injectionapi/message/bulk_recipient'
14
16
  require_relative 'socketlabs/injectionapi/message/custom_header'
15
17
  require_relative 'socketlabs/injectionapi/message/email_address'
16
18
  require_relative 'socketlabs/injectionapi/message/merge_data'
19
+
20
+ require_relative 'socketlabs/injectionapi/core/serialization/message_result_dto'
17
21
  require_relative 'socketlabs/injectionapi/core/serialization/address_json'
18
22
  require_relative 'socketlabs/injectionapi/core/serialization/attachment_json'
19
23
  require_relative 'socketlabs/injectionapi/core/serialization/custom_header_json'
@@ -24,6 +28,9 @@ require_relative 'socketlabs/injectionapi/core/serialization/merge_field_json'
24
28
  require_relative 'socketlabs/injectionapi/core/serialization/message_json'
25
29
  require_relative 'socketlabs/injectionapi/core/serialization/message_result_dto'
26
30
  require_relative 'socketlabs/injectionapi/core/injection_request_factory'
31
+ require_relative 'socketlabs/injectionapi/core/api_key_parser'
32
+ require_relative 'socketlabs/injectionapi/core/api_key_parse_result'
27
33
  require_relative 'socketlabs/injectionapi/core/http_request'
28
34
  require_relative 'socketlabs/injectionapi/core/retryhandler'
29
- require_relative 'socketlabs/injectionapi/core/http_response'
35
+ require_relative 'socketlabs/injectionapi/core/http_response'
36
+ require_relative 'socketlabs/injectionapi/exceptions/server_exception'
@@ -6,13 +6,13 @@ require 'socketlabs/version.rb'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'socketlabs-injectionapi'
8
8
  spec.version = SocketLabs::InjectionApi::VERSION
9
- spec.authors = ['David Schrenker', 'Praneeth Chandra']
9
+ spec.authors = ['David Schrenker', 'Praneeth Chandra', 'Reid Workman']
10
10
  spec.email = 'developers@socketlabs.com'
11
11
  spec.summary = 'SocketLabs Injection Api'
12
12
  spec.description = 'SocketLabs Email Delivery Ruby Client library'
13
13
  spec.homepage = 'https://github.com/socketlabs/socketlabs-ruby'
14
14
 
15
- spec.required_ruby_version = '>= 2.4'
15
+ spec.required_ruby_version = '>= 3.1.2'
16
16
 
17
17
  spec.license = 'MIT'
18
18
  files = `git ls-files -z`.split("\x0").reject do |f|
metadata CHANGED
@@ -1,15 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: socketlabs-injectionapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Schrenker
8
8
  - Praneeth Chandra
9
- autorequire:
9
+ - Reid Workman
10
+ autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2021-04-13 00:00:00.000000000 Z
13
+ date: 2023-05-22 00:00:00.000000000 Z
13
14
  dependencies: []
14
15
  description: SocketLabs Email Delivery Ruby Client library
15
16
  email: developers@socketlabs.com
@@ -18,12 +19,6 @@ extensions: []
18
19
  extra_rdoc_files: []
19
20
  files:
20
21
  - ".gitignore"
21
- - ".idea/inspectionProfiles/Project_Default.xml"
22
- - ".idea/misc.xml"
23
- - ".idea/modules.xml"
24
- - ".idea/socketlabs-ruby.iml"
25
- - ".idea/vcs.xml"
26
- - ".idea/workspace.xml"
27
22
  - CONTRIBUTING.md
28
23
  - LICENSE.MD
29
24
  - README.MD
@@ -31,6 +26,8 @@ files:
31
26
  - gemfile.lock
32
27
  - lib/socketlabs-injectionapi.rb
33
28
  - lib/socketlabs/injectionapi/address_result.rb
29
+ - lib/socketlabs/injectionapi/core/api_key_parse_result.rb
30
+ - lib/socketlabs/injectionapi/core/api_key_parser.rb
34
31
  - lib/socketlabs/injectionapi/core/http_request.rb
35
32
  - lib/socketlabs/injectionapi/core/http_response.rb
36
33
  - lib/socketlabs/injectionapi/core/injection_request_factory.rb
@@ -46,7 +43,9 @@ files:
46
43
  - lib/socketlabs/injectionapi/core/serialization/merge_field_json.rb
47
44
  - lib/socketlabs/injectionapi/core/serialization/message_json.rb
48
45
  - lib/socketlabs/injectionapi/core/serialization/message_result_dto.rb
46
+ - lib/socketlabs/injectionapi/core/serialization/metadata_json.rb
49
47
  - lib/socketlabs/injectionapi/core/string_extension.rb
48
+ - lib/socketlabs/injectionapi/exceptions/server_exception.rb
50
49
  - lib/socketlabs/injectionapi/message/attachment.rb
51
50
  - lib/socketlabs/injectionapi/message/basic_message.rb
52
51
  - lib/socketlabs/injectionapi/message/bulk_message.rb
@@ -55,6 +54,7 @@ files:
55
54
  - lib/socketlabs/injectionapi/message/email_address.rb
56
55
  - lib/socketlabs/injectionapi/message/merge_data.rb
57
56
  - lib/socketlabs/injectionapi/message/message_base.rb
57
+ - lib/socketlabs/injectionapi/message/metadata.rb
58
58
  - lib/socketlabs/injectionapi/proxy.rb
59
59
  - lib/socketlabs/injectionapi/retrysettings.rb
60
60
  - lib/socketlabs/injectionapi/send_response.rb
@@ -66,7 +66,7 @@ homepage: https://github.com/socketlabs/socketlabs-ruby
66
66
  licenses:
67
67
  - MIT
68
68
  metadata: {}
69
- post_install_message:
69
+ post_install_message:
70
70
  rdoc_options: []
71
71
  require_paths:
72
72
  - lib
@@ -74,15 +74,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
74
74
  requirements:
75
75
  - - ">="
76
76
  - !ruby/object:Gem::Version
77
- version: '2.4'
77
+ version: 3.1.2
78
78
  required_rubygems_version: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  requirements: []
84
- rubygems_version: 3.0.3
85
- signing_key:
84
+ rubygems_version: 3.4.10
85
+ signing_key:
86
86
  specification_version: 4
87
87
  summary: SocketLabs Injection Api
88
88
  test_files: []
@@ -1,7 +0,0 @@
1
- <component name="InspectionProjectProfileManager">
2
- <profile version="1.0">
3
- <option name="myName" value="Project Default" />
4
- <inspection_tool class="Rubocop" enabled="false" level="WARNING" enabled_by_default="false" />
5
- <inspection_tool class="RubyTooManyInstanceVariablesInspection" enabled="false" level="WARNING" enabled_by_default="false" />
6
- </profile>
7
- </component>
data/.idea/misc.xml DELETED
@@ -1,7 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="JavaScriptSettings">
4
- <option name="languageLevel" value="ES6" />
5
- </component>
6
- <component name="ProjectRootManager" version="2" project-jdk-name="ruby-2.2.6-p396" project-jdk-type="RUBY_SDK" />
7
- </project>
data/.idea/modules.xml DELETED
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectModuleManager">
4
- <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/socketlabs-ruby.iml" filepath="$PROJECT_DIR$/.idea/socketlabs-ruby.iml" />
6
- </modules>
7
- </component>
8
- </project>
@@ -1,12 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <module type="RUBY_MODULE" version="4">
3
- <component name="ModuleRunConfigurationManager">
4
- <shared />
5
- </component>
6
- <component name="NewModuleRootManager">
7
- <content url="file://$MODULE_DIR$" />
8
- <orderEntry type="jdk" jdkName="ruby-2.6.6-p146" jdkType="RUBY_SDK" />
9
- <orderEntry type="sourceFolder" forTests="false" />
10
- <orderEntry type="library" scope="PROVIDED" name="bundler (v2.1.4, ruby-2.6.6-p146) [gem]" level="application" />
11
- </component>
12
- </module>
data/.idea/vcs.xml DELETED
@@ -1,7 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VcsDirectoryMappings">
4
- <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
- <mapping directory="$PROJECT_DIR$/socketlabs-injectionapi-1.0.0" vcs="Git" />
6
- </component>
7
- </project>