socketlabs-injectionapi 0.0.1.pre.Dev
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 +7 -0
- data/.gitignore +50 -0
- data/.idea/inspectionProfiles/Project_Default.xml +7 -0
- data/.idea/misc.xml +7 -0
- data/.idea/modules.xml +8 -0
- data/.idea/socketlabs-ruby.iml +12 -0
- data/.idea/vcs.xml +7 -0
- data/.idea/workspace.xml +452 -0
- data/LICENSE.MD +21 -0
- data/README.MD +212 -0
- data/gemfile +3 -0
- data/gemfile.lock +17 -0
- data/lib/socketlabs/injectionapi/address_result.rb +41 -0
- data/lib/socketlabs/injectionapi/core/http_request.rb +135 -0
- data/lib/socketlabs/injectionapi/core/http_response.rb +27 -0
- data/lib/socketlabs/injectionapi/core/injection_request_factory.rb +300 -0
- data/lib/socketlabs/injectionapi/core/injection_response_parser.rb +130 -0
- data/lib/socketlabs/injectionapi/core/send_validator.rb +387 -0
- data/lib/socketlabs/injectionapi/core/serialization/address_json.rb +48 -0
- data/lib/socketlabs/injectionapi/core/serialization/attachment_json.rb +60 -0
- data/lib/socketlabs/injectionapi/core/serialization/custom_header_json.rb +40 -0
- data/lib/socketlabs/injectionapi/core/serialization/injection_request.rb +56 -0
- data/lib/socketlabs/injectionapi/core/serialization/injection_response_dto.rb +77 -0
- data/lib/socketlabs/injectionapi/core/serialization/merge_data_json.rb +103 -0
- data/lib/socketlabs/injectionapi/core/serialization/merge_field_json.rb +40 -0
- data/lib/socketlabs/injectionapi/core/serialization/message_json.rb +250 -0
- data/lib/socketlabs/injectionapi/core/serialization/message_result_dto.rb +66 -0
- data/lib/socketlabs/injectionapi/core/string_extension.rb +74 -0
- data/lib/socketlabs/injectionapi/message/attachment.rb +146 -0
- data/lib/socketlabs/injectionapi/message/basic_message.rb +136 -0
- data/lib/socketlabs/injectionapi/message/bulk_message.rb +103 -0
- data/lib/socketlabs/injectionapi/message/bulk_recipient.rb +87 -0
- data/lib/socketlabs/injectionapi/message/custom_header.rb +53 -0
- data/lib/socketlabs/injectionapi/message/email_address.rb +52 -0
- data/lib/socketlabs/injectionapi/message/merge_data.rb +50 -0
- data/lib/socketlabs/injectionapi/message/message_base.rb +167 -0
- data/lib/socketlabs/injectionapi/proxy.rb +29 -0
- data/lib/socketlabs/injectionapi/send_response.rb +63 -0
- data/lib/socketlabs/injectionapi/send_result.rb +318 -0
- data/lib/socketlabs/injectionapi/socketlabsclient.rb +123 -0
- data/lib/socketlabs/version.rb +5 -0
- data/lib/socketlabs-injectionapi.rb +27 -0
- data/socketlabs-injectionapi.gemspec +25 -0
- metadata +85 -0
@@ -0,0 +1,136 @@
|
|
1
|
+
require_relative 'message_base.rb'
|
2
|
+
require_relative 'email_address.rb'
|
3
|
+
|
4
|
+
module SocketLabs
|
5
|
+
module InjectionApi
|
6
|
+
module Message
|
7
|
+
class BasicMessage < MessageBase
|
8
|
+
|
9
|
+
def initialize(arguments = nil)
|
10
|
+
super
|
11
|
+
|
12
|
+
@to_email_address = Array.new
|
13
|
+
@cc_email_address = Array.new
|
14
|
+
@bcc_email_address = Array.new
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
# Get the To EmailAddress list
|
19
|
+
def to_email_address
|
20
|
+
@to_email_address
|
21
|
+
end
|
22
|
+
# Set the To EmailAddress list
|
23
|
+
def to_email_address=(value)
|
24
|
+
@to_email_address = Array.new
|
25
|
+
convert_email_address(@to_email_address, value)
|
26
|
+
end
|
27
|
+
# Add an EmailAddress to the To recipient list.
|
28
|
+
# @param [String] email_address
|
29
|
+
# @param [String] friendly_name
|
30
|
+
def add_to_email_address(email_address, friendly_name = nil)
|
31
|
+
convert_email_address(@to_email_address, email_address, friendly_name)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Get the CC EmailAddress list
|
35
|
+
def cc_email_address
|
36
|
+
@cc_email_address
|
37
|
+
end
|
38
|
+
# Set the CC EmailAddress list
|
39
|
+
def cc_email_address=(value)
|
40
|
+
@cc_email_address = Array.new
|
41
|
+
convert_email_address(@cc_email_address, value)
|
42
|
+
end
|
43
|
+
# Add an EmailAddress to the CC recipient list.
|
44
|
+
# @param [String] email_address
|
45
|
+
# @param [String] friendly_name
|
46
|
+
def add_cc_email_address(email_address, friendly_name = nil)
|
47
|
+
convert_email_address(@cc_email_address, email_address, friendly_name)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Get the CC EmailAddress list
|
51
|
+
def bcc_email_address
|
52
|
+
@bcc_email_address
|
53
|
+
end
|
54
|
+
# Set the CC EmailAddress list
|
55
|
+
def bcc_email_address=(value)
|
56
|
+
@bcc_email_address = Array.new
|
57
|
+
convert_email_address(@bcc_email_address, value)
|
58
|
+
end
|
59
|
+
# Add an EmailAddress to the CC recipient list.
|
60
|
+
# @param [String] email_address
|
61
|
+
# @param [String] friendly_name
|
62
|
+
def add_bcc_email_address(email_address, friendly_name = nil)
|
63
|
+
convert_email_address(@bcc_email_address, email_address, friendly_name)
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
def to_s
|
68
|
+
c = @to_email_address.any? ? @to_email_address.count : 0
|
69
|
+
c = c + (@cc_email_address.any? ? @cc_email_address.count : 0)
|
70
|
+
c = c + (@bcc_email_address.any? ? @bcc_email_address.count : 0)
|
71
|
+
|
72
|
+
"Recipients: #{c}, Subject: '#{@subject}'"
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
def to_json
|
77
|
+
{
|
78
|
+
subject: @subject,
|
79
|
+
textBody: @plain_text_body,
|
80
|
+
htmlBody: @html_body,
|
81
|
+
apiTemplate: @api_template,
|
82
|
+
mailingId: @mailing_id,
|
83
|
+
messageId: @message_id,
|
84
|
+
charSet: @charset,
|
85
|
+
from: @from_email_address,
|
86
|
+
replyTo: @reply_to_email_address,
|
87
|
+
attachments: @attachments,
|
88
|
+
customHeaders: @custom_headers,
|
89
|
+
to: @to_email_address,
|
90
|
+
cc: @cc_email_address,
|
91
|
+
bcc: @bcc_email_address
|
92
|
+
}
|
93
|
+
end
|
94
|
+
|
95
|
+
private
|
96
|
+
def convert_email_address(array_instance, email_address, friendly_name = nil)
|
97
|
+
|
98
|
+
if email_address.kind_of? Array
|
99
|
+
convert_email_address_array(array_instance, email_address)
|
100
|
+
else
|
101
|
+
convert_email_address_object(array_instance, email_address, friendly_name)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def convert_email_address_object(array_instance, email_address, friendly_name = nil)
|
106
|
+
unless email_address.nil?
|
107
|
+
|
108
|
+
if email_address.kind_of? EmailAddress
|
109
|
+
array_instance.push(email_address)
|
110
|
+
|
111
|
+
elsif email_address.kind_of? String
|
112
|
+
array_instance.push(EmailAddress.new(email_address, friendly_name))
|
113
|
+
|
114
|
+
elsif email_address.kind_of? Hash or email_address.kind_of? OpenStruct
|
115
|
+
array_instance.push(EmailAddress.new(email_address[:email_address], email_address[:friendly_name]))
|
116
|
+
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
122
|
+
|
123
|
+
def convert_email_address_array(array_instance, value)
|
124
|
+
|
125
|
+
if value.kind_of? Array
|
126
|
+
value.each do |x|
|
127
|
+
convert_email_address_object(array_instance, x)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require_relative 'message_base.rb'
|
2
|
+
require_relative 'bulk_recipient.rb'
|
3
|
+
|
4
|
+
module SocketLabs
|
5
|
+
module InjectionApi
|
6
|
+
module Message
|
7
|
+
class BulkMessage < MessageBase
|
8
|
+
|
9
|
+
def initialize(arguments = nil)
|
10
|
+
super
|
11
|
+
@to_recipient = Array.new
|
12
|
+
@global_merge_data = Array.new
|
13
|
+
end
|
14
|
+
|
15
|
+
attr_accessor :global_merge_data
|
16
|
+
|
17
|
+
# Get the To BulkRecipient list
|
18
|
+
def to_recipient
|
19
|
+
@to_recipient
|
20
|
+
end
|
21
|
+
# Set the To BulkRecipient list
|
22
|
+
def to_recipient=(value)
|
23
|
+
@to_recipient = Array.new
|
24
|
+
convert_bulk_recipient(@to_email_address, value)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Add an BulkRecipient to the To recipient list.
|
28
|
+
# @param [String] email_address
|
29
|
+
# @param [String] friendly_name
|
30
|
+
# @param [Array] merge_data
|
31
|
+
def add_to_recipient(email_address, friendly_name = nil, merge_data = nil)
|
32
|
+
convert_bulk_recipient(@to_recipient, email_address, friendly_name, merge_data)
|
33
|
+
end
|
34
|
+
|
35
|
+
def add_global_merge_data(key, value)
|
36
|
+
@global_merge_data.push(MergeData.new(key, value))
|
37
|
+
end
|
38
|
+
|
39
|
+
def to_s
|
40
|
+
c = @to_recipient.any? ? @to_recipient.count : 0
|
41
|
+
"Recipients: #{c}, Subject: '#{@subject}'"
|
42
|
+
end
|
43
|
+
|
44
|
+
def to_json
|
45
|
+
{
|
46
|
+
subject: @subject,
|
47
|
+
textBody: @plain_text_body,
|
48
|
+
htmlBody: @html_body,
|
49
|
+
apiTemplate: @api_template,
|
50
|
+
mailingId: @mailing_id,
|
51
|
+
messageId: @message_id,
|
52
|
+
charSet: @charset,
|
53
|
+
from: @from_email_address,
|
54
|
+
replyTo: @reply_to_email_address,
|
55
|
+
attachments: @attachments,
|
56
|
+
customHeaders: @custom_headers,
|
57
|
+
to: @to_recipient,
|
58
|
+
global_merge_data: @global_merge_data
|
59
|
+
}
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
def convert_bulk_recipient(array_instance, recipient, friendly_name = nil, merge_data = nil)
|
64
|
+
|
65
|
+
if recipient.kind_of? Array
|
66
|
+
convert_bulk_recipient_array(array_instance, recipient)
|
67
|
+
else
|
68
|
+
convert_bulk_recipient_object(array_instance, recipient, friendly_name, merge_data)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def convert_bulk_recipient_object(array_instance, recipient, friendly_name = nil, merge_data = nil)
|
73
|
+
unless recipient.nil?
|
74
|
+
|
75
|
+
if recipient.kind_of? BulkRecipient
|
76
|
+
array_instance.push(recipient)
|
77
|
+
|
78
|
+
elsif recipient.kind_of? String
|
79
|
+
array_instance.push(BulkRecipient.new(recipient, { :friendly_name => friendly_name, :merge_data => merge_data }))
|
80
|
+
|
81
|
+
elsif recipient.kind_of? Hash or recipient.kind_of? OpenStruct
|
82
|
+
array_instance.push(BulkRecipient.new(email_address[:email_address], { :friendly_name => email_address[:friendly_name], :merge_data => email_address[:merge_data] }, ))
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
def convert_bulk_recipient_array(array_instance, value)
|
91
|
+
|
92
|
+
if value.kind_of? Array
|
93
|
+
value.each do |x|
|
94
|
+
convert_email_address_object(array_instance, x)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require_relative '../core/string_extension.rb'
|
2
|
+
|
3
|
+
module SocketLabs
|
4
|
+
module InjectionApi
|
5
|
+
module Message
|
6
|
+
|
7
|
+
# Represents an individual BulkRecipient for a message.
|
8
|
+
# Example:
|
9
|
+
# email_address1 = BulkRecipient.new("recipient@example.com")
|
10
|
+
#
|
11
|
+
# email_address2 = BulkRecipient.new("recipient@example.com", "Recipient")
|
12
|
+
#
|
13
|
+
# email_address3 = BulkRecipient.new("recipient@example.com", "Recipient")
|
14
|
+
# email_address3.merge_data.push(MergeData.new("name1", "value1"))
|
15
|
+
# email_address3.add_merge_data("name2", "value2")
|
16
|
+
class BulkRecipient
|
17
|
+
include SocketLabs::InjectionApi
|
18
|
+
include SocketLabs::InjectionApi::Core
|
19
|
+
|
20
|
+
# A valid email address.
|
21
|
+
attr_accessor :email_address
|
22
|
+
# The friendly or display name for the recipient.
|
23
|
+
attr_accessor :friendly_name
|
24
|
+
# Merge data unique to the instance of the bulk recipient.
|
25
|
+
attr_accessor :merge_data
|
26
|
+
|
27
|
+
# Creates a new instance of the BulkRecipient class.
|
28
|
+
# @param [String] email_address
|
29
|
+
# @param [Hash] arguments
|
30
|
+
def initialize(
|
31
|
+
email_address,
|
32
|
+
arguments = nil
|
33
|
+
)
|
34
|
+
@email_address = email_address
|
35
|
+
@merge_data = Array.new
|
36
|
+
|
37
|
+
unless arguments.nil? || arguments.empty?
|
38
|
+
|
39
|
+
unless arguments[:friendly_name].nil? || arguments[:friendly_name].empty?
|
40
|
+
@friendly_name = arguments[:friendly_name]
|
41
|
+
end
|
42
|
+
|
43
|
+
unless arguments[:merge_data].nil? || arguments[:merge_data].empty?
|
44
|
+
unless arguments[:merge_data].nil? || arguments[:merge_data].empty?
|
45
|
+
arguments[:merge_data].each do |value|
|
46
|
+
if value.instance_of? MergeData
|
47
|
+
@merge_data.push(value)
|
48
|
+
elsif value.instance_of? Hash
|
49
|
+
@merge_data.push(MergeData.new(value[:key], value[:value]))
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
# Add to an Array of MergeData
|
60
|
+
# @param [String] key
|
61
|
+
# @param [String] value
|
62
|
+
def add_merge_data(key, value)
|
63
|
+
@merge_data.push(MergeData.new(key, value))
|
64
|
+
end
|
65
|
+
|
66
|
+
# Determines if the BulkRecipient is valid. Does simple syntax validation on the email address.
|
67
|
+
# @return [Boolean]
|
68
|
+
def is_valid
|
69
|
+
StringExtension.new.is_valid_email_address(@email_address)
|
70
|
+
end
|
71
|
+
|
72
|
+
# Represents the BulkRecipient as a string
|
73
|
+
# @return [String]
|
74
|
+
def to_s
|
75
|
+
if @friendly_name.nil? || @friendly_name.empty?
|
76
|
+
@email_address
|
77
|
+
else
|
78
|
+
"#{@friendly_name} <#{@email_address}>"
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require_relative '../core/string_extension.rb'
|
2
|
+
|
3
|
+
module SocketLabs
|
4
|
+
module InjectionApi
|
5
|
+
module Message
|
6
|
+
|
7
|
+
# Represents a custom header as a name-value pair.
|
8
|
+
# Example:
|
9
|
+
#
|
10
|
+
# header1 = CustomHeader.new
|
11
|
+
# header1.name = "name1"
|
12
|
+
# header1.value = "value1"
|
13
|
+
#
|
14
|
+
# header2 = CustomHeader.new("name2", "value2")
|
15
|
+
|
16
|
+
class CustomHeader
|
17
|
+
|
18
|
+
# the name of the custom header
|
19
|
+
attr_accessor :name
|
20
|
+
# the value of the custom header
|
21
|
+
attr_accessor :value
|
22
|
+
|
23
|
+
# Initializes a new instance of the CustomHeader class
|
24
|
+
# @param [String] name
|
25
|
+
# @param [String] value
|
26
|
+
def initialize(
|
27
|
+
name = nil,
|
28
|
+
value = nil
|
29
|
+
)
|
30
|
+
@name = name
|
31
|
+
@value = value
|
32
|
+
end
|
33
|
+
|
34
|
+
# Determines if the CustomHeader is valid.
|
35
|
+
# @return [Boolean]
|
36
|
+
def is_valid
|
37
|
+
valid_name = !(@name.nil? || @name.empty?)
|
38
|
+
valid_value = !(@value.nil? || @value.empty?)
|
39
|
+
|
40
|
+
valid_name && valid_value
|
41
|
+
end
|
42
|
+
|
43
|
+
# Represents the CustomHeader name-value pair as a String
|
44
|
+
# @return [String]
|
45
|
+
def to_s
|
46
|
+
"#{@name}, #{@value}"
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
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 an individual email address for a message.
|
8
|
+
# Example:
|
9
|
+
# email_address = EmailAddress.new("recipient@example.com", "Recipient 1")
|
10
|
+
|
11
|
+
class EmailAddress
|
12
|
+
include SocketLabs::InjectionApi
|
13
|
+
include SocketLabs::InjectionApi::Core
|
14
|
+
|
15
|
+
# the email address
|
16
|
+
attr_accessor :email_address
|
17
|
+
# the friendly or display name
|
18
|
+
attr_accessor :friendly_name
|
19
|
+
|
20
|
+
# Initializes a new instance of the EmailAddress class
|
21
|
+
# @param [String] email_address
|
22
|
+
# @param [String] friendly_name
|
23
|
+
def initialize(
|
24
|
+
email_address,
|
25
|
+
friendly_name = nil
|
26
|
+
)
|
27
|
+
@email_address = email_address
|
28
|
+
@friendly_name = friendly_name
|
29
|
+
end
|
30
|
+
|
31
|
+
# Determines if the EmailAddress is valid. Does simple syntax validation on the email address.
|
32
|
+
# @return [Boolean]
|
33
|
+
def is_valid
|
34
|
+
StringExtension.new.is_valid_email_address(@email_address)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Represents the EmailAddress as a string
|
38
|
+
# @return [String]
|
39
|
+
def to_s
|
40
|
+
if @friendly_name.nil? || @friendly_name.empty?
|
41
|
+
@email_address
|
42
|
+
else
|
43
|
+
"#{@friendly_name} <#{@email_address}>"
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require_relative '../core/string_extension.rb'
|
2
|
+
|
3
|
+
module SocketLabs
|
4
|
+
module InjectionApi
|
5
|
+
module Message
|
6
|
+
|
7
|
+
# Represents MergeData as a key and value pair.
|
8
|
+
# Example:
|
9
|
+
# data1 = MergeData.new("key1", "value1")
|
10
|
+
|
11
|
+
class MergeData
|
12
|
+
|
13
|
+
# the MergeData key
|
14
|
+
attr_accessor :key
|
15
|
+
# the value of the custom header
|
16
|
+
attr_accessor :value
|
17
|
+
|
18
|
+
# Initializes a new instance of the CustomHeader class
|
19
|
+
# @param [String] key
|
20
|
+
# @param [String] value
|
21
|
+
def initialize(
|
22
|
+
key = nil,
|
23
|
+
value = nil
|
24
|
+
)
|
25
|
+
@key = key
|
26
|
+
@value = value
|
27
|
+
end
|
28
|
+
|
29
|
+
# A quick check to ensure that the MergeData is valid.
|
30
|
+
# @return [Boolean]
|
31
|
+
def is_valid
|
32
|
+
valid_key = StringExtension.is_nil_or_white_space(@key)
|
33
|
+
valid_value = StringExtension.is_nil_or_white_space(@value)
|
34
|
+
if valid_key && valid_value
|
35
|
+
true
|
36
|
+
end
|
37
|
+
false
|
38
|
+
end
|
39
|
+
|
40
|
+
# Represents the CustomHeader name-value pair as a String
|
41
|
+
# @return [String]
|
42
|
+
def to_s
|
43
|
+
"#{@name}, #{@value}"
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,167 @@
|
|
1
|
+
|
2
|
+
module SocketLabs
|
3
|
+
module InjectionApi
|
4
|
+
module Message
|
5
|
+
class MessageBase
|
6
|
+
|
7
|
+
public
|
8
|
+
# the message Subject.
|
9
|
+
attr_accessor :subject
|
10
|
+
# the plain text portion of the message body.
|
11
|
+
attr_accessor :plain_text_body
|
12
|
+
# the HTML portion of the message body.
|
13
|
+
attr_accessor :html_body
|
14
|
+
# the Api Template for the message.
|
15
|
+
attr_accessor :api_template
|
16
|
+
# the custom MailingId for the message.
|
17
|
+
# See https://www.injectionapi.com/blog/best-practices-for-using-custom-mailingids-and-messageids/
|
18
|
+
# for more information.
|
19
|
+
attr_accessor :mailing_id
|
20
|
+
# the custom MessageId for the message.
|
21
|
+
# See https://www.injectionapi.com/blog/best-practices-for-using-custom-mailingids-and-messageids/
|
22
|
+
# for more information.
|
23
|
+
attr_accessor :message_id
|
24
|
+
# the optional character set. Default is UTF-8
|
25
|
+
attr_accessor :charset
|
26
|
+
|
27
|
+
def initialize(arguments = nil)
|
28
|
+
|
29
|
+
unless arguments.nil? || arguments.empty?
|
30
|
+
|
31
|
+
unless arguments[:subject].nil? || arguments[:subject].empty?
|
32
|
+
@subject = arguments[:subject]
|
33
|
+
end
|
34
|
+
|
35
|
+
unless arguments[:plain_text_body].nil? || arguments[:plain_text_body].empty?
|
36
|
+
@plain_text_body = arguments[:plain_text_body]
|
37
|
+
end
|
38
|
+
|
39
|
+
unless arguments[:html_body].nil? || arguments[:html_body].empty?
|
40
|
+
@html_body = arguments[:html_body]
|
41
|
+
end
|
42
|
+
|
43
|
+
unless arguments[:api_template].nil? || arguments[:api_template].empty?
|
44
|
+
@api_template = arguments[:api_template]
|
45
|
+
end
|
46
|
+
|
47
|
+
unless arguments[:mailing_id].nil? || arguments[:mailing_id].empty?
|
48
|
+
@mailing_id = arguments[:mailing_id]
|
49
|
+
end
|
50
|
+
|
51
|
+
unless arguments[:message_id].nil? || arguments[:message_id].empty?
|
52
|
+
@message_id = arguments[:message_id]
|
53
|
+
end
|
54
|
+
|
55
|
+
unless arguments[:charset].nil? || arguments[:charset].empty?
|
56
|
+
@charset = arguments[:charset]
|
57
|
+
end
|
58
|
+
|
59
|
+
unless arguments[:charset].nil? || arguments[:charset].empty?
|
60
|
+
@charset = arguments[:charset]
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
@from_email_address = nil
|
66
|
+
@reply_to_email_address = nil
|
67
|
+
|
68
|
+
@attachments = Array.new
|
69
|
+
@custom_headers = Array.new
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
# Get the From email address.
|
74
|
+
def from_email_address
|
75
|
+
@from_email_address
|
76
|
+
end
|
77
|
+
# Set the From email address.
|
78
|
+
def from_email_address=(value)
|
79
|
+
unless value.nil?
|
80
|
+
if value.kind_of? EmailAddress
|
81
|
+
@from_email_address = value
|
82
|
+
elsif value.kind_of? String
|
83
|
+
@from_email_address = EmailAddress.new(value)
|
84
|
+
else
|
85
|
+
raise StandardError("Invalid type for reply_to_email_address, type of 'EmailAddress' or 'String' was expected")
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
# Get the optional reply to email address for the message.
|
91
|
+
def reply_to_email_address
|
92
|
+
@reply_to_email_address
|
93
|
+
end
|
94
|
+
# Set the optional reply to address for the message.
|
95
|
+
def reply_to_email_address=(value)
|
96
|
+
unless value.nil?
|
97
|
+
if value.kind_of?(EmailAddress)
|
98
|
+
@reply_to_email_address = value
|
99
|
+
elsif value.kind_of? String
|
100
|
+
@from_email_address = EmailAddress.new(value)
|
101
|
+
else
|
102
|
+
raise StandardError("Invalid type for reply_to_email_address, type of 'EmailAddress' or 'String' was expected")
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
# Get the list of attachments.
|
108
|
+
def attachments
|
109
|
+
@attachments
|
110
|
+
end
|
111
|
+
# Set the list of attachments.
|
112
|
+
def attachments=(value)
|
113
|
+
@attachments = Array.new
|
114
|
+
unless value.nil? || value.empty?
|
115
|
+
value.each do |v1|
|
116
|
+
if v1.instance_of? Attachment
|
117
|
+
@attachments.push(v1)
|
118
|
+
else
|
119
|
+
raise StandardError("Invalid type for attachments, type of 'Attachment' was expected")
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
# Add an attachment to the attachments list.
|
125
|
+
def add_attachment(value)
|
126
|
+
@attachments.push(value)
|
127
|
+
end
|
128
|
+
|
129
|
+
# Get the list of custom message headers added to the message.
|
130
|
+
def custom_headers
|
131
|
+
@custom_headers
|
132
|
+
end
|
133
|
+
# Set the list of custom message headers added to the message.
|
134
|
+
def custom_headers=(value)
|
135
|
+
@custom_headers = Array.new
|
136
|
+
unless value.nil? || value.empty?
|
137
|
+
value.each do |v1|
|
138
|
+
if v1.instance_of? CustomHeader
|
139
|
+
@custom_headers.push(v1)
|
140
|
+
else
|
141
|
+
raise StandardError("Invalid type for custom_headers, type of 'CustomHeader' was expected")
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
# Add a CustomHeader to the message.
|
147
|
+
# @param [String/CustomHeader] name
|
148
|
+
# @param [String] value
|
149
|
+
def add_custom_header(header, value = nil)
|
150
|
+
|
151
|
+
if header.kind_of? CustomHeader
|
152
|
+
@custom_headers.push(header)
|
153
|
+
|
154
|
+
elsif header.kind_of? String
|
155
|
+
@custom_headers.push(CustomHeader.new(header, value))
|
156
|
+
|
157
|
+
end
|
158
|
+
|
159
|
+
end
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module SocketLabs
|
2
|
+
module InjectionApi
|
3
|
+
|
4
|
+
# Represents a http proxy.
|
5
|
+
class Proxy
|
6
|
+
|
7
|
+
# The name of the proxy hostname
|
8
|
+
attr_accessor :host
|
9
|
+
# The value of the proxy port
|
10
|
+
attr_accessor :port
|
11
|
+
|
12
|
+
def initialize (
|
13
|
+
host= nil,
|
14
|
+
port= nil
|
15
|
+
)
|
16
|
+
@host = host
|
17
|
+
@port = port
|
18
|
+
end
|
19
|
+
|
20
|
+
# Returns the Proxy as a string.
|
21
|
+
# @return [String]
|
22
|
+
def to_s
|
23
|
+
"#{@host}:#{@port}"
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|