unione 1.1.3

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.
Files changed (146) hide show
  1. checksums.yaml +7 -0
  2. data/AGENTS.md +99 -0
  3. data/LICENSE +21 -0
  4. data/README.md +270 -0
  5. data/docs/ConfirmedEmail.md +109 -0
  6. data/docs/Domain.md +257 -0
  7. data/docs/Email.md +126 -0
  8. data/docs/EmailValidation.md +54 -0
  9. data/docs/EventDump.md +157 -0
  10. data/docs/Obsolete.md +119 -0
  11. data/docs/Project.md +174 -0
  12. data/docs/Suppression.md +163 -0
  13. data/docs/System.md +73 -0
  14. data/docs/Tag.md +73 -0
  15. data/docs/Template.md +164 -0
  16. data/docs/Webhook.md +182 -0
  17. data/lib/unione/api/confirmed_email/confirmed_email_api.rb +47 -0
  18. data/lib/unione/api/confirmed_email/model/confirmed_email.rb +49 -0
  19. data/lib/unione/api/confirmed_email/model/confirmed_email_create_response.rb +50 -0
  20. data/lib/unione/api/confirmed_email/model/confirmed_email_delete_response.rb +50 -0
  21. data/lib/unione/api/confirmed_email/model/confirmed_email_list_response.rb +50 -0
  22. data/lib/unione/api/confirmed_email/model/confirmed_email_request.rb +42 -0
  23. data/lib/unione/api/domain/domain_api.rb +129 -0
  24. data/lib/unione/api/domain/model/dkim_status.rb +18 -0
  25. data/lib/unione/api/domain/model/domain_delete_request.rb +42 -0
  26. data/lib/unione/api/domain/model/domain_delete_response.rb +51 -0
  27. data/lib/unione/api/domain/model/domain_get_dns_records_request.rb +42 -0
  28. data/lib/unione/api/domain/model/domain_get_dns_records_response.rb +76 -0
  29. data/lib/unione/api/domain/model/domain_get_sandbox_domain_response.rb +51 -0
  30. data/lib/unione/api/domain/model/domain_list_request.rb +60 -0
  31. data/lib/unione/api/domain/model/domain_list_response.rb +51 -0
  32. data/lib/unione/api/domain/model/domain_list_response_domains_item.rb +58 -0
  33. data/lib/unione/api/domain/model/domain_list_response_domains_item_dkim.rb +52 -0
  34. data/lib/unione/api/domain/model/domain_list_response_domains_item_verification_record.rb +50 -0
  35. data/lib/unione/api/domain/model/domain_validate_dkim_request.rb +42 -0
  36. data/lib/unione/api/domain/model/domain_validate_dkim_response.rb +51 -0
  37. data/lib/unione/api/domain/model/domain_validate_verification_record_request.rb +42 -0
  38. data/lib/unione/api/domain/model/domain_validate_verification_record_response.rb +51 -0
  39. data/lib/unione/api/email/email_api.rb +56 -0
  40. data/lib/unione/api/email/model/email_send_request.rb +42 -0
  41. data/lib/unione/api/email/model/email_send_response.rb +83 -0
  42. data/lib/unione/api/email/model/email_subscribe_request.rb +58 -0
  43. data/lib/unione/api/email/model/message_object.rb +291 -0
  44. data/lib/unione/api/email/model/message_object_options.rb +70 -0
  45. data/lib/unione/api/email/model/message_object_recipients_item.rb +77 -0
  46. data/lib/unione/api/email_validation/email_validation_api.rb +34 -0
  47. data/lib/unione/api/email_validation/model/email_validation_single_request.rb +42 -0
  48. data/lib/unione/api/email_validation/model/email_validation_single_response.rb +140 -0
  49. data/lib/unione/api/event_dump/event_dump_api.rb +67 -0
  50. data/lib/unione/api/event_dump/model/event_dump_create_request.rb +119 -0
  51. data/lib/unione/api/event_dump/model/event_dump_create_response.rb +52 -0
  52. data/lib/unione/api/event_dump/model/event_dump_delete_request.rb +43 -0
  53. data/lib/unione/api/event_dump/model/event_dump_files_object.rb +51 -0
  54. data/lib/unione/api/event_dump/model/event_dump_get_request.rb +43 -0
  55. data/lib/unione/api/event_dump/model/event_dump_get_response.rb +51 -0
  56. data/lib/unione/api/event_dump/model/event_dump_list_response.rb +52 -0
  57. data/lib/unione/api/event_dump/model/event_dump_object.rb +66 -0
  58. data/lib/unione/api/event_dump/model/filter_object.rb +139 -0
  59. data/lib/unione/api/obsolete/model/obsolete_unsubscribed_check_request.rb +42 -0
  60. data/lib/unione/api/obsolete/model/obsolete_unsubscribed_check_response.rb +59 -0
  61. data/lib/unione/api/obsolete/model/obsolete_unsubscribed_list_request.rb +43 -0
  62. data/lib/unione/api/obsolete/model/obsolete_unsubscribed_list_response.rb +51 -0
  63. data/lib/unione/api/obsolete/model/obsolete_unsubscribed_list_response_unsubscribed_item.rb +50 -0
  64. data/lib/unione/api/obsolete/model/obsolete_unsubscribed_set_message.rb +25 -0
  65. data/lib/unione/api/obsolete/model/obsolete_unsubscribed_set_request.rb +42 -0
  66. data/lib/unione/api/obsolete/model/obsolete_unsubscribed_set_response.rb +64 -0
  67. data/lib/unione/api/obsolete/obsolete_api.rb +57 -0
  68. data/lib/unione/api/project/model/project_create_request.rb +42 -0
  69. data/lib/unione/api/project/model/project_create_response.rb +60 -0
  70. data/lib/unione/api/project/model/project_delete_request.rb +52 -0
  71. data/lib/unione/api/project/model/project_list_object.rb +146 -0
  72. data/lib/unione/api/project/model/project_list_request.rb +50 -0
  73. data/lib/unione/api/project/model/project_list_response.rb +51 -0
  74. data/lib/unione/api/project/model/project_object.rb +94 -0
  75. data/lib/unione/api/project/model/project_update_object.rb +130 -0
  76. data/lib/unione/api/project/model/project_update_request.rb +60 -0
  77. data/lib/unione/api/project/model/project_update_response.rb +52 -0
  78. data/lib/unione/api/project/project_api.rb +71 -0
  79. data/lib/unione/api/suppression/model/suppression_delete_request.rb +42 -0
  80. data/lib/unione/api/suppression/model/suppression_get_object.rb +91 -0
  81. data/lib/unione/api/suppression/model/suppression_get_request.rb +52 -0
  82. data/lib/unione/api/suppression/model/suppression_get_response.rb +59 -0
  83. data/lib/unione/api/suppression/model/suppression_list_object.rb +91 -0
  84. data/lib/unione/api/suppression/model/suppression_list_request.rb +94 -0
  85. data/lib/unione/api/suppression/model/suppression_list_response.rb +61 -0
  86. data/lib/unione/api/suppression/model/suppression_set_request.rb +69 -0
  87. data/lib/unione/api/suppression/suppression_api.rb +63 -0
  88. data/lib/unione/api/system/model/project_accounting_object.rb +62 -0
  89. data/lib/unione/api/system/model/system_info_response.rb +95 -0
  90. data/lib/unione/api/system/model/system_info_response_accounting.rb +68 -0
  91. data/lib/unione/api/system/model/system_ping_response.rb +51 -0
  92. data/lib/unione/api/system/system_api.rb +35 -0
  93. data/lib/unione/api/tag/model/tag_delete_request.rb +42 -0
  94. data/lib/unione/api/tag/model/tag_list_response.rb +51 -0
  95. data/lib/unione/api/tag/model/tags_response_object.rb +50 -0
  96. data/lib/unione/api/tag/tag_api.rb +40 -0
  97. data/lib/unione/api/template/model/editor_type.rb +19 -0
  98. data/lib/unione/api/template/model/template_delete_request.rb +42 -0
  99. data/lib/unione/api/template/model/template_get_request.rb +42 -0
  100. data/lib/unione/api/template/model/template_get_response.rb +51 -0
  101. data/lib/unione/api/template/model/template_list_object.rb +232 -0
  102. data/lib/unione/api/template/model/template_list_request.rb +52 -0
  103. data/lib/unione/api/template/model/template_list_response.rb +51 -0
  104. data/lib/unione/api/template/model/template_object.rb +201 -0
  105. data/lib/unione/api/template/model/template_set_request.rb +42 -0
  106. data/lib/unione/api/template/model/template_set_response.rb +51 -0
  107. data/lib/unione/api/template/template_api.rb +66 -0
  108. data/lib/unione/api/webhook/model/block_type.rb +20 -0
  109. data/lib/unione/api/webhook/model/device_type.rb +22 -0
  110. data/lib/unione/api/webhook/model/domain_status.rb +19 -0
  111. data/lib/unione/api/webhook/model/event_name.rb +19 -0
  112. data/lib/unione/api/webhook/model/traffic_type.rb +24 -0
  113. data/lib/unione/api/webhook/model/webhook_callback.rb +52 -0
  114. data/lib/unione/api/webhook/model/webhook_callback_events_by_user_item.rb +66 -0
  115. data/lib/unione/api/webhook/model/webhook_callback_events_by_user_item_events_item.rb +52 -0
  116. data/lib/unione/api/webhook/model/webhook_callback_events_by_user_item_events_item_event_data.rb +167 -0
  117. data/lib/unione/api/webhook/model/webhook_callback_events_by_user_item_events_item_event_data_delivery_info.rb +192 -0
  118. data/lib/unione/api/webhook/model/webhook_delete_request.rb +42 -0
  119. data/lib/unione/api/webhook/model/webhook_event_format.rb +18 -0
  120. data/lib/unione/api/webhook/model/webhook_events_object.rb +52 -0
  121. data/lib/unione/api/webhook/model/webhook_get_request.rb +42 -0
  122. data/lib/unione/api/webhook/model/webhook_get_response.rb +51 -0
  123. data/lib/unione/api/webhook/model/webhook_list_request.rb +51 -0
  124. data/lib/unione/api/webhook/model/webhook_list_response.rb +51 -0
  125. data/lib/unione/api/webhook/model/webhook_object.rb +123 -0
  126. data/lib/unione/api/webhook/model/webhook_set_request.rb +109 -0
  127. data/lib/unione/api/webhook/model/webhook_set_response.rb +51 -0
  128. data/lib/unione/api/webhook/model/webhook_status.rb +21 -0
  129. data/lib/unione/api/webhook/webhook_api.rb +89 -0
  130. data/lib/unione/client/api_client.rb +93 -0
  131. data/lib/unione/client/api_error.rb +22 -0
  132. data/lib/unione/client/configuration.rb +49 -0
  133. data/lib/unione/client/decode.rb +33 -0
  134. data/lib/unione/common/model/attachments_array_item.rb +59 -0
  135. data/lib/unione/common/model/body_object.rb +57 -0
  136. data/lib/unione/common/model/email_counter_mode.rb +21 -0
  137. data/lib/unione/common/model/email_status.rb +23 -0
  138. data/lib/unione/common/model/headers_object.rb +72 -0
  139. data/lib/unione/common/model/inline_attachments_array_item.rb +59 -0
  140. data/lib/unione/common/model/success_response.rb +41 -0
  141. data/lib/unione/common/model/template_engine.rb +19 -0
  142. data/lib/unione/common/model/verification_record_status.rb +16 -0
  143. data/lib/unione/uni_one_client.rb +127 -0
  144. data/lib/unione/version.rb +5 -0
  145. data/lib/unione.rb +130 -0
  146. metadata +187 -0
@@ -0,0 +1,291 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UniOne
4
+ module Api
5
+ module Email
6
+ module Model
7
+ # Object containing all message properties.
8
+ class MessageObject
9
+ # Contains recipient emails, substitutions(merge tags) and metadata.
10
+ # @return [Array<MessageObjectRecipientsItem>, nil]
11
+ attr_accessor :recipients
12
+
13
+ # Optional identifier of the template that had been created by
14
+ # [template/set](https://docs.unione.io/en/web-api-ref#template-set) method. If template_id is passed
15
+ # then fields from the template are used instead of missed email/send parameters. E.g. if "body"
16
+ # parameter in email/send is omitted, "body" from template will be used. If "subject" in email/send is
17
+ # omitted, "subject" from template will be used.
18
+ # @return [String, nil]
19
+ attr_accessor :template_id
20
+
21
+ # An array of strings. The maximum string length is 100 characters. You can include up to 4 strings
22
+ # which must be unique. No more than 10 000 tags are allowed per project; if you try to add more,
23
+ # email/send will return an error. You may use tags to categorize emails by your own criteria, and
24
+ # they will be passed along by event-dump methods.
25
+ # @return [Array<String>, nil]
26
+ attr_accessor :tags
27
+
28
+ # Whether to skip or not appending default unsubscribe footer. 1=skip, 0=append, default is 0. You
29
+ # should [ask support](https://cp.unione.io/en/support) to approve
30
+ # usage of skip_unsubscribe=1. [Read more](https://docs.unione.io/en/unsubscribe-link).
31
+ # Allowed values: `0`, `1`.
32
+ # @return [Integer, nil]
33
+ attr_accessor :skip_unsubscribe
34
+
35
+ # The language of the unsubscribe footer and unsubscribe page. Languages supported are: "be", "de",
36
+ # "en", "es", "fr", "it", "pl", "pt", "ru", "ua", "kz".
37
+ # @return [String, nil]
38
+ attr_accessor :global_language
39
+
40
+ # The [template engine](https://docs.unione.io/en/template-engines) for handling the
41
+ # substitutions(merge tags), "simple", "velocity", "liquid" or "none". Default value is "simple".
42
+ # @return [TemplateEngine, nil]
43
+ attr_accessor :template_engine
44
+
45
+ # Object for passing the substitutions(merge tags) common for all recipients - e.g., company name. If
46
+ # the substitution names are duplicated in object "substitutions", the values of the variables will be
47
+ # taken from the object "substitutions". The substitutions can be used in the following parameters:
48
+ #
49
+ # - body.html
50
+ # - body.plaintext
51
+ # - body.amp
52
+ # - subject
53
+ # - from_name
54
+ # - options.unsubscribe_url
55
+ # A substitution name can consist from latin characeters, numbers and "_" symbol, and should start
56
+ # with the letter.
57
+ # @return [Hash{String => String}, nil]
58
+ attr_accessor :global_substitutions
59
+
60
+ # Object for passing the metadata common for all the recipients, such as "key": "value". Max key
61
+ # quantity: 10. Max key length: 64 symbols. Max value length: 1024 symbols. The metadata is returned
62
+ # by [webhook](https://docs.unione.io/en/web-api-ref#webhook). To group single emails into a campaign,
63
+ # you can use the system key 'campaign_id' with a value in the form of a non-negative decimal integer
64
+ # up to 128 bits or a UUID in the format 'c7703772-453e-4c77-a9ae-9a1b94051b5a'. Incorrect values will
65
+ # be treated as '0'.
66
+ # @return [Hash{String => String}, nil]
67
+ attr_accessor :global_metadata
68
+
69
+ # Contains HTML/plaintext/AMP parts of the email. Either html or plaintext part is required.
70
+ # @return [BodyObject, nil]
71
+ attr_accessor :body
72
+
73
+ # Email subject.
74
+ # @return [String, nil]
75
+ attr_accessor :subject
76
+
77
+ # Sender's email. Required only if template_id parameter is empty.
78
+ # @return [String, nil]
79
+ attr_accessor :from_email
80
+
81
+ # Sender's name.
82
+ # @return [String, nil]
83
+ attr_accessor :from_name
84
+
85
+ # Optional Reply-To email (in case it's different to sender's email)
86
+ # @return [String, nil]
87
+ attr_accessor :reply_to
88
+
89
+ # Optional Reply-To name (if reply_to email is specified and you want to display not only this email
90
+ # but also the name)
91
+ # @return [String, nil]
92
+ attr_accessor :reply_to_name
93
+
94
+ # 1 = click tracking is on (default), 0 = click tracking is off. To use track_links = 0, you need to
95
+ # ask support to enable this feature.
96
+ # Allowed values: `0`, `1`.
97
+ # @return [Integer, nil]
98
+ attr_accessor :track_links
99
+
100
+ # 1 = read tracking is on (default), 0=read tracking is off. To use track_read = 0, you need to ask
101
+ # support to enable this feature.
102
+ # Allowed values: `0`, `1`.
103
+ # @return [Integer, nil]
104
+ attr_accessor :track_read
105
+
106
+ # (allowed values 0 or 1, default 0) If set to 1, the global unavailability list will be ignored. Even
107
+ # if the address was found to be unreachable while sending other UniOne users' emails, or its owner
108
+ # has issued complaints, the message will still be sent. The setting may be ignored for certain
109
+ # addresses.
110
+ # Allowed values: `0`, `1`.
111
+ # @return [Integer, nil]
112
+ attr_accessor :bypass_global
113
+
114
+ # (allowed values 0 or 1, default 0) If set to 1, the current user's or project's unavailability list
115
+ # will be ignored. Works only if bypass_global is set to 1.
116
+ # Allowed values: `0`, `1`.
117
+ # @return [Integer, nil]
118
+ attr_accessor :bypass_unavailable
119
+
120
+ # (allowed values 0 or 1, default 0) If set to 1, the current list of unsubscribed addresses for this
121
+ # account or project will be ignored. Works only if bypass_global is set to 1. The setting is
122
+ # available only for users that have been granted the right to omit the unsubscribe link (to request,
123
+ # please contact [support](https://cp.unione.io/en/support)).
124
+ # Allowed values: `0`, `1`.
125
+ # @return [Integer, nil]
126
+ attr_accessor :bypass_unsubscribed
127
+
128
+ # (allowed values 0 or 1, default 0) If set to 1, the user's or project's complaint list will be
129
+ # ignored. Works only if bypass_global is set to 1. The setting is available only for users that have
130
+ # been granted the right to omit the unsubscribe link (to request, please contact
131
+ # [support](https://cp.unione.io/en/support)).
132
+ # Allowed values: `0`, `1`.
133
+ # @return [Integer, nil]
134
+ attr_accessor :bypass_complained
135
+
136
+ # A string of up to 64 characters containing a unique message key. This can be used to prevent
137
+ # occasional message duplicates. If you send another API request with the same message key within the
138
+ # next minute, it will be declined. We can generate a message key for each letter automatically; to
139
+ # enable this option, please contact our [tech support](https://cp.unione.io/en/support).
140
+ # @return [String, nil]
141
+ attr_accessor :idempotence_key
142
+
143
+ # Contains email headers, maximum 50. Only headers with “X-” name prefix are accepted, all other are
144
+ # ignored, for example X-UNIONE-Global-Language, X-UNIONE-Template-Engine. Standard headers "To,"
145
+ # "CC," and "BCC" are passed without the "X-." Yet, they are processed in a particular way and, as a
146
+ # result, have a number of restrictions. You can find more details about it [here](/cc-and-bcc). If
147
+ # our support have approved omitting standard unsubscription block for you, you can also pass
148
+ # List-Unsubscribe, List-Subscribe, List-Help, List-Owner, List-Archive, In-Reply-To and References
149
+ # headers.
150
+ # @return [HeadersObject, nil]
151
+ attr_accessor :headers
152
+
153
+ # Optional array of attachments
154
+ # @return [Array<AttachmentsArrayItem>, nil]
155
+ attr_accessor :attachments
156
+
157
+ # Optional array of inline attachments, e.g. for including images in email instead of loading them
158
+ # from external URL.
159
+ # @return [Array<InlineAttachmentsArrayItem>, nil]
160
+ attr_accessor :inline_attachments
161
+
162
+ # Additional message options.
163
+ # @return [MessageObjectOptions, nil]
164
+ attr_accessor :options
165
+
166
+ def initialize(
167
+ recipients:,
168
+ body:,
169
+ subject:,
170
+ template_id: nil,
171
+ tags: nil,
172
+ skip_unsubscribe: nil,
173
+ global_language: nil,
174
+ template_engine: nil,
175
+ global_substitutions: nil,
176
+ global_metadata: nil,
177
+ from_email: nil,
178
+ from_name: nil,
179
+ reply_to: nil,
180
+ reply_to_name: nil,
181
+ track_links: nil,
182
+ track_read: nil,
183
+ bypass_global: nil,
184
+ bypass_unavailable: nil,
185
+ bypass_unsubscribed: nil,
186
+ bypass_complained: nil,
187
+ idempotence_key: nil,
188
+ headers: nil,
189
+ attachments: nil,
190
+ inline_attachments: nil,
191
+ options: nil
192
+ )
193
+ @recipients = recipients
194
+ @template_id = template_id
195
+ @tags = tags
196
+ @skip_unsubscribe = skip_unsubscribe
197
+ @global_language = global_language
198
+ @template_engine = template_engine
199
+ @global_substitutions = global_substitutions
200
+ @global_metadata = global_metadata
201
+ @body = body
202
+ @subject = subject
203
+ @from_email = from_email
204
+ @from_name = from_name
205
+ @reply_to = reply_to
206
+ @reply_to_name = reply_to_name
207
+ @track_links = track_links
208
+ @track_read = track_read
209
+ @bypass_global = bypass_global
210
+ @bypass_unavailable = bypass_unavailable
211
+ @bypass_unsubscribed = bypass_unsubscribed
212
+ @bypass_complained = bypass_complained
213
+ @idempotence_key = idempotence_key
214
+ @headers = headers
215
+ @attachments = attachments
216
+ @inline_attachments = inline_attachments
217
+ @options = options
218
+ end
219
+
220
+ # Builds the object from decoded JSON. Lenient: a missing field, nil or a value of another type
221
+ # gives nil (data that is not a Hash gives an empty object).
222
+ def self.from_h(data)
223
+ data = {} unless data.is_a?(Hash)
224
+ new(
225
+ recipients: ::UniOne::Client::Decode.list(data['recipients']) { |item0| ::UniOne::Client::Decode.model(::UniOne::Api::Email::Model::MessageObjectRecipientsItem, item0) },
226
+ body: ::UniOne::Client::Decode.model(::UniOne::Common::Model::BodyObject, data['body']),
227
+ subject: data['subject'],
228
+ template_id: data['template_id'],
229
+ tags: ::UniOne::Client::Decode.list(data['tags']),
230
+ skip_unsubscribe: data['skip_unsubscribe'],
231
+ global_language: data['global_language'],
232
+ template_engine: data['template_engine'],
233
+ global_substitutions: ::UniOne::Client::Decode.map(data['global_substitutions']),
234
+ global_metadata: ::UniOne::Client::Decode.map(data['global_metadata']),
235
+ from_email: data['from_email'],
236
+ from_name: data['from_name'],
237
+ reply_to: data['reply_to'],
238
+ reply_to_name: data['reply_to_name'],
239
+ track_links: data['track_links'],
240
+ track_read: data['track_read'],
241
+ bypass_global: data['bypass_global'],
242
+ bypass_unavailable: data['bypass_unavailable'],
243
+ bypass_unsubscribed: data['bypass_unsubscribed'],
244
+ bypass_complained: data['bypass_complained'],
245
+ idempotence_key: data['idempotence_key'],
246
+ headers: ::UniOne::Client::Decode.model(::UniOne::Common::Model::HeadersObject, data['headers']),
247
+ attachments: ::UniOne::Client::Decode.list(data['attachments']) { |item0| ::UniOne::Client::Decode.model(::UniOne::Common::Model::AttachmentsArrayItem, item0) },
248
+ inline_attachments: ::UniOne::Client::Decode.list(data['inline_attachments']) { |item0| ::UniOne::Client::Decode.model(::UniOne::Common::Model::InlineAttachmentsArrayItem, item0) },
249
+ options: ::UniOne::Client::Decode.model(::UniOne::Api::Email::Model::MessageObjectOptions, data['options'])
250
+ )
251
+ end
252
+
253
+ # JSON-ready hash, nil fields are omitted.
254
+ def to_h
255
+ {
256
+ 'recipients' => @recipients.nil? ? nil : @recipients.map { |item0| item0.to_h },
257
+ 'template_id' => @template_id,
258
+ 'tags' => @tags,
259
+ 'skip_unsubscribe' => @skip_unsubscribe,
260
+ 'global_language' => @global_language,
261
+ 'template_engine' => @template_engine,
262
+ 'global_substitutions' => @global_substitutions,
263
+ 'global_metadata' => @global_metadata,
264
+ 'body' => @body.nil? ? nil : @body.to_h,
265
+ 'subject' => @subject,
266
+ 'from_email' => @from_email,
267
+ 'from_name' => @from_name,
268
+ 'reply_to' => @reply_to,
269
+ 'reply_to_name' => @reply_to_name,
270
+ 'track_links' => @track_links,
271
+ 'track_read' => @track_read,
272
+ 'bypass_global' => @bypass_global,
273
+ 'bypass_unavailable' => @bypass_unavailable,
274
+ 'bypass_unsubscribed' => @bypass_unsubscribed,
275
+ 'bypass_complained' => @bypass_complained,
276
+ 'idempotence_key' => @idempotence_key,
277
+ 'headers' => @headers.nil? ? nil : @headers.to_h,
278
+ 'attachments' => @attachments.nil? ? nil : @attachments.map { |item0| item0.to_h },
279
+ 'inline_attachments' => @inline_attachments.nil? ? nil : @inline_attachments.map { |item0| item0.to_h },
280
+ 'options' => @options.nil? ? nil : @options.to_h,
281
+ }.compact
282
+ end
283
+
284
+ def to_json(*args)
285
+ to_h.to_json(*args)
286
+ end
287
+ end
288
+ end
289
+ end
290
+ end
291
+ end
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UniOne
4
+ module Api
5
+ module Email
6
+ module Model
7
+ # Additional message options.
8
+ class MessageObjectOptions
9
+ # Date and time in "YYYY-MM-DD hh:mm:ss" format in the UTC timezone. Allows schedule sending up to 24
10
+ # hours in advance.
11
+ # @return [String, nil]
12
+ attr_accessor :send_at
13
+
14
+ # Custom unsubscribe link. Read more [here](https://docs.unione.io/en/unsubscribe-link).
15
+ # @return [String, nil]
16
+ attr_accessor :unsubscribe_url
17
+
18
+ # Backend-domain identifier to send message with. If custom_backend_id is not set, default one for
19
+ # your account/project will be used. You can pay for one or more dedicated IPs and use this option.
20
+ # @return [Integer, nil]
21
+ attr_accessor :custom_backend_id
22
+
23
+ # SMTP pool identifier to send message with. Usually you don't need to pass this parameter because
24
+ # correct smtp_pool_id is selected automatically based on the default one for your account/project or
25
+ # according to custom_backend_id parameter.
26
+ # @return [String, nil]
27
+ attr_accessor :smtp_pool_id
28
+
29
+ def initialize(
30
+ send_at: nil,
31
+ unsubscribe_url: nil,
32
+ custom_backend_id: nil,
33
+ smtp_pool_id: nil
34
+ )
35
+ @send_at = send_at
36
+ @unsubscribe_url = unsubscribe_url
37
+ @custom_backend_id = custom_backend_id
38
+ @smtp_pool_id = smtp_pool_id
39
+ end
40
+
41
+ # Builds the object from decoded JSON. Lenient: a missing field, nil or a value of another type
42
+ # gives nil (data that is not a Hash gives an empty object).
43
+ def self.from_h(data)
44
+ data = {} unless data.is_a?(Hash)
45
+ new(
46
+ send_at: data['send_at'],
47
+ unsubscribe_url: data['unsubscribe_url'],
48
+ custom_backend_id: data['custom_backend_id'],
49
+ smtp_pool_id: data['smtp_pool_id']
50
+ )
51
+ end
52
+
53
+ # JSON-ready hash, nil fields are omitted.
54
+ def to_h
55
+ {
56
+ 'send_at' => @send_at,
57
+ 'unsubscribe_url' => @unsubscribe_url,
58
+ 'custom_backend_id' => @custom_backend_id,
59
+ 'smtp_pool_id' => @smtp_pool_id,
60
+ }.compact
61
+ end
62
+
63
+ def to_json(*args)
64
+ to_h.to_json(*args)
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UniOne
4
+ module Api
5
+ module Email
6
+ module Model
7
+ # MessageObjectRecipientsItem
8
+ class MessageObjectRecipientsItem
9
+ # Recipient email
10
+ # @return [String, nil]
11
+ attr_accessor :email
12
+
13
+ # Object to pass the substitutions(merge tags) for the recipient (e.g. recipient name, discount code,
14
+ # password change link, etc. See [Template engines](https://docs.unione.io/en/template-engines)). The
15
+ # substitutions can be used in the following parameters:
16
+ #
17
+ # - body.html
18
+ # - body.plaintext
19
+ # - body.amp
20
+ # - subject
21
+ # - from_name
22
+ # - headers["List-Unsubscribe"]
23
+ # - options.unsubscribe_url
24
+ # A substitution name can consist from latin characters, numbers and "_" symbol, and should start with
25
+ # the letter. There's a special substitution "to_name" which is used to put recipent's name like "Name
26
+ # Surname" to include it to SMTP header "To" in the form "Name Surname <email@example.com>". The
27
+ # "to_name" length is limited to 78 symbols.
28
+ # @return [Hash{String => String}, nil]
29
+ attr_accessor :substitutions
30
+
31
+ # Object for passing the metadata, such as "key": "value". Max key quantity: 10. Max key length: 64
32
+ # symbols. Max value length: 1024 symbols. The metadata is returned by
33
+ # [webhook](https://docs.unione.io/en/web-api-ref#webhook) and
34
+ # [event-dump](https://docs.unione.io/en/web-api-ref#event-dump) methods. If you pass strign up to 128
35
+ # bit with "campaign_id" field name (name is configurable thru support), it will be considered as
36
+ # campaign identifier in statistics.
37
+ # @return [Hash{String => String}, nil]
38
+ attr_accessor :metadata
39
+
40
+ def initialize(
41
+ email:,
42
+ substitutions: nil,
43
+ metadata: nil
44
+ )
45
+ @email = email
46
+ @substitutions = substitutions
47
+ @metadata = metadata
48
+ end
49
+
50
+ # Builds the object from decoded JSON. Lenient: a missing field, nil or a value of another type
51
+ # gives nil (data that is not a Hash gives an empty object).
52
+ def self.from_h(data)
53
+ data = {} unless data.is_a?(Hash)
54
+ new(
55
+ email: data['email'],
56
+ substitutions: ::UniOne::Client::Decode.map(data['substitutions']),
57
+ metadata: ::UniOne::Client::Decode.map(data['metadata'])
58
+ )
59
+ end
60
+
61
+ # JSON-ready hash, nil fields are omitted.
62
+ def to_h
63
+ {
64
+ 'email' => @email,
65
+ 'substitutions' => @substitutions,
66
+ 'metadata' => @metadata,
67
+ }.compact
68
+ end
69
+
70
+ def to_json(*args)
71
+ to_h.to_json(*args)
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+
5
+ module UniOne
6
+ module Api
7
+ module EmailValidation
8
+ # Email validation methods. As a result of the check, you’ll get detailed information on email
9
+ # validity. It will help eliminate nonexistent emails, decrease the number of complaints, clean up the
10
+ # subscribers list and eventually enhance your sender reputation score. For example, you may add
11
+ # validation to a subscription form on your site to let users know they’ve just entered an invalid
12
+ # address.
13
+ class EmailValidationApi
14
+ # @param client [::UniOne::Client::ApiClient]
15
+ def initialize(client)
16
+ @client = client
17
+ end
18
+
19
+ # A maximum of two concurrent requests are allowed; if you send more requests, an error will be
20
+ # returned. Since the verification process should be completed promptly, we've set a time limit on
21
+ # email check. If we encounter a slow email server that does not respond in 5 seconds, you may get an
22
+ # “unknown” status.
23
+ #
24
+ # Documentation: https://docs.unione.io/en/web-api-ref#email-validation-single
25
+ # @param request [::UniOne::Api::EmailValidation::Model::EmailValidationSingleRequest, Hash]
26
+ # @return [::UniOne::Api::EmailValidation::Model::EmailValidationSingleResponse]
27
+ # @raise [::UniOne::Client::ApiError]
28
+ def single(request)
29
+ ::UniOne::Api::EmailValidation::Model::EmailValidationSingleResponse.from_h(@client.call('/email-validation/single.json', request.is_a?(Hash) ? request : request.to_h))
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UniOne
4
+ module Api
5
+ module EmailValidation
6
+ module Model
7
+ # EmailValidationSingleRequest
8
+ class EmailValidationSingleRequest
9
+ # Email address to be checked.
10
+ # @return [String, nil]
11
+ attr_accessor :email
12
+
13
+ def initialize(
14
+ email:
15
+ )
16
+ @email = email
17
+ end
18
+
19
+ # Builds the object from decoded JSON. Lenient: a missing field, nil or a value of another type
20
+ # gives nil (data that is not a Hash gives an empty object).
21
+ def self.from_h(data)
22
+ data = {} unless data.is_a?(Hash)
23
+ new(
24
+ email: data['email']
25
+ )
26
+ end
27
+
28
+ # JSON-ready hash, nil fields are omitted.
29
+ def to_h
30
+ {
31
+ 'email' => @email,
32
+ }.compact
33
+ end
34
+
35
+ def to_json(*args)
36
+ to_h.to_json(*args)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,140 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UniOne
4
+ module Api
5
+ module EmailValidation
6
+ module Model
7
+ # EmailValidationSingleResponse
8
+ class EmailValidationSingleResponse
9
+ # "success" string
10
+ # Allowed values: `success`.
11
+ # @return [String, nil]
12
+ attr_accessor :status
13
+
14
+ # Email address to be checked.
15
+ # @return [String, nil]
16
+ attr_accessor :email
17
+
18
+ # Possible statuses:
19
+ #
20
+ # - "valid" - the address is valid,
21
+ # - "invalid" - the address is invalid,
22
+ # - "suspicious" - the address looks suspicious,
23
+ # - "unknown" - could not perform validation, the domain’s mail server has not responded within the time limit.
24
+ # @return [String, nil]
25
+ attr_accessor :result
26
+
27
+ # Possible statuses:
28
+ #
29
+ # - "no_mx_record" - no MX record found for the target domain,
30
+ # - "syntax_error" - the address syntax is invalid,
31
+ # - "possible_typo" - the address is likely to have a typo,
32
+ # - "mailbox_not_found" - the address does not exist,
33
+ # - "global_suppression" - the address has been marked as unreachable due to multiple previous delivery errors,
34
+ # - "disposable" - this is a disposable one-time email address which is usually valid for a few minutes only,
35
+ # - "role" - the address is not likely to belong to an actual person, but rather to a certain business staff role,
36
+ # - "abuse" - the address is known to be a source of a large number of complaints, sometimes issued automatically,
37
+ # - "spamtrap" - this email is a spam trap, it is published openly but never used for actual emails. Sending messages to such addresses has a huge negative impact on reputation score,
38
+ # - "smtp_connection_failed" - the domain’s SMTP server does not respond; the address may contain a typo.
39
+ # @return [String, nil]
40
+ attr_accessor :cause
41
+
42
+ # Validity score, from 0 to 100 (0 – invalid, 100 – valid).
43
+ # @return [Integer, nil]
44
+ attr_accessor :validity
45
+
46
+ # Local part (everything preceding the @ sign).
47
+ # @return [String, nil]
48
+ attr_accessor :local_part
49
+
50
+ # Domain name part.
51
+ # @return [String, nil]
52
+ attr_accessor :domain
53
+
54
+ # True if the address’ domain does have an MX record, false if does not.
55
+ # @return [Boolean, nil]
56
+ attr_accessor :mx_found
57
+
58
+ # Preferred MX record for the domain.
59
+ # @return [String, nil]
60
+ attr_accessor :mx_record
61
+
62
+ # For addresses which are likely to have typing errors (cause=possible_typo), a suggested variant with
63
+ # a fixed typo.
64
+ # @return [String, nil]
65
+ attr_accessor :did_you_mean
66
+
67
+ # Email check date and time, YYYY-MM-DD hh:mm:ss UTC.
68
+ # @return [String, nil]
69
+ attr_accessor :processed_at
70
+
71
+ def initialize(
72
+ status: nil,
73
+ email: nil,
74
+ result: nil,
75
+ cause: nil,
76
+ validity: nil,
77
+ local_part: nil,
78
+ domain: nil,
79
+ mx_found: nil,
80
+ mx_record: nil,
81
+ did_you_mean: nil,
82
+ processed_at: nil
83
+ )
84
+ @status = status
85
+ @email = email
86
+ @result = result
87
+ @cause = cause
88
+ @validity = validity
89
+ @local_part = local_part
90
+ @domain = domain
91
+ @mx_found = mx_found
92
+ @mx_record = mx_record
93
+ @did_you_mean = did_you_mean
94
+ @processed_at = processed_at
95
+ end
96
+
97
+ # Builds the object from decoded JSON. Lenient: a missing field, nil or a value of another type
98
+ # gives nil (data that is not a Hash gives an empty object).
99
+ def self.from_h(data)
100
+ data = {} unless data.is_a?(Hash)
101
+ new(
102
+ status: data['status'],
103
+ email: data['email'],
104
+ result: data['result'],
105
+ cause: data['cause'],
106
+ validity: data['validity'],
107
+ local_part: data['local_part'],
108
+ domain: data['domain'],
109
+ mx_found: data['mx_found'],
110
+ mx_record: data['mx_record'],
111
+ did_you_mean: data['did_you_mean'],
112
+ processed_at: data['processed_at']
113
+ )
114
+ end
115
+
116
+ # JSON-ready hash, nil fields are omitted.
117
+ def to_h
118
+ {
119
+ 'status' => @status,
120
+ 'email' => @email,
121
+ 'result' => @result,
122
+ 'cause' => @cause,
123
+ 'validity' => @validity,
124
+ 'local_part' => @local_part,
125
+ 'domain' => @domain,
126
+ 'mx_found' => @mx_found,
127
+ 'mx_record' => @mx_record,
128
+ 'did_you_mean' => @did_you_mean,
129
+ 'processed_at' => @processed_at,
130
+ }.compact
131
+ end
132
+
133
+ def to_json(*args)
134
+ to_h.to_json(*args)
135
+ end
136
+ end
137
+ end
138
+ end
139
+ end
140
+ end