socketlabs-injectionapi 1.4.2 → 1.4.4
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/README.MD +33 -30
- data/gemfile.lock +18 -18
- data/lib/socketlabs/injectionapi/core/api_key_parser.rb +1 -1
- data/lib/socketlabs/injectionapi/send_result.rb +8 -0
- data/lib/socketlabs/injectionapi/socketlabsclient.rb +14 -0
- data/lib/socketlabs/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee741c53907bad14908179b9fe0ee9d50884adfec3b5df7680bb19a5db3c7715
|
4
|
+
data.tar.gz: d9aff889b425ce7eb65efd939fbd6e7e8682632be9fe566cc6087887cb0e5762
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00c01b3e6dc055a20ed7945b06bd36a6be49dd30336621f2f8dc7453aa721e0f66a1d543ac7a2520ce606c6abf5dbe739bc3008f23669cf2ce5550bf599777b6
|
7
|
+
data.tar.gz: 8dd25c0911d4c9a1479341828e51fabe15469172e8863272609db937a8867805d4062d8f2531b385d811a824b4a9ae6847d4bdd7a7b26b24f17caec3e978cf04
|
data/README.MD
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
[](https://www.socketlabs.com/developers)
|
1
|
+
[](https://www.socketlabs.com/developers)
|
2
2
|
# [](https://twitter.com/socketlabs) [](./LICENSE) [](https://github.com/socketlabs/socketlabs-nodejs/blob/master/CONTRIBUTING.md)
|
3
3
|
|
4
4
|
The SocketLabs Email Delivery Ruby library allows you to easily send email messages via the [SocketLabs Injection API](https://www.socketlabs.com/docs/inject/). The library makes it easy to build and send any type of message supported by the API, from a simple message to a single recipient all the way to a complex bulk message sent to a group of recipients with unique merge data per recipient.
|
@@ -30,7 +30,7 @@ And then execute:
|
|
30
30
|
Install it yourself as:
|
31
31
|
|
32
32
|
$ gem install socketlabs-injectionapi
|
33
|
-
|
33
|
+
|
34
34
|
Or From git
|
35
35
|
|
36
36
|
$ gem 'socketlabs-injectionapi', :git => "https://github.com/socketlabs/socketlabs-ruby.git"
|
@@ -41,21 +41,21 @@ For more information please see the [Installing Gems](https://guides.rubygems.or
|
|
41
41
|
<a name="getting-started" id="getting-started"></a>
|
42
42
|
# Getting Started
|
43
43
|
## Obtaining your API Key and SocketLabs ServerId number
|
44
|
-
In order to get started, you'll need to enable the Injection API feature in the [SocketLabs Control Panel](https://cp.socketlabs.com).
|
45
|
-
Once logged in, navigate to your SocketLabs server's dashboard (if you only have one server on your account you'll be taken here immediately after logging in).
|
46
|
-
Make note of your 4 or 5 digit ServerId number, as you'll need this along with
|
47
|
-
your API key in order to use the Injection API.
|
44
|
+
In order to get started, you'll need to enable the Injection API feature in the [SocketLabs Control Panel](https://cp.socketlabs.com).
|
45
|
+
Once logged in, navigate to your SocketLabs server's dashboard (if you only have one server on your account you'll be taken here immediately after logging in).
|
46
|
+
Make note of your 4 or 5 digit ServerId number, as you'll need this along with
|
47
|
+
your API key in order to use the Injection API.
|
48
48
|
|
49
|
-
To enable the Injection API, click on the "For Developers" dropdown on the top-level navigation, then choose the "Configure HTTP Injection API" option.
|
49
|
+
To enable the Injection API, click on the "For Developers" dropdown on the top-level navigation, then choose the "Configure HTTP Injection API" option.
|
50
50
|
Once here, you can enable the feature by choosing the "Enabled" option in the
|
51
|
-
dropdown. Enabling the feature will also generate your API key, which you'll
|
52
|
-
need (along with your ServerId) to start using the API. Be sure to click the
|
51
|
+
dropdown. Enabling the feature will also generate your API key, which you'll
|
52
|
+
need (along with your ServerId) to start using the API. Be sure to click the
|
53
53
|
"Update" button to save your changes once you are finished.
|
54
54
|
|
55
55
|
|
56
56
|
## Basic Message
|
57
|
-
A basic message is an email message like you'd send from a personal email client such as Outlook.
|
58
|
-
A basic message can have many recipients, including multiple To addresses, CC addresses, and even BCC addresses.
|
57
|
+
A basic message is an email message like you'd send from a personal email client such as Outlook.
|
58
|
+
A basic message can have many recipients, including multiple To addresses, CC addresses, and even BCC addresses.
|
59
59
|
You can also send a file attachment in a basic message.
|
60
60
|
|
61
61
|
```ruby
|
@@ -72,7 +72,7 @@ message.plain_text_body = "This is the Plain Text Body of my message."
|
|
72
72
|
|
73
73
|
message.from_email_address = EmailAddress.new("from@example.com")
|
74
74
|
|
75
|
-
# A basic message supports up to 50 recipients
|
75
|
+
# A basic message supports up to 50 recipients
|
76
76
|
# and supports several different ways to add recipients
|
77
77
|
|
78
78
|
# Add a To address by passing the email address
|
@@ -94,9 +94,9 @@ response = client.send(message)
|
|
94
94
|
```
|
95
95
|
|
96
96
|
## Bulk Message
|
97
|
-
A bulk message usually contains a single recipient per message
|
98
|
-
and is generally used to send the same content to many recipients,
|
99
|
-
optionally customizing the message via the use of MergeData.
|
97
|
+
A bulk message usually contains a single recipient per message
|
98
|
+
and is generally used to send the same content to many recipients,
|
99
|
+
optionally customizing the message via the use of MergeData.
|
100
100
|
For more information about using Merge data, please see the [Injection API documentation](https://www.socketlabs.com/docs/inject/).
|
101
101
|
```ruby
|
102
102
|
require "socketlabs-injectionapi"
|
@@ -130,20 +130,20 @@ response = client.send(message)
|
|
130
130
|
|
131
131
|
<a name="managing-api-keys" id="managing-api-keys"></a>
|
132
132
|
## Managing API Keys
|
133
|
-
For ease of demonstration, many of our examples include the ServerId (SOCKETLABS_SERVER_ID) and API key
|
134
|
-
(SOCKETLABS_INJECTION_API_KEY) directly in our code sample. Generally it is not considered a good practice to store
|
135
|
-
sensitive information like this directly in your code. Depending on your project type, we recommend either storing your
|
136
|
-
credentials using Environment Variables. For more information please see:
|
133
|
+
For ease of demonstration, many of our examples include the ServerId (SOCKETLABS_SERVER_ID) and API key
|
134
|
+
(SOCKETLABS_INJECTION_API_KEY) directly in our code sample. Generally it is not considered a good practice to store
|
135
|
+
sensitive information like this directly in your code. Depending on your project type, we recommend either storing your
|
136
|
+
credentials using Environment Variables. For more information please see:
|
137
137
|
[Using Environment Variables](https://docs.microsoft.com/en-us/dotnet/api/system.environment.getenvironmentvariable)
|
138
138
|
|
139
139
|
|
140
140
|
<a name="examples-and-use-cases" id="examples-and-use-cases"></a>
|
141
141
|
# Examples and Use Cases
|
142
|
-
In order to demonstrate the many possible use cases for the SDK, we've provided
|
143
|
-
an assortment of code examples. These examples demonstrate many different
|
144
|
-
features available to the Injection API and SDK, including using templates
|
145
|
-
created in the [SocketLabs Email Designer](https://www.socketlabs.com/blog/introducing-new-email-designer/), custom email headers, sending
|
146
|
-
attachments, sending content that is stored in an HTML file, advanced bulk
|
142
|
+
In order to demonstrate the many possible use cases for the SDK, we've provided
|
143
|
+
an assortment of code examples. These examples demonstrate many different
|
144
|
+
features available to the Injection API and SDK, including using templates
|
145
|
+
created in the [SocketLabs Email Designer](https://www.socketlabs.com/blog/introducing-new-email-designer/), custom email headers, sending
|
146
|
+
attachments, sending content that is stored in an HTML file, advanced bulk
|
147
147
|
merging, and even pulling recipients from a datasource.
|
148
148
|
|
149
149
|
### [Basic send example](https://github.com/socketlabs/socketlabs-ruby/blob/master/examples/basic/basic_send.rb)
|
@@ -153,11 +153,11 @@ This example demonstrates a Basic Send.
|
|
153
153
|
This example demonstrates many features of the Basic Send, including adding multiple recipients, adding message and mailing id's, and adding an embedded image.
|
154
154
|
|
155
155
|
### [Basic send from HTML file](https://github.com/socketlabs/socketlabs-ruby/blob/master/examples/basic/basic_send_from_html_file.rb)
|
156
|
-
This example demonstrates how to read in your HTML content from an HTML file
|
156
|
+
This example demonstrates how to read in your HTML content from an HTML file
|
157
157
|
rather than passing in a string directly.
|
158
158
|
|
159
159
|
### [Basic send from SocketLabs Template](https://github.com/socketlabs/socketlabs-ruby/blob/master/examples/basic/basic_send_with_api_template.rb)
|
160
|
-
This example demonstrates the sending of a piece of content that was created in the
|
160
|
+
This example demonstrates the sending of a piece of content that was created in the
|
161
161
|
SocketLabs Email Designer. This is also known as the [API Templates](https://www.socketlabs.com/blog/introducing-api-templates/) feature.
|
162
162
|
|
163
163
|
### [Basic send with specified character set](https://github.com/socketlabs/socketlabs-ruby/blob/master/examples/basic/basic_send_with_ascii_charset.rb)
|
@@ -195,19 +195,19 @@ This example demonstrates the results of attempting to do a send with invalid re
|
|
195
195
|
This example demonstrates how to send a bulk message to multiple recipients.
|
196
196
|
|
197
197
|
### [Bulk send with merge data](https://github.com/socketlabs/socketlabs-ruby/blob/master/examples/bulk/bulk_send_with_merge_data.rb)
|
198
|
-
This example demonstrates how to send a bulk message to multiple recipients with
|
198
|
+
This example demonstrates how to send a bulk message to multiple recipients with
|
199
199
|
unique merge data per recipient.
|
200
200
|
|
201
201
|
### [Bulk send with complex merge including attachments](https://github.com/socketlabs/socketlabs-ruby/blob/master/examples/bulk/bulk_send_complex.rb)
|
202
|
-
This example demonstrates many features of the `BulkMessage()`, including
|
202
|
+
This example demonstrates many features of the `BulkMessage()`, including
|
203
203
|
adding multiple recipients, merge data, and adding an attachment.
|
204
204
|
|
205
205
|
### [Bulk send with recipients pulled from a datasource](https://github.com/socketlabs/socketlabs-ruby/blob/master/examples/bulk/bulk_send_from_data_source_with_merge_data.rb)
|
206
|
-
This example uses a mock repository class to demonstrate how you would pull
|
206
|
+
This example uses a mock repository class to demonstrate how you would pull
|
207
207
|
your recipients from a database and create a bulk mailing with merge data.
|
208
208
|
|
209
209
|
### [Bulk send with Ascii charset and special characters](https://github.com/socketlabs/socketlabs-ruby/blob/master/examples/bulk/bulk_send_with_ascii_charset_merge_data.rb)
|
210
|
-
This example demonstrates how to send a bulk message with a specified character
|
210
|
+
This example demonstrates how to send a bulk message with a specified character
|
211
211
|
set and special characters.
|
212
212
|
|
213
213
|
### [Bulk send with Amp ](https://github.com/socketlabs/socketlabs-ruby/blob/master/examples/bulk/bulk_send_with_amp_body.rb )
|
@@ -216,6 +216,9 @@ For more information about AMP please see [AMP Project](https://amp.dev/document
|
|
216
216
|
|
217
217
|
<a name="version"></a>
|
218
218
|
# Version
|
219
|
+
* 1.4.4 - Added MetadataOrTagsAreTooLarge error messsage
|
220
|
+
* 1.4.2 - Adding API Key Authorization
|
221
|
+
* 1.4.0 - Adding Metadata and Tags
|
219
222
|
* 1.2.1 - Adding optional retry logic for Http requests. If configured, the request will retry when certain 500 errors occur (500, 502, 503, 504)
|
220
223
|
* 1.1.1 - Adding request timeout value on the client for Http requests
|
221
224
|
* 1.1.0 - Adds Amp Html Support
|
data/gemfile.lock
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
socketlabs-injectionapi (1.4.1)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: http://rubygems.org/
|
8
|
-
specs:
|
9
|
-
|
10
|
-
PLATFORMS
|
11
|
-
x64-mingw-ucrt
|
12
|
-
x64-mingw32
|
13
|
-
|
14
|
-
DEPENDENCIES
|
15
|
-
socketlabs-injectionapi!
|
16
|
-
|
17
|
-
BUNDLED WITH
|
18
|
-
2.3.7
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
socketlabs-injectionapi (1.4.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://rubygems.org/
|
8
|
+
specs:
|
9
|
+
|
10
|
+
PLATFORMS
|
11
|
+
x64-mingw-ucrt
|
12
|
+
x64-mingw32
|
13
|
+
|
14
|
+
DEPENDENCIES
|
15
|
+
socketlabs-injectionapi!
|
16
|
+
|
17
|
+
BUNDLED WITH
|
18
|
+
2.3.7
|
@@ -9,7 +9,7 @@ module SocketLabs
|
|
9
9
|
|
10
10
|
# Parse the API key to determine what kind of key was provided.
|
11
11
|
# @param [String] wholeApiKey: A ApiKeyParseResult with the parsing results
|
12
|
-
# @return [ApiKeyParseResult] the
|
12
|
+
# @return [ApiKeyParseResult] the ApiKeyParseResult from the request
|
13
13
|
def parse(
|
14
14
|
wholeApiKey
|
15
15
|
)
|
@@ -316,6 +316,14 @@ module SocketLabs
|
|
316
316
|
:name =>"MessageValidationInvalidMetadata",
|
317
317
|
:value =>38,
|
318
318
|
:message =>"SDK Validation Error: Message contains invalid metadata"
|
319
|
+
},
|
320
|
+
|
321
|
+
# Metadata and tags exceed 12.5KB
|
322
|
+
"MetadataOrTagsAreTooLarge" =>
|
323
|
+
{
|
324
|
+
:name =>"MetadataOrTagsAreTooLarge",
|
325
|
+
:value =>39,
|
326
|
+
:message =>"Metadata and tags exceed 12.5KB"
|
319
327
|
}
|
320
328
|
|
321
329
|
}
|
@@ -137,6 +137,20 @@ module SocketLabs
|
|
137
137
|
debug_json = request_hash.to_json
|
138
138
|
@request_json = debug_json
|
139
139
|
|
140
|
+
apiKeyParser = ApiKeyParser.new()
|
141
|
+
parseResult = apiKeyParser.parse(@api_key);
|
142
|
+
|
143
|
+
httpArguments = {
|
144
|
+
:http_endpoint => @endpoint,
|
145
|
+
:proxy => @proxy,
|
146
|
+
:timeout => @request_timeout,
|
147
|
+
:authorization => ''
|
148
|
+
}
|
149
|
+
if parseResult == ApiKeyParseResult.enum["Success"]
|
150
|
+
httpArguments[:authorization] = @api_key
|
151
|
+
request.api_key = ''
|
152
|
+
end
|
153
|
+
|
140
154
|
http_request = HttpRequest.new(http_method, { :http_endpoint => @endpoint, :proxy => @proxy, :timeout => @request_timeout })
|
141
155
|
retry_handler = RetryHandler.new(http_request, @endpoint, RetrySettings.new(@number_of_retries))
|
142
156
|
response = retry_handler.send(request)
|
data/lib/socketlabs/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: socketlabs-injectionapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Schrenker
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2023-
|
13
|
+
date: 2023-10-17 00:00:00.000000000 Z
|
14
14
|
dependencies: []
|
15
15
|
description: SocketLabs Email Delivery Ruby Client library
|
16
16
|
email: developers@socketlabs.com
|