sendpost_ruby_sdk 1.2.2 → 2.0.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.
Files changed (293) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +21 -0
  3. data/README.md +583 -145
  4. data/docs/AccountStats.md +20 -0
  5. data/docs/AccountStatsStat.md +38 -0
  6. data/docs/AggregateStat.md +38 -0
  7. data/docs/AggregateStats.md +38 -0
  8. data/docs/AggregatedEmailStats.md +38 -0
  9. data/docs/Attachment.md +4 -4
  10. data/docs/AutoWarmupPlan.md +80 -0
  11. data/docs/CopyTo.md +5 -5
  12. data/docs/CreateDomainRequest.md +18 -0
  13. data/docs/CreateSubAccountRequest.md +18 -0
  14. data/docs/CreateSuppressionRequest.md +24 -0
  15. data/docs/CreateSuppressionRequestHardBounceInner.md +18 -0
  16. data/docs/{SuppressionEmail.md → CreateSuppressionRequestManualInner.md} +3 -3
  17. data/docs/CreateSuppressionRequestSpamComplaintInner.md +18 -0
  18. data/docs/CreateSuppressionRequestUnsubscribeInner.md +18 -0
  19. data/docs/CreateWebhookRequest.md +46 -0
  20. data/docs/DeleteResponse.md +2 -2
  21. data/docs/DeleteSubAccountResponse.md +20 -0
  22. data/docs/DeleteSuppression200ResponseInner.md +20 -0
  23. data/docs/DeleteSuppressionRequest.md +18 -0
  24. data/docs/DeleteWebhookResponse.md +20 -0
  25. data/docs/Device.md +1 -1
  26. data/docs/Domain.md +56 -0
  27. data/docs/DomainApi.md +301 -0
  28. data/docs/DomainDkim.md +22 -0
  29. data/docs/DomainDmarc.md +22 -0
  30. data/docs/DomainGpt.md +22 -0
  31. data/docs/DomainReturnPath.md +22 -0
  32. data/docs/DomainSpf.md +22 -0
  33. data/docs/DomainTrack.md +22 -0
  34. data/docs/EIP.md +18 -0
  35. data/docs/{From.md → EmailAddress.md} +4 -4
  36. data/docs/EmailApi.md +38 -32
  37. data/docs/EmailMessage.md +30 -24
  38. data/docs/EmailMessageFrom.md +20 -0
  39. data/docs/EmailMessageObject.md +46 -0
  40. data/docs/{ReplyTo.md → EmailMessageReplyTo.md} +5 -5
  41. data/docs/EmailMessageToInner.md +26 -0
  42. data/docs/EmailMessageToInnerBccInner.md +22 -0
  43. data/docs/EmailMessageToInnerCcInner.md +22 -0
  44. data/docs/EmailMessageWithTemplate.md +52 -0
  45. data/docs/EmailResponse.md +8 -8
  46. data/docs/EmailStats.md +20 -0
  47. data/docs/EmailStatsStats.md +38 -0
  48. data/docs/Event.md +56 -0
  49. data/docs/EventMetadata.md +13 -13
  50. data/docs/{City.md → GeoLocation.md} +8 -8
  51. data/docs/IP.md +62 -0
  52. data/docs/IPAllocationRequest.md +20 -0
  53. data/docs/IPApi.md +375 -0
  54. data/docs/IPDeletionResponse.md +20 -0
  55. data/docs/IPPool.md +42 -0
  56. data/docs/IPPoolCreateRequest.md +28 -0
  57. data/docs/IPPoolDeleteResponse.md +20 -0
  58. data/docs/IPPoolUpdateRequest.md +24 -0
  59. data/docs/IPPoolsApi.md +361 -0
  60. data/docs/IPUpdateRequest.md +18 -0
  61. data/docs/Label.md +22 -0
  62. data/docs/Member.md +40 -0
  63. data/docs/Message.md +76 -0
  64. data/docs/MessageApi.md +79 -0
  65. data/docs/MessageHeaderTo.md +26 -0
  66. data/docs/MessageTo.md +26 -0
  67. data/docs/{Os.md → OperatingSystem.md} +7 -7
  68. data/docs/Person.md +20 -0
  69. data/docs/{To.md → Recipient.md} +7 -7
  70. data/docs/SMTPAuth.md +26 -0
  71. data/docs/Stat.md +20 -0
  72. data/docs/StatStat.md +38 -0
  73. data/docs/StatStats.md +38 -0
  74. data/docs/StatsAApi.md +307 -0
  75. data/docs/StatsApi.md +237 -0
  76. data/docs/SubAccount.md +48 -0
  77. data/docs/SubAccountApi.md +375 -0
  78. data/docs/Suppression.md +8 -8
  79. data/docs/SuppressionApi.md +76 -134
  80. data/docs/ThirdPartySendingProvider.md +38 -0
  81. data/docs/UpdateSubAccount.md +18 -0
  82. data/docs/UpdateWebhook.md +46 -0
  83. data/docs/UserAgent.md +4 -4
  84. data/docs/Webhook.md +54 -0
  85. data/docs/WebhookApi.md +375 -0
  86. data/git_push.sh +1 -1
  87. data/lib/sendpost_ruby_sdk/api/domain_api.rb +290 -0
  88. data/lib/sendpost_ruby_sdk/api/email_api.rb +33 -35
  89. data/lib/sendpost_ruby_sdk/api/ip_api.rb +356 -0
  90. data/lib/sendpost_ruby_sdk/api/ip_pools_api.rb +356 -0
  91. data/lib/sendpost_ruby_sdk/api/message_api.rb +85 -0
  92. data/lib/sendpost_ruby_sdk/api/stats_a_api.rb +320 -0
  93. data/lib/sendpost_ruby_sdk/api/stats_api.rb +260 -0
  94. data/lib/sendpost_ruby_sdk/api/sub_account_api.rb +356 -0
  95. data/lib/sendpost_ruby_sdk/api/suppression_api.rb +81 -141
  96. data/lib/sendpost_ruby_sdk/api/webhook_api.rb +356 -0
  97. data/lib/sendpost_ruby_sdk/api_client.rb +26 -24
  98. data/lib/sendpost_ruby_sdk/api_error.rb +3 -3
  99. data/lib/sendpost_ruby_sdk/configuration.rb +28 -3
  100. data/lib/sendpost_ruby_sdk/models/account_stats.rb +229 -0
  101. data/lib/sendpost_ruby_sdk/models/account_stats_stat.rb +311 -0
  102. data/lib/sendpost_ruby_sdk/models/aggregate_stat.rb +321 -0
  103. data/lib/sendpost_ruby_sdk/models/aggregate_stats.rb +310 -0
  104. data/lib/sendpost_ruby_sdk/models/aggregated_email_stats.rb +321 -0
  105. data/lib/sendpost_ruby_sdk/models/attachment.rb +15 -7
  106. data/lib/sendpost_ruby_sdk/models/auto_warmup_plan.rb +531 -0
  107. data/lib/sendpost_ruby_sdk/models/copy_to.rb +28 -19
  108. data/lib/sendpost_ruby_sdk/models/create_domain_request.rb +221 -0
  109. data/lib/sendpost_ruby_sdk/models/create_sub_account_request.rb +221 -0
  110. data/lib/sendpost_ruby_sdk/models/create_suppression_request.rb +259 -0
  111. data/lib/sendpost_ruby_sdk/models/create_suppression_request_hard_bounce_inner.rb +220 -0
  112. data/lib/sendpost_ruby_sdk/models/create_suppression_request_manual_inner.rb +220 -0
  113. data/lib/sendpost_ruby_sdk/models/create_suppression_request_spam_complaint_inner.rb +220 -0
  114. data/lib/sendpost_ruby_sdk/models/create_suppression_request_unsubscribe_inner.rb +220 -0
  115. data/lib/sendpost_ruby_sdk/models/create_webhook_request.rb +361 -0
  116. data/lib/sendpost_ruby_sdk/models/delete_response.rb +15 -7
  117. data/lib/sendpost_ruby_sdk/models/delete_sub_account_response.rb +231 -0
  118. data/lib/sendpost_ruby_sdk/models/delete_suppression200_response_inner.rb +231 -0
  119. data/lib/sendpost_ruby_sdk/models/delete_suppression_request.rb +222 -0
  120. data/lib/sendpost_ruby_sdk/models/delete_webhook_response.rb +231 -0
  121. data/lib/sendpost_ruby_sdk/models/device.rb +13 -7
  122. data/lib/sendpost_ruby_sdk/models/domain.rb +435 -0
  123. data/lib/sendpost_ruby_sdk/models/domain_dkim.rb +239 -0
  124. data/lib/sendpost_ruby_sdk/models/domain_dmarc.rb +239 -0
  125. data/lib/sendpost_ruby_sdk/models/domain_gpt.rb +239 -0
  126. data/lib/sendpost_ruby_sdk/models/domain_return_path.rb +239 -0
  127. data/lib/sendpost_ruby_sdk/models/domain_spf.rb +239 -0
  128. data/lib/sendpost_ruby_sdk/models/domain_track.rb +239 -0
  129. data/lib/sendpost_ruby_sdk/models/eip.rb +238 -0
  130. data/lib/sendpost_ruby_sdk/models/email_address.rb +229 -0
  131. data/lib/sendpost_ruby_sdk/models/email_message.rb +121 -86
  132. data/lib/sendpost_ruby_sdk/models/email_message_from.rb +229 -0
  133. data/lib/sendpost_ruby_sdk/models/email_message_object.rb +354 -0
  134. data/lib/sendpost_ruby_sdk/models/email_message_reply_to.rb +229 -0
  135. data/lib/sendpost_ruby_sdk/models/email_message_to_inner.rb +262 -0
  136. data/lib/sendpost_ruby_sdk/models/email_message_to_inner_bcc_inner.rb +240 -0
  137. data/lib/sendpost_ruby_sdk/models/email_message_to_inner_cc_inner.rb +240 -0
  138. data/lib/sendpost_ruby_sdk/models/email_message_with_template.rb +392 -0
  139. data/lib/sendpost_ruby_sdk/models/email_response.rb +40 -32
  140. data/lib/sendpost_ruby_sdk/models/email_stats.rb +230 -0
  141. data/lib/sendpost_ruby_sdk/models/email_stats_stats.rb +321 -0
  142. data/lib/sendpost_ruby_sdk/models/event.rb +393 -0
  143. data/lib/sendpost_ruby_sdk/models/event_metadata.rb +59 -53
  144. data/lib/sendpost_ruby_sdk/models/geo_location.rb +256 -0
  145. data/lib/sendpost_ruby_sdk/models/ip.rb +643 -0
  146. data/lib/sendpost_ruby_sdk/models/ip_allocation_request.rb +266 -0
  147. data/lib/sendpost_ruby_sdk/models/ip_deletion_response.rb +265 -0
  148. data/lib/sendpost_ruby_sdk/models/ip_pool.rb +357 -0
  149. data/lib/sendpost_ruby_sdk/models/ip_pool_create_request.rb +299 -0
  150. data/lib/sendpost_ruby_sdk/models/ip_pool_delete_response.rb +229 -0
  151. data/lib/sendpost_ruby_sdk/models/ip_pool_update_request.rb +249 -0
  152. data/lib/sendpost_ruby_sdk/models/ip_update_request.rb +238 -0
  153. data/lib/sendpost_ruby_sdk/models/label.rb +241 -0
  154. data/lib/sendpost_ruby_sdk/models/member.rb +331 -0
  155. data/lib/sendpost_ruby_sdk/models/message.rb +523 -0
  156. data/lib/sendpost_ruby_sdk/models/message_header_to.rb +268 -0
  157. data/lib/sendpost_ruby_sdk/models/message_to.rb +268 -0
  158. data/lib/sendpost_ruby_sdk/models/operating_system.rb +256 -0
  159. data/lib/sendpost_ruby_sdk/models/person.rb +231 -0
  160. data/lib/sendpost_ruby_sdk/models/recipient.rb +263 -0
  161. data/lib/sendpost_ruby_sdk/models/smtp_auth.rb +261 -0
  162. data/lib/sendpost_ruby_sdk/models/stat.rb +230 -0
  163. data/lib/sendpost_ruby_sdk/models/stat_stat.rb +322 -0
  164. data/lib/sendpost_ruby_sdk/models/stat_stats.rb +321 -0
  165. data/lib/sendpost_ruby_sdk/models/sub_account.rb +415 -0
  166. data/lib/sendpost_ruby_sdk/models/suppression.rb +40 -29
  167. data/lib/sendpost_ruby_sdk/models/third_party_sending_provider.rb +310 -0
  168. data/lib/sendpost_ruby_sdk/models/update_sub_account.rb +221 -0
  169. data/lib/sendpost_ruby_sdk/models/update_webhook.rb +368 -0
  170. data/lib/sendpost_ruby_sdk/models/user_agent.rb +13 -7
  171. data/lib/sendpost_ruby_sdk/models/webhook.rb +405 -0
  172. data/lib/sendpost_ruby_sdk/version.rb +4 -4
  173. data/lib/sendpost_ruby_sdk.rb +73 -15
  174. data/spec/api/domain_api_spec.rb +85 -0
  175. data/spec/api/email_api_spec.rb +9 -9
  176. data/spec/api/ip_api_spec.rb +98 -0
  177. data/spec/api/ip_pools_api_spec.rb +98 -0
  178. data/spec/api/message_api_spec.rb +47 -0
  179. data/spec/api/stats_a_api_spec.rb +89 -0
  180. data/spec/api/stats_api_spec.rb +78 -0
  181. data/spec/api/sub_account_api_spec.rb +98 -0
  182. data/spec/api/suppression_api_spec.rb +22 -34
  183. data/spec/api/webhook_api_spec.rb +98 -0
  184. data/spec/models/account_stats_spec.rb +42 -0
  185. data/spec/models/account_stats_stat_spec.rb +96 -0
  186. data/spec/models/aggregate_stat_spec.rb +96 -0
  187. data/spec/models/aggregate_stats_spec.rb +96 -0
  188. data/spec/models/aggregated_email_stats_spec.rb +96 -0
  189. data/spec/models/attachment_spec.rb +6 -4
  190. data/spec/models/auto_warmup_plan_spec.rb +222 -0
  191. data/spec/models/copy_to_spec.rb +8 -6
  192. data/spec/models/create_domain_request_spec.rb +36 -0
  193. data/spec/models/create_sub_account_request_spec.rb +36 -0
  194. data/spec/models/create_suppression_request_hard_bounce_inner_spec.rb +36 -0
  195. data/spec/models/create_suppression_request_manual_inner_spec.rb +36 -0
  196. data/spec/models/create_suppression_request_spam_complaint_inner_spec.rb +36 -0
  197. data/spec/models/create_suppression_request_spec.rb +54 -0
  198. data/spec/models/create_suppression_request_unsubscribe_inner_spec.rb +36 -0
  199. data/spec/models/create_webhook_request_spec.rb +120 -0
  200. data/spec/models/delete_response_spec.rb +6 -4
  201. data/spec/models/delete_sub_account_response_spec.rb +42 -0
  202. data/spec/models/delete_suppression200_response_inner_spec.rb +42 -0
  203. data/spec/models/delete_suppression_request_spec.rb +36 -0
  204. data/spec/models/delete_webhook_response_spec.rb +42 -0
  205. data/spec/models/device_spec.rb +6 -4
  206. data/spec/models/domain_dkim_spec.rb +48 -0
  207. data/spec/models/domain_dmarc_spec.rb +48 -0
  208. data/spec/models/domain_gpt_spec.rb +48 -0
  209. data/spec/models/domain_return_path_spec.rb +48 -0
  210. data/spec/models/domain_spec.rb +150 -0
  211. data/spec/models/domain_spf_spec.rb +48 -0
  212. data/spec/models/domain_track_spec.rb +48 -0
  213. data/spec/models/eip_spec.rb +36 -0
  214. data/spec/models/email_address_spec.rb +42 -0
  215. data/spec/models/email_message_from_spec.rb +42 -0
  216. data/spec/models/email_message_object_spec.rb +120 -0
  217. data/spec/models/email_message_reply_to_spec.rb +42 -0
  218. data/spec/models/email_message_spec.rb +37 -17
  219. data/spec/models/email_message_to_inner_bcc_inner_spec.rb +48 -0
  220. data/spec/models/email_message_to_inner_cc_inner_spec.rb +48 -0
  221. data/spec/models/email_message_to_inner_spec.rb +60 -0
  222. data/spec/models/email_message_with_template_spec.rb +138 -0
  223. data/spec/models/email_response_spec.rb +10 -8
  224. data/spec/models/email_stats_spec.rb +42 -0
  225. data/spec/models/email_stats_stats_spec.rb +96 -0
  226. data/spec/models/event_metadata_spec.rb +24 -10
  227. data/spec/models/event_spec.rb +150 -0
  228. data/spec/models/geo_location_spec.rb +60 -0
  229. data/spec/models/ip_allocation_request_spec.rb +42 -0
  230. data/spec/models/ip_deletion_response_spec.rb +42 -0
  231. data/spec/models/ip_pool_create_request_spec.rb +66 -0
  232. data/spec/models/ip_pool_delete_response_spec.rb +42 -0
  233. data/spec/models/ip_pool_spec.rb +108 -0
  234. data/spec/models/ip_pool_update_request_spec.rb +54 -0
  235. data/spec/models/ip_spec.rb +168 -0
  236. data/spec/models/ip_update_request_spec.rb +36 -0
  237. data/spec/models/label_spec.rb +48 -0
  238. data/spec/models/member_spec.rb +102 -0
  239. data/spec/models/message_header_to_spec.rb +60 -0
  240. data/spec/models/message_spec.rb +210 -0
  241. data/spec/models/message_to_spec.rb +60 -0
  242. data/spec/models/operating_system_spec.rb +60 -0
  243. data/spec/models/person_spec.rb +42 -0
  244. data/spec/models/recipient_spec.rb +60 -0
  245. data/spec/models/smtp_auth_spec.rb +60 -0
  246. data/spec/models/stat_spec.rb +42 -0
  247. data/spec/models/stat_stat_spec.rb +96 -0
  248. data/spec/models/stat_stats_spec.rb +96 -0
  249. data/spec/models/sub_account_spec.rb +130 -0
  250. data/spec/models/suppression_spec.rb +11 -9
  251. data/spec/models/third_party_sending_provider_spec.rb +96 -0
  252. data/spec/models/update_sub_account_spec.rb +36 -0
  253. data/spec/models/update_webhook_spec.rb +120 -0
  254. data/spec/models/user_agent_spec.rb +6 -4
  255. data/spec/models/webhook_spec.rb +144 -0
  256. data/spec/spec_helper.rb +3 -3
  257. metadata +295 -66
  258. data/config-ruby.json +0 -11
  259. data/docs/CountStat.md +0 -18
  260. data/docs/QEmailMessage.md +0 -70
  261. data/docs/QEvent.md +0 -42
  262. data/docs/RDSuppression.md +0 -18
  263. data/docs/RSuppression.md +0 -24
  264. data/docs/WebhookEvent.md +0 -20
  265. data/generate-libs.bash +0 -1
  266. data/lib/sendpost_ruby_sdk/models/city.rb +0 -250
  267. data/lib/sendpost_ruby_sdk/models/count_stat.rb +0 -214
  268. data/lib/sendpost_ruby_sdk/models/from.rb +0 -223
  269. data/lib/sendpost_ruby_sdk/models/os.rb +0 -250
  270. data/lib/sendpost_ruby_sdk/models/q_email_message.rb +0 -456
  271. data/lib/sendpost_ruby_sdk/models/q_event.rb +0 -324
  272. data/lib/sendpost_ruby_sdk/models/r_suppression.rb +0 -249
  273. data/lib/sendpost_ruby_sdk/models/rd_suppression.rb +0 -216
  274. data/lib/sendpost_ruby_sdk/models/reply_to.rb +0 -223
  275. data/lib/sendpost_ruby_sdk/models/suppression_email.rb +0 -214
  276. data/lib/sendpost_ruby_sdk/models/to.rb +0 -254
  277. data/lib/sendpost_ruby_sdk/models/webhook_event.rb +0 -223
  278. data/sendpost.yaml +0 -666
  279. data/sendpost_ruby_sdk.gemspec +0 -38
  280. data/spec/api_client_spec.rb +0 -228
  281. data/spec/configuration_spec.rb +0 -42
  282. data/spec/models/city_spec.rb +0 -58
  283. data/spec/models/count_stat_spec.rb +0 -34
  284. data/spec/models/from_spec.rb +0 -40
  285. data/spec/models/os_spec.rb +0 -58
  286. data/spec/models/q_email_message_spec.rb +0 -190
  287. data/spec/models/q_event_spec.rb +0 -106
  288. data/spec/models/r_suppression_spec.rb +0 -52
  289. data/spec/models/rd_suppression_spec.rb +0 -34
  290. data/spec/models/reply_to_spec.rb +0 -40
  291. data/spec/models/suppression_email_spec.rb +0 -34
  292. data/spec/models/to_spec.rb +0 -58
  293. data/spec/models/webhook_event_spec.rb +0 -40
@@ -0,0 +1,230 @@
1
+ =begin
2
+ #SendPost API
3
+
4
+ ## Introduction SendPost provides email API and SMTP relay which can be used not just to send & measure but also alert & optimised email sending. You can use SendPost to: * Send personalised emails to multiple recipients using email API * Track opens and clicks * Analyse statistics around open, clicks, bounce, unsubscribe and spam At and advanced level you can use it to: * Manage multiple sub-accounts which may map to your promotional or transactional sending, multiple product lines or multiple customers * Classify your emails using groups for better analysis * Analyse and fix email sending at sub-account level, IP Pool level or group level * Have automated alerts to notify disruptions regarding email sending * Manage different dedicated IP Pools so to better control your email sending * Automatically know when IP or domain is blacklisted or sender score is down * Leverage pro deliverability tools to get significantly better email deliverability & inboxing [<img src=\"https://run.pstmn.io/button.svg\" alt=\"Run In Postman\" style=\"width: 128px; height: 32px;\">](https://god.gw.postman.com/run-collection/33476323-e6dbd27f-c4a7-4d49-bcac-94b0611b938b?action=collection%2Ffork&source=rip_markdown&collection-url=entityId%3D33476323-e6dbd27f-c4a7-4d49-bcac-94b0611b938b%26entityType%3Dcollection%26workspaceId%3D6b1e4f65-96a9-4136-9512-6266c852517e) # Overview ## REST API SendPost API is built on REST API principles. Authenticated users can interact with any of the API endpoints to perform: * **GET**- to get a resource * **POST** - to create a resource * **PUT** - to update an existing resource * **DELETE** - to delete a resource The API endpoint for all API calls is: <code>https://api.sendpost.io/api/v1</code> Some conventions that have been followed in the API design overall are following: * All resources have either <code>/api/v1/subaccount</code> or <code>/api/v1/account</code> in their API call resource path based on who is authorised for the resource. All API calls with path <code>/api/v1/subaccount</code> use <code>X-SubAccount-ApiKey</code> in their request header. Likewise all API calls with path <code>/api/v1/account</code> use <code>X-Account-ApiKey</code> in their request header. * All resource endpoints end with singular name and not plural. So we have <code>domain</code> instead of domains for domain resource endpoint. Likewise we have <code>sender</code> instead of senders for sender resource endpoint. * Body submitted for POST / PUT API calls as well as JSON response from SendPost API follow camelcase convention * All timestamps returned in response (created or submittedAt response fields) are UNIX nano epoch timestamp. <aside class=\"success\"> All resources have either <code>/api/v1/subaccount</code> or <code>/api/v1/account</code> in their API call resource path based on who is authorised for the resource. All API calls with path <code>/api/v1/subaccount</code> use <code>X-SubAccount-ApiKey</code> in their request header. Likewise all API calls with path <code>/api/v1/account</code> use <code>X-Account-ApiKey</code> in their request header. </aside> SendPost uses conventional HTTP response codes to indicate the success or failure of an API request. * Codes in the <code>2xx</code> range indicate success. * Codes in the <code>4xx</code> range indicate an error owing due to unauthorize access, incorrect request parameters or body etc. * Code in the <code>5xx</code> range indicate an eror with SendPost's servers ( internal service issue or maintenance ) <aside class=\"info\"> SendPost all responses return <code>created</code> in UNIX nano epoch timestamp. </aside> ## Authentication SendPost uses API keys for authentication. You can register a new SendPost API key at our [developer portal](https://app.sendpost.io/register). SendPost expects the API key to be included in all API requests to the server in a header that looks like the following: `X-SubAccount-ApiKey: AHEZEP8192SEGH` This API key is used for all Sub-Account level operations such as: * Sending emails * Retrieving stats regarding open, click, bounce, unsubscribe and spam * Uploading suppressions list * Verifying sending domains and more In addition to <code>X-SubAccount-ApiKey</code> you also have another API Key <code>X-Account-APIKey</code> which is used for Account level operations such as : * Creating and managing sub-accounts * Allocating IPs for your account * Getting overall billing and usage information * Email List validation * Creating and managing alerts and more <aside class=\"notice\"> You must look at individual API reference page to look at whether <code>X-SubAccount-ApiKey</code> is required or <code>X-Account-ApiKey</code> </aside> In case an incorrect API Key header is specified or if it is missed you will get HTTP Response 401 ( Unauthorized ) response from SendPost. ## HTTP Response Headers Code | Reason | Details ---------------| -----------------------| ----------- 200 | Success | Everything went well 401 | Unauthorized | Incorrect or missing API header either <code>X-SubAccount-ApiKey</code> or <code>X-Account-ApiKey</code> 403 | Forbidden | Typically sent when resource with same name or details already exist 406 | Missing resource id | Resource id specified is either missing or doesn't exist 422 | Unprocessable entity | Request body is not in proper format 500 | Internal server error | Some error happened at SendPost while processing API request 503 | Service Unavailable | SendPost is offline for maintenance. Please try again later # API SDKs We have native SendPost SDKs in the following programming languages. You can integrate with them or create your own SDK with our API specification. In case you need any assistance with respect to API then do reachout to our team from website chat or email us at **hello@sendpost.io** * [PHP](https://github.com/sendpost/sendpost_php_sdk) * [Javascript](https://github.com/sendpost/sendpost_javascript_sdk) * [Ruby](https://github.com/sendpost/sendpost_ruby_sdk) * [Python](https://github.com/sendpost/sendpost_python_sdk) * [Golang](https://github.com/sendpost/sendpost_go_sdk) # API Reference SendX REST API can be broken down into two major sub-sections: * Sub-Account * Account Sub-Account API operations enable common email sending API use-cases like sending bulk email, adding new domains or senders for email sending programmatically, retrieving stats, adding suppressions etc. All Sub-Account API operations need to pass <code>X-SubAccount-ApiKey</code> header with every API call. The Account API operations allow users to manage multiple sub-accounts and manage IPs. A single parent SendPost account can have 100's of sub-accounts. You may want to create sub-accounts for different products your company is running or to segregate types of emails or for managing email sending across multiple customers of yours. # SMTP Reference Simple Mail Transfer Protocol (SMTP) is a quick and easy way to send email from one server to another. SendPost provides an SMTP service that allows you to deliver your email via our servers instead of your own client or server. This means you can count on SendPost's delivery at scale for your SMTP needs. ## Integrating SMTP 1. Get the SMTP `username` and `password` from your SendPost account. 2. Set the server host in your email client or application to `smtp.sendpost.io`. This setting is sometimes referred to as the external SMTP server or the SMTP relay. 3. Set the `username` and `password`. 4. Set the port to `587` (or as specified below). ## SMTP Ports - For an unencrypted or a TLS connection, use port `25`, `2525` or `587`. - For a SSL connection, use port `465` - Check your firewall and network to ensure they're not blocking any of our SMTP Endpoints. SendPost supports STARTTLS for establishing a TLS-encrypted connection. STARTTLS is a means of upgrading an unencrypted connection to an encrypted connection. There are versions of STARTTLS for a variety of protocols; the SMTP version is defined in [RFC 3207](https://www.ietf.org/rfc/rfc3207.txt). To set up a STARTTLS connection, the SMTP client connects to the SendPost SMTP endpoint `smtp.sendpost.io` on port 25, 587, or 2525, issues an EHLO command, and waits for the server to announce that it supports the STARTTLS SMTP extension. The client then issues the STARTTLS command, initiating TLS negotiation. When negotiation is complete, the client issues an EHLO command over the new encrypted connection, and the SMTP session proceeds normally. <aside class=\"success\"> If you are unsure which port to use, a TLS connection on port 587 is typically recommended. </aside> ## Sending email from your application ```javascript \"use strict\"; const nodemailer = require(\"nodemailer\"); async function main() { // create reusable transporter object using the default SMTP transport let transporter = nodemailer.createTransport({ host: \"smtp.sendpost.io\", port: 587, secure: false, // true for 465, false for other ports auth: { user: \"<username>\" , // generated ethereal user pass: \"<password>\", // generated ethereal password }, requireTLS: true, debug: true, logger: true, }); // send mail with defined transport object try { let info = await transporter.sendMail({ from: 'erlich@piedpiper.com', to: 'gilfoyle@piedpiper.com', subject: 'Test Email Subject', html: '<h1>Hello Geeks!!!</h1>', }); console.log(\"Message sent: %s\", info.messageId); } catch (e) { console.log(e) } } main().catch(console.error); ``` For PHP ```php <?php // Import PHPMailer classes into the global namespace use PHPMailer\\PHPMailer\\PHPMailer; use PHPMailer\\PHPMailer\\SMTP; use PHPMailer\\PHPMailer\\Exception; // Load Composer's autoloader require 'vendor/autoload.php'; $mail = new PHPMailer(true); // Settings try { $mail->SMTPDebug = SMTP::DEBUG_CONNECTION; // Enable verbose debug output $mail->isSMTP(); // Send using SMTP $mail->Host = 'smtp.sendpost.io'; // Set the SMTP server to send through $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = '<username>'; // SMTP username $mail->Password = '<password>'; // SMTP password $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; // Enable implicit TLS encryption $mail->Port = 587; // TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS` //Recipients $mail->setFrom('erlich@piedpiper.com', 'Erlich'); $mail->addAddress('gilfoyle@piedpiper.com', 'Gilfoyle'); //Content $mail->isHTML(true); //Set email format to HTML $mail->Subject = 'Here is the subject'; $mail->Body = 'This is the HTML message body <b>in bold!</b>'; $mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; $mail->send(); echo 'Message has been sent'; } catch (Exception $e) { echo \"Message could not be sent. Mailer Error: {$mail->ErrorInfo}\"; } ``` For Python ```python #!/usr/bin/python3 import sys import os import re from smtplib import SMTP import ssl from email.mime.text import MIMEText SMTPserver = 'smtp.sendpost.io' PORT = 587 sender = 'erlich@piedpiper.com' destination = ['gilfoyle@piedpiper.com'] USERNAME = \"<username>\" PASSWORD = \"<password>\" # typical values for text_subtype are plain, html, xml text_subtype = 'plain' content=\"\"\"\\ Test message \"\"\" subject=\"Sent from Python\" try: msg = MIMEText(content, text_subtype) msg['Subject']= subject msg['From'] = sender conn = SMTP(SMTPserver, PORT) conn.ehlo() context = ssl.create_default_context() conn.starttls(context=context) # upgrade to tls conn.ehlo() conn.set_debuglevel(True) conn.login(USERNAME, PASSWORD) try: resp = conn.sendmail(sender, destination, msg.as_string()) print(\"Send Mail Response: \", resp) except Exception as e: print(\"Send Email Error: \", e) finally: conn.quit() except Exception as e: print(\"Error:\", e) ``` For Golang ```go package main import ( \"fmt\" \"net/smtp\" \"os\" ) // Sending Email Using Smtp in Golang func main() { username := \"<username>\" password := \"<password>\" from := \"erlich@piedpiper.com\" toList := []string{\"gilfoyle@piedpiper.com\"} host := \"smtp.sendpost.io\" port := \"587\" // recommended // This is the message to send in the mail msg := \"Hello geeks!!!\" // We can't send strings directly in mail, // strings need to be converted into slice bytes body := []byte(msg) // PlainAuth uses the given username and password to // authenticate to host and act as identity. // Usually identity should be the empty string, // to act as username. auth := smtp.PlainAuth(\"\", username, password, host) // SendMail uses TLS connection to send the mail // The email is sent to all address in the toList, // the body should be of type bytes, not strings // This returns error if any occured. err := smtp.SendMail(host+\":\"+port, auth, from, toList, body) // handling the errors if err != nil { fmt.Println(err) os.Exit(1) } fmt.Println(\"Successfully sent mail to all user in toList\") } ``` For Java ```java // implementation 'com.sun.mail:javax.mail:1.6.2' import java.util.Properties; import javax.mail.Message; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; public class SMTPConnect { // This address must be verified. static final String FROM = \"erlich@piedpiper.com\"; static final String FROMNAME = \"Erlich Bachman\"; // Replace recipient@example.com with a \"To\" address. If your account // is still in the sandbox, this address must be verified. static final String TO = \"gilfoyle@piedpiper.com\"; // Replace smtp_username with your SendPost SMTP user name. static final String SMTP_USERNAME = \"<username>\"; // Replace smtp_password with your SendPost SMTP password. static final String SMTP_PASSWORD = \"<password>\"; // SMTP Host Name static final String HOST = \"smtp.sendpost.io\"; // The port you will connect to on SendPost SMTP Endpoint. static final int PORT = 587; static final String SUBJECT = \"SendPost SMTP Test (SMTP interface accessed using Java)\"; static final String BODY = String.join( System.getProperty(\"line.separator\"), \"<h1>SendPost SMTP Test</h1>\", \"<p>This email was sent with SendPost using the \", \"<a href='https://github.com/eclipse-ee4j/mail'>Javamail Package</a>\", \" for <a href='https://www.java.com'>Java</a>.\" ); public static void main(String[] args) throws Exception { // Create a Properties object to contain connection configuration information. Properties props = System.getProperties(); props.put(\"mail.transport.protocol\", \"smtp\"); props.put(\"mail.smtp.port\", PORT); props.put(\"mail.smtp.starttls.enable\", \"true\"); props.put(\"mail.smtp.debug\", \"true\"); props.put(\"mail.smtp.auth\", \"true\"); // Create a Session object to represent a mail session with the specified properties. Session session = Session.getDefaultInstance(props); // Create a message with the specified information. MimeMessage msg = new MimeMessage(session); msg.setFrom(new InternetAddress(FROM,FROMNAME)); msg.setRecipient(Message.RecipientType.TO, new InternetAddress(TO)); msg.setSubject(SUBJECT); msg.setContent(BODY,\"text/html\"); // Create a transport. Transport transport = session.getTransport(); // Send the message. try { System.out.println(\"Sending...\"); // Connect to SendPost SMTP using the SMTP username and password you specified above. transport.connect(HOST, SMTP_USERNAME, SMTP_PASSWORD); // Send the email. transport.sendMessage(msg, msg.getAllRecipients()); System.out.println(\"Email sent!\"); } catch (Exception ex) { System.out.println(\"The email was not sent.\"); System.out.println(\"Error message: \" + ex.getMessage()); System.out.println(ex); } // Close and terminate the connection. } } ``` Many programming languages support sending email using SMTP. This capability might be built into the programming language itself, or it might be available as an add-on, plug-in, or library. You can take advantage of this capability by sending email through SendPost from within application programs that you write. We have provided examples in Python3, Golang, Java, PHP, JS.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.13.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Sendpost
17
+ class Stat
18
+ # Date for which stats are retrieved (UTC).
19
+ attr_accessor :date
20
+
21
+ attr_accessor :stat
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :'date' => :'date',
27
+ :'stat' => :'stat'
28
+ }
29
+ end
30
+
31
+ # Returns attribute mapping this model knows about
32
+ def self.acceptable_attribute_map
33
+ attribute_map
34
+ end
35
+
36
+ # Returns all the JSON keys this model knows about
37
+ def self.acceptable_attributes
38
+ acceptable_attribute_map.values
39
+ end
40
+
41
+ # Attribute type mapping.
42
+ def self.openapi_types
43
+ {
44
+ :'date' => :'Date',
45
+ :'stat' => :'StatStat'
46
+ }
47
+ end
48
+
49
+ # List of attributes with nullable: true
50
+ def self.openapi_nullable
51
+ Set.new([
52
+ ])
53
+ end
54
+
55
+ # Initializes the object
56
+ # @param [Hash] attributes Model attributes in the form of hash
57
+ def initialize(attributes = {})
58
+ if (!attributes.is_a?(Hash))
59
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Sendpost::Stat` initialize method"
60
+ end
61
+
62
+ # check to see if the attribute exists and convert string to symbol for hash key
63
+ acceptable_attribute_map = self.class.acceptable_attribute_map
64
+ attributes = attributes.each_with_object({}) { |(k, v), h|
65
+ if (!acceptable_attribute_map.key?(k.to_sym))
66
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Sendpost::Stat`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
67
+ end
68
+ h[k.to_sym] = v
69
+ }
70
+
71
+ if attributes.key?(:'date')
72
+ self.date = attributes[:'date']
73
+ end
74
+
75
+ if attributes.key?(:'stat')
76
+ self.stat = attributes[:'stat']
77
+ end
78
+ end
79
+
80
+ # Show invalid properties with the reasons. Usually used together with valid?
81
+ # @return Array for valid properties with the reasons
82
+ def list_invalid_properties
83
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
84
+ invalid_properties = Array.new
85
+ invalid_properties
86
+ end
87
+
88
+ # Check to see if the all the properties in the model are valid
89
+ # @return true if the model is valid
90
+ def valid?
91
+ warn '[DEPRECATED] the `valid?` method is obsolete'
92
+ true
93
+ end
94
+
95
+ # Checks equality by comparing each attribute.
96
+ # @param [Object] Object to be compared
97
+ def ==(o)
98
+ return true if self.equal?(o)
99
+ self.class == o.class &&
100
+ date == o.date &&
101
+ stat == o.stat
102
+ end
103
+
104
+ # @see the `==` method
105
+ # @param [Object] Object to be compared
106
+ def eql?(o)
107
+ self == o
108
+ end
109
+
110
+ # Calculates hash code according to all attributes.
111
+ # @return [Integer] Hash code
112
+ def hash
113
+ [date, stat].hash
114
+ end
115
+
116
+ # Builds the object from hash
117
+ # @param [Hash] attributes Model attributes in the form of hash
118
+ # @return [Object] Returns the model itself
119
+ def self.build_from_hash(attributes)
120
+ return nil unless attributes.is_a?(Hash)
121
+ attributes = attributes.transform_keys(&:to_sym)
122
+ transformed_hash = {}
123
+ openapi_types.each_pair do |key, type|
124
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
125
+ transformed_hash["#{key}"] = nil
126
+ elsif type =~ /\AArray<(.*)>/i
127
+ # check to ensure the input is an array given that the attribute
128
+ # is documented as an array but the input is not
129
+ if attributes[attribute_map[key]].is_a?(Array)
130
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
131
+ end
132
+ elsif !attributes[attribute_map[key]].nil?
133
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
134
+ end
135
+ end
136
+ new(transformed_hash)
137
+ end
138
+
139
+ # Deserializes the data based on type
140
+ # @param string type Data type
141
+ # @param string value Value to be deserialized
142
+ # @return [Object] Deserialized data
143
+ def self._deserialize(type, value)
144
+ case type.to_sym
145
+ when :Time
146
+ Time.parse(value)
147
+ when :Date
148
+ Date.parse(value)
149
+ when :String
150
+ value.to_s
151
+ when :Integer
152
+ value.to_i
153
+ when :Float
154
+ value.to_f
155
+ when :Boolean
156
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
157
+ true
158
+ else
159
+ false
160
+ end
161
+ when :Object
162
+ # generic object (usually a Hash), return directly
163
+ value
164
+ when /\AArray<(?<inner_type>.+)>\z/
165
+ inner_type = Regexp.last_match[:inner_type]
166
+ value.map { |v| _deserialize(inner_type, v) }
167
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
168
+ k_type = Regexp.last_match[:k_type]
169
+ v_type = Regexp.last_match[:v_type]
170
+ {}.tap do |hash|
171
+ value.each do |k, v|
172
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
173
+ end
174
+ end
175
+ else # model
176
+ # models (e.g. Pet) or oneOf
177
+ klass = Sendpost.const_get(type)
178
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
179
+ end
180
+ end
181
+
182
+ # Returns the string representation of the object
183
+ # @return [String] String presentation of the object
184
+ def to_s
185
+ to_hash.to_s
186
+ end
187
+
188
+ # to_body is an alias to to_hash (backward compatibility)
189
+ # @return [Hash] Returns the object in the form of hash
190
+ def to_body
191
+ to_hash
192
+ end
193
+
194
+ # Returns the object in the form of hash
195
+ # @return [Hash] Returns the object in the form of hash
196
+ def to_hash
197
+ hash = {}
198
+ self.class.attribute_map.each_pair do |attr, param|
199
+ value = self.send(attr)
200
+ if value.nil?
201
+ is_nullable = self.class.openapi_nullable.include?(attr)
202
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
203
+ end
204
+
205
+ hash[param] = _to_hash(value)
206
+ end
207
+ hash
208
+ end
209
+
210
+ # Outputs non-array value in the form of hash
211
+ # For object, use to_hash. Otherwise, just return the value
212
+ # @param [Object] value Any valid value
213
+ # @return [Hash] Returns the value in the form of hash
214
+ def _to_hash(value)
215
+ if value.is_a?(Array)
216
+ value.compact.map { |v| _to_hash(v) }
217
+ elsif value.is_a?(Hash)
218
+ {}.tap do |hash|
219
+ value.each { |k, v| hash[k] = _to_hash(v) }
220
+ end
221
+ elsif value.respond_to? :to_hash
222
+ value.to_hash
223
+ else
224
+ value
225
+ end
226
+ end
227
+
228
+ end
229
+
230
+ end
@@ -0,0 +1,322 @@
1
+ =begin
2
+ #SendPost API
3
+
4
+ ## Introduction SendPost provides email API and SMTP relay which can be used not just to send & measure but also alert & optimised email sending. You can use SendPost to: * Send personalised emails to multiple recipients using email API * Track opens and clicks * Analyse statistics around open, clicks, bounce, unsubscribe and spam At and advanced level you can use it to: * Manage multiple sub-accounts which may map to your promotional or transactional sending, multiple product lines or multiple customers * Classify your emails using groups for better analysis * Analyse and fix email sending at sub-account level, IP Pool level or group level * Have automated alerts to notify disruptions regarding email sending * Manage different dedicated IP Pools so to better control your email sending * Automatically know when IP or domain is blacklisted or sender score is down * Leverage pro deliverability tools to get significantly better email deliverability & inboxing [<img src=\"https://run.pstmn.io/button.svg\" alt=\"Run In Postman\" style=\"width: 128px; height: 32px;\">](https://god.gw.postman.com/run-collection/33476323-e6dbd27f-c4a7-4d49-bcac-94b0611b938b?action=collection%2Ffork&source=rip_markdown&collection-url=entityId%3D33476323-e6dbd27f-c4a7-4d49-bcac-94b0611b938b%26entityType%3Dcollection%26workspaceId%3D6b1e4f65-96a9-4136-9512-6266c852517e) # Overview ## REST API SendPost API is built on REST API principles. Authenticated users can interact with any of the API endpoints to perform: * **GET**- to get a resource * **POST** - to create a resource * **PUT** - to update an existing resource * **DELETE** - to delete a resource The API endpoint for all API calls is: <code>https://api.sendpost.io/api/v1</code> Some conventions that have been followed in the API design overall are following: * All resources have either <code>/api/v1/subaccount</code> or <code>/api/v1/account</code> in their API call resource path based on who is authorised for the resource. All API calls with path <code>/api/v1/subaccount</code> use <code>X-SubAccount-ApiKey</code> in their request header. Likewise all API calls with path <code>/api/v1/account</code> use <code>X-Account-ApiKey</code> in their request header. * All resource endpoints end with singular name and not plural. So we have <code>domain</code> instead of domains for domain resource endpoint. Likewise we have <code>sender</code> instead of senders for sender resource endpoint. * Body submitted for POST / PUT API calls as well as JSON response from SendPost API follow camelcase convention * All timestamps returned in response (created or submittedAt response fields) are UNIX nano epoch timestamp. <aside class=\"success\"> All resources have either <code>/api/v1/subaccount</code> or <code>/api/v1/account</code> in their API call resource path based on who is authorised for the resource. All API calls with path <code>/api/v1/subaccount</code> use <code>X-SubAccount-ApiKey</code> in their request header. Likewise all API calls with path <code>/api/v1/account</code> use <code>X-Account-ApiKey</code> in their request header. </aside> SendPost uses conventional HTTP response codes to indicate the success or failure of an API request. * Codes in the <code>2xx</code> range indicate success. * Codes in the <code>4xx</code> range indicate an error owing due to unauthorize access, incorrect request parameters or body etc. * Code in the <code>5xx</code> range indicate an eror with SendPost's servers ( internal service issue or maintenance ) <aside class=\"info\"> SendPost all responses return <code>created</code> in UNIX nano epoch timestamp. </aside> ## Authentication SendPost uses API keys for authentication. You can register a new SendPost API key at our [developer portal](https://app.sendpost.io/register). SendPost expects the API key to be included in all API requests to the server in a header that looks like the following: `X-SubAccount-ApiKey: AHEZEP8192SEGH` This API key is used for all Sub-Account level operations such as: * Sending emails * Retrieving stats regarding open, click, bounce, unsubscribe and spam * Uploading suppressions list * Verifying sending domains and more In addition to <code>X-SubAccount-ApiKey</code> you also have another API Key <code>X-Account-APIKey</code> which is used for Account level operations such as : * Creating and managing sub-accounts * Allocating IPs for your account * Getting overall billing and usage information * Email List validation * Creating and managing alerts and more <aside class=\"notice\"> You must look at individual API reference page to look at whether <code>X-SubAccount-ApiKey</code> is required or <code>X-Account-ApiKey</code> </aside> In case an incorrect API Key header is specified or if it is missed you will get HTTP Response 401 ( Unauthorized ) response from SendPost. ## HTTP Response Headers Code | Reason | Details ---------------| -----------------------| ----------- 200 | Success | Everything went well 401 | Unauthorized | Incorrect or missing API header either <code>X-SubAccount-ApiKey</code> or <code>X-Account-ApiKey</code> 403 | Forbidden | Typically sent when resource with same name or details already exist 406 | Missing resource id | Resource id specified is either missing or doesn't exist 422 | Unprocessable entity | Request body is not in proper format 500 | Internal server error | Some error happened at SendPost while processing API request 503 | Service Unavailable | SendPost is offline for maintenance. Please try again later # API SDKs We have native SendPost SDKs in the following programming languages. You can integrate with them or create your own SDK with our API specification. In case you need any assistance with respect to API then do reachout to our team from website chat or email us at **hello@sendpost.io** * [PHP](https://github.com/sendpost/sendpost_php_sdk) * [Javascript](https://github.com/sendpost/sendpost_javascript_sdk) * [Ruby](https://github.com/sendpost/sendpost_ruby_sdk) * [Python](https://github.com/sendpost/sendpost_python_sdk) * [Golang](https://github.com/sendpost/sendpost_go_sdk) # API Reference SendX REST API can be broken down into two major sub-sections: * Sub-Account * Account Sub-Account API operations enable common email sending API use-cases like sending bulk email, adding new domains or senders for email sending programmatically, retrieving stats, adding suppressions etc. All Sub-Account API operations need to pass <code>X-SubAccount-ApiKey</code> header with every API call. The Account API operations allow users to manage multiple sub-accounts and manage IPs. A single parent SendPost account can have 100's of sub-accounts. You may want to create sub-accounts for different products your company is running or to segregate types of emails or for managing email sending across multiple customers of yours. # SMTP Reference Simple Mail Transfer Protocol (SMTP) is a quick and easy way to send email from one server to another. SendPost provides an SMTP service that allows you to deliver your email via our servers instead of your own client or server. This means you can count on SendPost's delivery at scale for your SMTP needs. ## Integrating SMTP 1. Get the SMTP `username` and `password` from your SendPost account. 2. Set the server host in your email client or application to `smtp.sendpost.io`. This setting is sometimes referred to as the external SMTP server or the SMTP relay. 3. Set the `username` and `password`. 4. Set the port to `587` (or as specified below). ## SMTP Ports - For an unencrypted or a TLS connection, use port `25`, `2525` or `587`. - For a SSL connection, use port `465` - Check your firewall and network to ensure they're not blocking any of our SMTP Endpoints. SendPost supports STARTTLS for establishing a TLS-encrypted connection. STARTTLS is a means of upgrading an unencrypted connection to an encrypted connection. There are versions of STARTTLS for a variety of protocols; the SMTP version is defined in [RFC 3207](https://www.ietf.org/rfc/rfc3207.txt). To set up a STARTTLS connection, the SMTP client connects to the SendPost SMTP endpoint `smtp.sendpost.io` on port 25, 587, or 2525, issues an EHLO command, and waits for the server to announce that it supports the STARTTLS SMTP extension. The client then issues the STARTTLS command, initiating TLS negotiation. When negotiation is complete, the client issues an EHLO command over the new encrypted connection, and the SMTP session proceeds normally. <aside class=\"success\"> If you are unsure which port to use, a TLS connection on port 587 is typically recommended. </aside> ## Sending email from your application ```javascript \"use strict\"; const nodemailer = require(\"nodemailer\"); async function main() { // create reusable transporter object using the default SMTP transport let transporter = nodemailer.createTransport({ host: \"smtp.sendpost.io\", port: 587, secure: false, // true for 465, false for other ports auth: { user: \"<username>\" , // generated ethereal user pass: \"<password>\", // generated ethereal password }, requireTLS: true, debug: true, logger: true, }); // send mail with defined transport object try { let info = await transporter.sendMail({ from: 'erlich@piedpiper.com', to: 'gilfoyle@piedpiper.com', subject: 'Test Email Subject', html: '<h1>Hello Geeks!!!</h1>', }); console.log(\"Message sent: %s\", info.messageId); } catch (e) { console.log(e) } } main().catch(console.error); ``` For PHP ```php <?php // Import PHPMailer classes into the global namespace use PHPMailer\\PHPMailer\\PHPMailer; use PHPMailer\\PHPMailer\\SMTP; use PHPMailer\\PHPMailer\\Exception; // Load Composer's autoloader require 'vendor/autoload.php'; $mail = new PHPMailer(true); // Settings try { $mail->SMTPDebug = SMTP::DEBUG_CONNECTION; // Enable verbose debug output $mail->isSMTP(); // Send using SMTP $mail->Host = 'smtp.sendpost.io'; // Set the SMTP server to send through $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = '<username>'; // SMTP username $mail->Password = '<password>'; // SMTP password $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; // Enable implicit TLS encryption $mail->Port = 587; // TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS` //Recipients $mail->setFrom('erlich@piedpiper.com', 'Erlich'); $mail->addAddress('gilfoyle@piedpiper.com', 'Gilfoyle'); //Content $mail->isHTML(true); //Set email format to HTML $mail->Subject = 'Here is the subject'; $mail->Body = 'This is the HTML message body <b>in bold!</b>'; $mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; $mail->send(); echo 'Message has been sent'; } catch (Exception $e) { echo \"Message could not be sent. Mailer Error: {$mail->ErrorInfo}\"; } ``` For Python ```python #!/usr/bin/python3 import sys import os import re from smtplib import SMTP import ssl from email.mime.text import MIMEText SMTPserver = 'smtp.sendpost.io' PORT = 587 sender = 'erlich@piedpiper.com' destination = ['gilfoyle@piedpiper.com'] USERNAME = \"<username>\" PASSWORD = \"<password>\" # typical values for text_subtype are plain, html, xml text_subtype = 'plain' content=\"\"\"\\ Test message \"\"\" subject=\"Sent from Python\" try: msg = MIMEText(content, text_subtype) msg['Subject']= subject msg['From'] = sender conn = SMTP(SMTPserver, PORT) conn.ehlo() context = ssl.create_default_context() conn.starttls(context=context) # upgrade to tls conn.ehlo() conn.set_debuglevel(True) conn.login(USERNAME, PASSWORD) try: resp = conn.sendmail(sender, destination, msg.as_string()) print(\"Send Mail Response: \", resp) except Exception as e: print(\"Send Email Error: \", e) finally: conn.quit() except Exception as e: print(\"Error:\", e) ``` For Golang ```go package main import ( \"fmt\" \"net/smtp\" \"os\" ) // Sending Email Using Smtp in Golang func main() { username := \"<username>\" password := \"<password>\" from := \"erlich@piedpiper.com\" toList := []string{\"gilfoyle@piedpiper.com\"} host := \"smtp.sendpost.io\" port := \"587\" // recommended // This is the message to send in the mail msg := \"Hello geeks!!!\" // We can't send strings directly in mail, // strings need to be converted into slice bytes body := []byte(msg) // PlainAuth uses the given username and password to // authenticate to host and act as identity. // Usually identity should be the empty string, // to act as username. auth := smtp.PlainAuth(\"\", username, password, host) // SendMail uses TLS connection to send the mail // The email is sent to all address in the toList, // the body should be of type bytes, not strings // This returns error if any occured. err := smtp.SendMail(host+\":\"+port, auth, from, toList, body) // handling the errors if err != nil { fmt.Println(err) os.Exit(1) } fmt.Println(\"Successfully sent mail to all user in toList\") } ``` For Java ```java // implementation 'com.sun.mail:javax.mail:1.6.2' import java.util.Properties; import javax.mail.Message; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; public class SMTPConnect { // This address must be verified. static final String FROM = \"erlich@piedpiper.com\"; static final String FROMNAME = \"Erlich Bachman\"; // Replace recipient@example.com with a \"To\" address. If your account // is still in the sandbox, this address must be verified. static final String TO = \"gilfoyle@piedpiper.com\"; // Replace smtp_username with your SendPost SMTP user name. static final String SMTP_USERNAME = \"<username>\"; // Replace smtp_password with your SendPost SMTP password. static final String SMTP_PASSWORD = \"<password>\"; // SMTP Host Name static final String HOST = \"smtp.sendpost.io\"; // The port you will connect to on SendPost SMTP Endpoint. static final int PORT = 587; static final String SUBJECT = \"SendPost SMTP Test (SMTP interface accessed using Java)\"; static final String BODY = String.join( System.getProperty(\"line.separator\"), \"<h1>SendPost SMTP Test</h1>\", \"<p>This email was sent with SendPost using the \", \"<a href='https://github.com/eclipse-ee4j/mail'>Javamail Package</a>\", \" for <a href='https://www.java.com'>Java</a>.\" ); public static void main(String[] args) throws Exception { // Create a Properties object to contain connection configuration information. Properties props = System.getProperties(); props.put(\"mail.transport.protocol\", \"smtp\"); props.put(\"mail.smtp.port\", PORT); props.put(\"mail.smtp.starttls.enable\", \"true\"); props.put(\"mail.smtp.debug\", \"true\"); props.put(\"mail.smtp.auth\", \"true\"); // Create a Session object to represent a mail session with the specified properties. Session session = Session.getDefaultInstance(props); // Create a message with the specified information. MimeMessage msg = new MimeMessage(session); msg.setFrom(new InternetAddress(FROM,FROMNAME)); msg.setRecipient(Message.RecipientType.TO, new InternetAddress(TO)); msg.setSubject(SUBJECT); msg.setContent(BODY,\"text/html\"); // Create a transport. Transport transport = session.getTransport(); // Send the message. try { System.out.println(\"Sending...\"); // Connect to SendPost SMTP using the SMTP username and password you specified above. transport.connect(HOST, SMTP_USERNAME, SMTP_PASSWORD); // Send the email. transport.sendMessage(msg, msg.getAllRecipients()); System.out.println(\"Email sent!\"); } catch (Exception ex) { System.out.println(\"The email was not sent.\"); System.out.println(\"Error message: \" + ex.getMessage()); System.out.println(ex); } // Close and terminate the connection. } } ``` Many programming languages support sending email using SMTP. This capability might be built into the programming language itself, or it might be available as an add-on, plug-in, or library. You can take advantage of this capability by sending email through SendPost from within application programs that you write. We have provided examples in Python3, Golang, Java, PHP, JS.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.13.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Sendpost
17
+ # Statistics data for the date
18
+ class StatStat
19
+ # Number of emails accepted by SendPost API.
20
+ attr_accessor :processed
21
+
22
+ # Number of emails sent.
23
+ attr_accessor :sent
24
+
25
+ # Number of emails we were able to successfully deliver at SMTP without encountering any error
26
+ attr_accessor :delivered
27
+
28
+ # Number of emails drop without attempting to deliver either because the email is invalid or email in in existing suppression list
29
+ attr_accessor :dropped
30
+
31
+ # Number of emails dropped by SMTP.
32
+ attr_accessor :smtp_dropped
33
+
34
+ # Number of emails where we got SMTP hard bounce error code by the recipient mail provider
35
+ attr_accessor :hard_bounced
36
+
37
+ # Number of emails where we got temporary soft bounce error by the recipent mail provider. Soft bounced emails are retried upto 5 times over 24 hour period before marking them as hardBounced.
38
+ attr_accessor :soft_bounced
39
+
40
+ # Number of emails opened by recipients
41
+ attr_accessor :opened
42
+
43
+ # Number of email links clicked by recipients
44
+ attr_accessor :clicked
45
+
46
+ # Number of email recipients who unsubscribed from receiving further emails
47
+ attr_accessor :unsubscribed
48
+
49
+ # Number of email recipients who marked emails as spam
50
+ attr_accessor :spam
51
+
52
+ # Attribute mapping from ruby-style variable name to JSON key.
53
+ def self.attribute_map
54
+ {
55
+ :'processed' => :'processed',
56
+ :'sent' => :'sent',
57
+ :'delivered' => :'delivered',
58
+ :'dropped' => :'dropped',
59
+ :'smtp_dropped' => :'smtpDropped',
60
+ :'hard_bounced' => :'hardBounced',
61
+ :'soft_bounced' => :'softBounced',
62
+ :'opened' => :'opened',
63
+ :'clicked' => :'clicked',
64
+ :'unsubscribed' => :'unsubscribed',
65
+ :'spam' => :'spam'
66
+ }
67
+ end
68
+
69
+ # Returns attribute mapping this model knows about
70
+ def self.acceptable_attribute_map
71
+ attribute_map
72
+ end
73
+
74
+ # Returns all the JSON keys this model knows about
75
+ def self.acceptable_attributes
76
+ acceptable_attribute_map.values
77
+ end
78
+
79
+ # Attribute type mapping.
80
+ def self.openapi_types
81
+ {
82
+ :'processed' => :'Integer',
83
+ :'sent' => :'Integer',
84
+ :'delivered' => :'Integer',
85
+ :'dropped' => :'Integer',
86
+ :'smtp_dropped' => :'Integer',
87
+ :'hard_bounced' => :'Integer',
88
+ :'soft_bounced' => :'Integer',
89
+ :'opened' => :'Integer',
90
+ :'clicked' => :'Integer',
91
+ :'unsubscribed' => :'Integer',
92
+ :'spam' => :'Integer'
93
+ }
94
+ end
95
+
96
+ # List of attributes with nullable: true
97
+ def self.openapi_nullable
98
+ Set.new([
99
+ ])
100
+ end
101
+
102
+ # Initializes the object
103
+ # @param [Hash] attributes Model attributes in the form of hash
104
+ def initialize(attributes = {})
105
+ if (!attributes.is_a?(Hash))
106
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Sendpost::StatStat` initialize method"
107
+ end
108
+
109
+ # check to see if the attribute exists and convert string to symbol for hash key
110
+ acceptable_attribute_map = self.class.acceptable_attribute_map
111
+ attributes = attributes.each_with_object({}) { |(k, v), h|
112
+ if (!acceptable_attribute_map.key?(k.to_sym))
113
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Sendpost::StatStat`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
114
+ end
115
+ h[k.to_sym] = v
116
+ }
117
+
118
+ if attributes.key?(:'processed')
119
+ self.processed = attributes[:'processed']
120
+ end
121
+
122
+ if attributes.key?(:'sent')
123
+ self.sent = attributes[:'sent']
124
+ end
125
+
126
+ if attributes.key?(:'delivered')
127
+ self.delivered = attributes[:'delivered']
128
+ end
129
+
130
+ if attributes.key?(:'dropped')
131
+ self.dropped = attributes[:'dropped']
132
+ end
133
+
134
+ if attributes.key?(:'smtp_dropped')
135
+ self.smtp_dropped = attributes[:'smtp_dropped']
136
+ end
137
+
138
+ if attributes.key?(:'hard_bounced')
139
+ self.hard_bounced = attributes[:'hard_bounced']
140
+ end
141
+
142
+ if attributes.key?(:'soft_bounced')
143
+ self.soft_bounced = attributes[:'soft_bounced']
144
+ end
145
+
146
+ if attributes.key?(:'opened')
147
+ self.opened = attributes[:'opened']
148
+ end
149
+
150
+ if attributes.key?(:'clicked')
151
+ self.clicked = attributes[:'clicked']
152
+ end
153
+
154
+ if attributes.key?(:'unsubscribed')
155
+ self.unsubscribed = attributes[:'unsubscribed']
156
+ end
157
+
158
+ if attributes.key?(:'spam')
159
+ self.spam = attributes[:'spam']
160
+ end
161
+ end
162
+
163
+ # Show invalid properties with the reasons. Usually used together with valid?
164
+ # @return Array for valid properties with the reasons
165
+ def list_invalid_properties
166
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
167
+ invalid_properties = Array.new
168
+ invalid_properties
169
+ end
170
+
171
+ # Check to see if the all the properties in the model are valid
172
+ # @return true if the model is valid
173
+ def valid?
174
+ warn '[DEPRECATED] the `valid?` method is obsolete'
175
+ true
176
+ end
177
+
178
+ # Checks equality by comparing each attribute.
179
+ # @param [Object] Object to be compared
180
+ def ==(o)
181
+ return true if self.equal?(o)
182
+ self.class == o.class &&
183
+ processed == o.processed &&
184
+ sent == o.sent &&
185
+ delivered == o.delivered &&
186
+ dropped == o.dropped &&
187
+ smtp_dropped == o.smtp_dropped &&
188
+ hard_bounced == o.hard_bounced &&
189
+ soft_bounced == o.soft_bounced &&
190
+ opened == o.opened &&
191
+ clicked == o.clicked &&
192
+ unsubscribed == o.unsubscribed &&
193
+ spam == o.spam
194
+ end
195
+
196
+ # @see the `==` method
197
+ # @param [Object] Object to be compared
198
+ def eql?(o)
199
+ self == o
200
+ end
201
+
202
+ # Calculates hash code according to all attributes.
203
+ # @return [Integer] Hash code
204
+ def hash
205
+ [processed, sent, delivered, dropped, smtp_dropped, hard_bounced, soft_bounced, opened, clicked, unsubscribed, spam].hash
206
+ end
207
+
208
+ # Builds the object from hash
209
+ # @param [Hash] attributes Model attributes in the form of hash
210
+ # @return [Object] Returns the model itself
211
+ def self.build_from_hash(attributes)
212
+ return nil unless attributes.is_a?(Hash)
213
+ attributes = attributes.transform_keys(&:to_sym)
214
+ transformed_hash = {}
215
+ openapi_types.each_pair do |key, type|
216
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
217
+ transformed_hash["#{key}"] = nil
218
+ elsif type =~ /\AArray<(.*)>/i
219
+ # check to ensure the input is an array given that the attribute
220
+ # is documented as an array but the input is not
221
+ if attributes[attribute_map[key]].is_a?(Array)
222
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
223
+ end
224
+ elsif !attributes[attribute_map[key]].nil?
225
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
226
+ end
227
+ end
228
+ new(transformed_hash)
229
+ end
230
+
231
+ # Deserializes the data based on type
232
+ # @param string type Data type
233
+ # @param string value Value to be deserialized
234
+ # @return [Object] Deserialized data
235
+ def self._deserialize(type, value)
236
+ case type.to_sym
237
+ when :Time
238
+ Time.parse(value)
239
+ when :Date
240
+ Date.parse(value)
241
+ when :String
242
+ value.to_s
243
+ when :Integer
244
+ value.to_i
245
+ when :Float
246
+ value.to_f
247
+ when :Boolean
248
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
249
+ true
250
+ else
251
+ false
252
+ end
253
+ when :Object
254
+ # generic object (usually a Hash), return directly
255
+ value
256
+ when /\AArray<(?<inner_type>.+)>\z/
257
+ inner_type = Regexp.last_match[:inner_type]
258
+ value.map { |v| _deserialize(inner_type, v) }
259
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
260
+ k_type = Regexp.last_match[:k_type]
261
+ v_type = Regexp.last_match[:v_type]
262
+ {}.tap do |hash|
263
+ value.each do |k, v|
264
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
265
+ end
266
+ end
267
+ else # model
268
+ # models (e.g. Pet) or oneOf
269
+ klass = Sendpost.const_get(type)
270
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
271
+ end
272
+ end
273
+
274
+ # Returns the string representation of the object
275
+ # @return [String] String presentation of the object
276
+ def to_s
277
+ to_hash.to_s
278
+ end
279
+
280
+ # to_body is an alias to to_hash (backward compatibility)
281
+ # @return [Hash] Returns the object in the form of hash
282
+ def to_body
283
+ to_hash
284
+ end
285
+
286
+ # Returns the object in the form of hash
287
+ # @return [Hash] Returns the object in the form of hash
288
+ def to_hash
289
+ hash = {}
290
+ self.class.attribute_map.each_pair do |attr, param|
291
+ value = self.send(attr)
292
+ if value.nil?
293
+ is_nullable = self.class.openapi_nullable.include?(attr)
294
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
295
+ end
296
+
297
+ hash[param] = _to_hash(value)
298
+ end
299
+ hash
300
+ end
301
+
302
+ # Outputs non-array value in the form of hash
303
+ # For object, use to_hash. Otherwise, just return the value
304
+ # @param [Object] value Any valid value
305
+ # @return [Hash] Returns the value in the form of hash
306
+ def _to_hash(value)
307
+ if value.is_a?(Array)
308
+ value.compact.map { |v| _to_hash(v) }
309
+ elsif value.is_a?(Hash)
310
+ {}.tap do |hash|
311
+ value.each { |k, v| hash[k] = _to_hash(v) }
312
+ end
313
+ elsif value.respond_to? :to_hash
314
+ value.to_hash
315
+ else
316
+ value
317
+ end
318
+ end
319
+
320
+ end
321
+
322
+ end