sendpost_ruby_sdk 1.0.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +21 -0
- data/README.md +626 -82
- data/docs/AccountStats.md +20 -0
- data/docs/AccountStatsStat.md +38 -0
- data/docs/AggregateStat.md +38 -0
- data/docs/AggregateStats.md +38 -0
- data/docs/AggregatedEmailStats.md +38 -0
- data/docs/Attachment.md +4 -4
- data/docs/AutoWarmupPlan.md +80 -0
- data/docs/CopyTo.md +5 -5
- data/docs/CreateDomainRequest.md +18 -0
- data/docs/CreateSubAccountRequest.md +18 -0
- data/docs/CreateSuppressionRequest.md +24 -0
- data/docs/CreateSuppressionRequestHardBounceInner.md +18 -0
- data/docs/{SuppressionEmail.md → CreateSuppressionRequestManualInner.md} +3 -3
- data/docs/CreateSuppressionRequestSpamComplaintInner.md +18 -0
- data/docs/CreateSuppressionRequestUnsubscribeInner.md +18 -0
- data/docs/CreateWebhookRequest.md +46 -0
- data/docs/DeleteResponse.md +2 -2
- data/docs/DeleteSubAccountResponse.md +20 -0
- data/docs/DeleteSuppression200ResponseInner.md +20 -0
- data/docs/DeleteSuppressionRequest.md +18 -0
- data/docs/DeleteWebhookResponse.md +20 -0
- data/docs/Device.md +1 -1
- data/docs/Domain.md +56 -0
- data/docs/DomainApi.md +301 -0
- data/docs/DomainDkim.md +22 -0
- data/docs/DomainDmarc.md +22 -0
- data/docs/DomainGpt.md +22 -0
- data/docs/DomainReturnPath.md +22 -0
- data/docs/DomainTrack.md +22 -0
- data/docs/EIP.md +18 -0
- data/docs/{From.md → EmailAddress.md} +4 -4
- data/docs/EmailApi.md +38 -32
- data/docs/EmailMessage.md +30 -24
- data/docs/EmailMessageFrom.md +20 -0
- data/docs/EmailMessageObject.md +46 -0
- data/docs/{ReplyTo.md → EmailMessageReplyTo.md} +5 -5
- data/docs/EmailMessageToInner.md +26 -0
- data/docs/EmailMessageToInnerBccInner.md +22 -0
- data/docs/EmailMessageToInnerCcInner.md +22 -0
- data/docs/EmailMessageWithTemplate.md +52 -0
- data/docs/EmailResponse.md +8 -8
- data/docs/EmailStats.md +20 -0
- data/docs/EmailStatsStats.md +38 -0
- data/docs/Event.md +56 -0
- data/docs/EventMetadata.md +13 -9
- data/docs/{City.md → GeoLocation.md} +8 -8
- data/docs/IP.md +62 -0
- data/docs/IPAllocationRequest.md +20 -0
- data/docs/IPApi.md +375 -0
- data/docs/IPDeletionResponse.md +20 -0
- data/docs/IPPool.md +42 -0
- data/docs/IPPoolCreateRequest.md +28 -0
- data/docs/IPPoolDeleteResponse.md +20 -0
- data/docs/IPPoolUpdateRequest.md +24 -0
- data/docs/IPPoolsApi.md +361 -0
- data/docs/IPUpdateRequest.md +18 -0
- data/docs/Label.md +22 -0
- data/docs/Member.md +40 -0
- data/docs/Message.md +76 -0
- data/docs/MessageApi.md +79 -0
- data/docs/MessageHeaderTo.md +26 -0
- data/docs/MessageTo.md +26 -0
- data/docs/{Os.md → OperatingSystem.md} +7 -7
- data/docs/Person.md +20 -0
- data/docs/{To.md → Recipient.md} +7 -7
- data/docs/SMTPAuth.md +26 -0
- data/docs/Stat.md +20 -0
- data/docs/StatStats.md +38 -0
- data/docs/StatsAApi.md +307 -0
- data/docs/StatsApi.md +237 -0
- data/docs/SubAccount.md +48 -0
- data/docs/SubAccountApi.md +375 -0
- data/docs/Suppression.md +8 -8
- data/docs/SuppressionApi.md +76 -134
- data/docs/ThirdPartySendingProvider.md +38 -0
- data/docs/UpdateSubAccount.md +18 -0
- data/docs/UpdateWebhook.md +46 -0
- data/docs/UserAgent.md +4 -4
- data/docs/Webhook.md +54 -0
- data/docs/WebhookApi.md +375 -0
- data/git_push.sh +2 -2
- data/lib/sendpost_ruby_sdk/api/domain_api.rb +290 -0
- data/lib/sendpost_ruby_sdk/api/email_api.rb +33 -35
- data/lib/sendpost_ruby_sdk/api/ip_api.rb +356 -0
- data/lib/sendpost_ruby_sdk/api/ip_pools_api.rb +356 -0
- data/lib/sendpost_ruby_sdk/api/message_api.rb +85 -0
- data/lib/sendpost_ruby_sdk/api/stats_a_api.rb +320 -0
- data/lib/sendpost_ruby_sdk/api/stats_api.rb +260 -0
- data/lib/sendpost_ruby_sdk/api/sub_account_api.rb +356 -0
- data/lib/sendpost_ruby_sdk/api/suppression_api.rb +81 -141
- data/lib/sendpost_ruby_sdk/api/webhook_api.rb +356 -0
- data/lib/sendpost_ruby_sdk/api_client.rb +26 -24
- data/lib/sendpost_ruby_sdk/api_error.rb +3 -3
- data/lib/sendpost_ruby_sdk/configuration.rb +39 -12
- data/lib/sendpost_ruby_sdk/models/account_stats.rb +229 -0
- data/lib/sendpost_ruby_sdk/models/account_stats_stat.rb +310 -0
- data/lib/sendpost_ruby_sdk/models/aggregate_stat.rb +321 -0
- data/lib/sendpost_ruby_sdk/models/aggregate_stats.rb +310 -0
- data/lib/sendpost_ruby_sdk/models/aggregated_email_stats.rb +321 -0
- data/lib/sendpost_ruby_sdk/models/attachment.rb +27 -24
- data/lib/sendpost_ruby_sdk/models/auto_warmup_plan.rb +531 -0
- data/lib/sendpost_ruby_sdk/models/copy_to.rb +40 -36
- data/lib/sendpost_ruby_sdk/models/create_domain_request.rb +221 -0
- data/lib/sendpost_ruby_sdk/models/create_sub_account_request.rb +221 -0
- data/lib/sendpost_ruby_sdk/models/create_suppression_request.rb +259 -0
- data/lib/sendpost_ruby_sdk/models/create_suppression_request_hard_bounce_inner.rb +220 -0
- data/lib/sendpost_ruby_sdk/models/create_suppression_request_manual_inner.rb +220 -0
- data/lib/sendpost_ruby_sdk/models/create_suppression_request_spam_complaint_inner.rb +220 -0
- data/lib/sendpost_ruby_sdk/models/create_suppression_request_unsubscribe_inner.rb +220 -0
- data/lib/sendpost_ruby_sdk/models/create_webhook_request.rb +361 -0
- data/lib/sendpost_ruby_sdk/models/delete_response.rb +27 -24
- data/lib/sendpost_ruby_sdk/models/delete_sub_account_response.rb +231 -0
- data/lib/sendpost_ruby_sdk/models/delete_suppression200_response_inner.rb +231 -0
- data/lib/sendpost_ruby_sdk/models/delete_suppression_request.rb +222 -0
- data/lib/sendpost_ruby_sdk/models/delete_webhook_response.rb +231 -0
- data/lib/sendpost_ruby_sdk/models/device.rb +25 -24
- data/lib/sendpost_ruby_sdk/models/domain.rb +406 -0
- data/lib/sendpost_ruby_sdk/models/domain_dkim.rb +239 -0
- data/lib/sendpost_ruby_sdk/models/domain_dmarc.rb +239 -0
- data/lib/sendpost_ruby_sdk/models/domain_gpt.rb +239 -0
- data/lib/sendpost_ruby_sdk/models/domain_return_path.rb +239 -0
- data/lib/sendpost_ruby_sdk/models/domain_track.rb +239 -0
- data/lib/sendpost_ruby_sdk/models/eip.rb +238 -0
- data/lib/sendpost_ruby_sdk/models/email_address.rb +229 -0
- data/lib/sendpost_ruby_sdk/models/email_message.rb +133 -103
- data/lib/sendpost_ruby_sdk/models/email_message_from.rb +229 -0
- data/lib/sendpost_ruby_sdk/models/email_message_object.rb +354 -0
- data/lib/sendpost_ruby_sdk/models/email_message_reply_to.rb +229 -0
- data/lib/sendpost_ruby_sdk/models/email_message_to_inner.rb +262 -0
- data/lib/sendpost_ruby_sdk/models/email_message_to_inner_bcc_inner.rb +240 -0
- data/lib/sendpost_ruby_sdk/models/email_message_to_inner_cc_inner.rb +240 -0
- data/lib/sendpost_ruby_sdk/models/email_message_with_template.rb +392 -0
- data/lib/sendpost_ruby_sdk/models/email_response.rb +52 -49
- data/lib/sendpost_ruby_sdk/models/email_stats.rb +230 -0
- data/lib/sendpost_ruby_sdk/models/email_stats_stats.rb +321 -0
- data/lib/sendpost_ruby_sdk/models/event.rb +393 -0
- data/lib/sendpost_ruby_sdk/models/event_metadata.rb +77 -58
- data/lib/sendpost_ruby_sdk/models/geo_location.rb +256 -0
- data/lib/sendpost_ruby_sdk/models/ip.rb +491 -0
- data/lib/sendpost_ruby_sdk/models/ip_allocation_request.rb +266 -0
- data/lib/sendpost_ruby_sdk/models/ip_deletion_response.rb +265 -0
- data/lib/sendpost_ruby_sdk/models/ip_pool.rb +335 -0
- data/lib/sendpost_ruby_sdk/models/ip_pool_create_request.rb +269 -0
- data/lib/sendpost_ruby_sdk/models/ip_pool_delete_response.rb +229 -0
- data/lib/sendpost_ruby_sdk/models/ip_pool_update_request.rb +249 -0
- data/lib/sendpost_ruby_sdk/models/ip_update_request.rb +238 -0
- data/lib/sendpost_ruby_sdk/models/label.rb +241 -0
- data/lib/sendpost_ruby_sdk/models/member.rb +331 -0
- data/lib/sendpost_ruby_sdk/models/message.rb +523 -0
- data/lib/sendpost_ruby_sdk/models/message_header_to.rb +268 -0
- data/lib/sendpost_ruby_sdk/models/message_to.rb +268 -0
- data/lib/sendpost_ruby_sdk/models/operating_system.rb +256 -0
- data/lib/sendpost_ruby_sdk/models/person.rb +231 -0
- data/lib/sendpost_ruby_sdk/models/recipient.rb +263 -0
- data/lib/sendpost_ruby_sdk/models/smtp_auth.rb +261 -0
- data/lib/sendpost_ruby_sdk/models/stat.rb +230 -0
- data/lib/sendpost_ruby_sdk/models/stat_stats.rb +321 -0
- data/lib/sendpost_ruby_sdk/models/sub_account.rb +415 -0
- data/lib/sendpost_ruby_sdk/models/suppression.rb +52 -46
- data/lib/sendpost_ruby_sdk/models/third_party_sending_provider.rb +310 -0
- data/lib/sendpost_ruby_sdk/models/update_sub_account.rb +221 -0
- data/lib/sendpost_ruby_sdk/models/update_webhook.rb +368 -0
- data/lib/sendpost_ruby_sdk/models/user_agent.rb +25 -24
- data/lib/sendpost_ruby_sdk/models/webhook.rb +405 -0
- data/lib/sendpost_ruby_sdk/version.rb +4 -4
- data/lib/sendpost_ruby_sdk.rb +72 -15
- data/spec/api/domain_api_spec.rb +85 -0
- data/spec/api/email_api_spec.rb +9 -9
- data/spec/api/ip_api_spec.rb +98 -0
- data/spec/api/ip_pools_api_spec.rb +98 -0
- data/spec/api/message_api_spec.rb +47 -0
- data/spec/api/stats_a_api_spec.rb +89 -0
- data/spec/api/stats_api_spec.rb +78 -0
- data/spec/api/sub_account_api_spec.rb +98 -0
- data/spec/api/suppression_api_spec.rb +22 -34
- data/spec/api/webhook_api_spec.rb +98 -0
- data/spec/models/account_stats_spec.rb +42 -0
- data/spec/models/account_stats_stat_spec.rb +96 -0
- data/spec/models/aggregate_stat_spec.rb +96 -0
- data/spec/models/aggregate_stats_spec.rb +96 -0
- data/spec/models/aggregated_email_stats_spec.rb +96 -0
- data/spec/models/attachment_spec.rb +6 -4
- data/spec/models/auto_warmup_plan_spec.rb +222 -0
- data/spec/models/copy_to_spec.rb +8 -6
- data/spec/models/create_domain_request_spec.rb +36 -0
- data/spec/models/create_sub_account_request_spec.rb +36 -0
- data/spec/models/create_suppression_request_hard_bounce_inner_spec.rb +36 -0
- data/spec/models/create_suppression_request_manual_inner_spec.rb +36 -0
- data/spec/models/create_suppression_request_spam_complaint_inner_spec.rb +36 -0
- data/spec/models/create_suppression_request_spec.rb +54 -0
- data/spec/models/create_suppression_request_unsubscribe_inner_spec.rb +36 -0
- data/spec/models/create_webhook_request_spec.rb +120 -0
- data/spec/models/delete_response_spec.rb +6 -4
- data/spec/models/delete_sub_account_response_spec.rb +42 -0
- data/spec/models/delete_suppression200_response_inner_spec.rb +42 -0
- data/spec/models/delete_suppression_request_spec.rb +36 -0
- data/spec/models/delete_webhook_response_spec.rb +42 -0
- data/spec/models/device_spec.rb +6 -4
- data/spec/models/domain_dkim_spec.rb +48 -0
- data/spec/models/domain_dmarc_spec.rb +48 -0
- data/spec/models/domain_gpt_spec.rb +48 -0
- data/spec/models/domain_return_path_spec.rb +48 -0
- data/spec/models/domain_spec.rb +150 -0
- data/spec/models/domain_track_spec.rb +48 -0
- data/spec/models/eip_spec.rb +36 -0
- data/spec/models/email_address_spec.rb +42 -0
- data/spec/models/email_message_from_spec.rb +42 -0
- data/spec/models/email_message_object_spec.rb +120 -0
- data/spec/models/email_message_reply_to_spec.rb +42 -0
- data/spec/models/email_message_spec.rb +37 -17
- data/spec/models/email_message_to_inner_bcc_inner_spec.rb +48 -0
- data/spec/models/email_message_to_inner_cc_inner_spec.rb +48 -0
- data/spec/models/email_message_to_inner_spec.rb +60 -0
- data/spec/models/email_message_with_template_spec.rb +138 -0
- data/spec/models/email_response_spec.rb +10 -8
- data/spec/models/email_stats_spec.rb +42 -0
- data/spec/models/email_stats_stats_spec.rb +96 -0
- data/spec/models/event_metadata_spec.rb +24 -10
- data/spec/models/event_spec.rb +150 -0
- data/spec/models/geo_location_spec.rb +60 -0
- data/spec/models/ip_allocation_request_spec.rb +42 -0
- data/spec/models/ip_deletion_response_spec.rb +42 -0
- data/spec/models/ip_pool_create_request_spec.rb +66 -0
- data/spec/models/ip_pool_delete_response_spec.rb +42 -0
- data/spec/models/ip_pool_spec.rb +108 -0
- data/spec/models/ip_pool_update_request_spec.rb +54 -0
- data/spec/models/ip_spec.rb +168 -0
- data/spec/models/ip_update_request_spec.rb +36 -0
- data/spec/models/label_spec.rb +48 -0
- data/spec/models/member_spec.rb +102 -0
- data/spec/models/message_header_to_spec.rb +60 -0
- data/spec/models/message_spec.rb +210 -0
- data/spec/models/message_to_spec.rb +60 -0
- data/spec/models/operating_system_spec.rb +60 -0
- data/spec/models/person_spec.rb +42 -0
- data/spec/models/recipient_spec.rb +60 -0
- data/spec/models/smtp_auth_spec.rb +60 -0
- data/spec/models/stat_spec.rb +42 -0
- data/spec/models/stat_stats_spec.rb +96 -0
- data/spec/models/sub_account_spec.rb +130 -0
- data/spec/models/suppression_spec.rb +11 -9
- data/spec/models/third_party_sending_provider_spec.rb +96 -0
- data/spec/models/update_sub_account_spec.rb +36 -0
- data/spec/models/update_webhook_spec.rb +120 -0
- data/spec/models/user_agent_spec.rb +6 -4
- data/spec/models/webhook_spec.rb +144 -0
- data/spec/spec_helper.rb +3 -3
- metadata +288 -67
- data/config-ruby.json +0 -11
- data/docs/CountStat.md +0 -18
- data/docs/QEmailMessage.md +0 -70
- data/docs/QEvent.md +0 -42
- data/docs/RDSuppression.md +0 -18
- data/docs/RSuppression.md +0 -24
- data/docs/WebhookEvent.md +0 -20
- data/generate-libs.bash +0 -1
- data/lib/sendpost_ruby_sdk/models/city.rb +0 -255
- data/lib/sendpost_ruby_sdk/models/count_stat.rb +0 -219
- data/lib/sendpost_ruby_sdk/models/from.rb +0 -228
- data/lib/sendpost_ruby_sdk/models/os.rb +0 -255
- data/lib/sendpost_ruby_sdk/models/q_email_message.rb +0 -461
- data/lib/sendpost_ruby_sdk/models/q_event.rb +0 -329
- data/lib/sendpost_ruby_sdk/models/r_suppression.rb +0 -254
- data/lib/sendpost_ruby_sdk/models/rd_suppression.rb +0 -221
- data/lib/sendpost_ruby_sdk/models/reply_to.rb +0 -228
- data/lib/sendpost_ruby_sdk/models/suppression_email.rb +0 -219
- data/lib/sendpost_ruby_sdk/models/to.rb +0 -259
- data/lib/sendpost_ruby_sdk/models/webhook_event.rb +0 -228
- data/sendpost.yaml +0 -662
- data/sendpost_ruby_sdk.gemspec +0 -38
- data/spec/api_client_spec.rb +0 -228
- data/spec/configuration_spec.rb +0 -42
- data/spec/models/city_spec.rb +0 -58
- data/spec/models/count_stat_spec.rb +0 -34
- data/spec/models/from_spec.rb +0 -40
- data/spec/models/os_spec.rb +0 -58
- data/spec/models/q_email_message_spec.rb +0 -190
- data/spec/models/q_event_spec.rb +0 -106
- data/spec/models/r_suppression_spec.rb +0 -52
- data/spec/models/rd_suppression_spec.rb +0 -34
- data/spec/models/reply_to_spec.rb +0 -40
- data/spec/models/suppression_email_spec.rb +0 -34
- data/spec/models/to_spec.rb +0 -58
- data/spec/models/webhook_event_spec.rb +0 -40
|
@@ -0,0 +1,356 @@
|
|
|
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 'cgi'
|
|
14
|
+
|
|
15
|
+
module Sendpost
|
|
16
|
+
class WebhookApi
|
|
17
|
+
attr_accessor :api_client
|
|
18
|
+
|
|
19
|
+
def initialize(api_client = ApiClient.default)
|
|
20
|
+
@api_client = api_client
|
|
21
|
+
end
|
|
22
|
+
# Create Webhook
|
|
23
|
+
# Create a new webhook by specifying its properties.
|
|
24
|
+
# @param create_webhook_request [CreateWebhookRequest]
|
|
25
|
+
# @param [Hash] opts the optional parameters
|
|
26
|
+
# @return [Webhook]
|
|
27
|
+
def create_webhook(create_webhook_request, opts = {})
|
|
28
|
+
data, _status_code, _headers = create_webhook_with_http_info(create_webhook_request, opts)
|
|
29
|
+
data
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Create Webhook
|
|
33
|
+
# Create a new webhook by specifying its properties.
|
|
34
|
+
# @param create_webhook_request [CreateWebhookRequest]
|
|
35
|
+
# @param [Hash] opts the optional parameters
|
|
36
|
+
# @return [Array<(Webhook, Integer, Hash)>] Webhook data, response status code and response headers
|
|
37
|
+
def create_webhook_with_http_info(create_webhook_request, opts = {})
|
|
38
|
+
if @api_client.config.debugging
|
|
39
|
+
@api_client.config.logger.debug 'Calling API: WebhookApi.create_webhook ...'
|
|
40
|
+
end
|
|
41
|
+
# verify the required parameter 'create_webhook_request' is set
|
|
42
|
+
if @api_client.config.client_side_validation && create_webhook_request.nil?
|
|
43
|
+
fail ArgumentError, "Missing the required parameter 'create_webhook_request' when calling WebhookApi.create_webhook"
|
|
44
|
+
end
|
|
45
|
+
# resource path
|
|
46
|
+
local_var_path = '/account/webhook'
|
|
47
|
+
|
|
48
|
+
# query parameters
|
|
49
|
+
query_params = opts[:query_params] || {}
|
|
50
|
+
|
|
51
|
+
# header parameters
|
|
52
|
+
header_params = opts[:header_params] || {}
|
|
53
|
+
# HTTP header 'Accept' (if needed)
|
|
54
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
|
|
55
|
+
# HTTP header 'Content-Type'
|
|
56
|
+
content_type = @api_client.select_header_content_type(['application/json'])
|
|
57
|
+
if !content_type.nil?
|
|
58
|
+
header_params['Content-Type'] = content_type
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# form parameters
|
|
62
|
+
form_params = opts[:form_params] || {}
|
|
63
|
+
|
|
64
|
+
# http body (model)
|
|
65
|
+
post_body = opts[:debug_body] || @api_client.object_to_http_body(create_webhook_request)
|
|
66
|
+
|
|
67
|
+
# return_type
|
|
68
|
+
return_type = opts[:debug_return_type] || 'Webhook'
|
|
69
|
+
|
|
70
|
+
# auth_names
|
|
71
|
+
auth_names = opts[:debug_auth_names] || ['accountAuth']
|
|
72
|
+
|
|
73
|
+
new_options = opts.merge(
|
|
74
|
+
:operation => :"WebhookApi.create_webhook",
|
|
75
|
+
:header_params => header_params,
|
|
76
|
+
:query_params => query_params,
|
|
77
|
+
:form_params => form_params,
|
|
78
|
+
:body => post_body,
|
|
79
|
+
:auth_names => auth_names,
|
|
80
|
+
:return_type => return_type
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
|
84
|
+
if @api_client.config.debugging
|
|
85
|
+
@api_client.config.logger.debug "API called: WebhookApi#create_webhook\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
|
86
|
+
end
|
|
87
|
+
return data, status_code, headers
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# Delete Webhook
|
|
91
|
+
# Delete a webhook by its ID.
|
|
92
|
+
# @param webhook_id [Integer] ID of the webhook to delete.
|
|
93
|
+
# @param [Hash] opts the optional parameters
|
|
94
|
+
# @return [DeleteWebhookResponse]
|
|
95
|
+
def delete_webhook(webhook_id, opts = {})
|
|
96
|
+
data, _status_code, _headers = delete_webhook_with_http_info(webhook_id, opts)
|
|
97
|
+
data
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# Delete Webhook
|
|
101
|
+
# Delete a webhook by its ID.
|
|
102
|
+
# @param webhook_id [Integer] ID of the webhook to delete.
|
|
103
|
+
# @param [Hash] opts the optional parameters
|
|
104
|
+
# @return [Array<(DeleteWebhookResponse, Integer, Hash)>] DeleteWebhookResponse data, response status code and response headers
|
|
105
|
+
def delete_webhook_with_http_info(webhook_id, opts = {})
|
|
106
|
+
if @api_client.config.debugging
|
|
107
|
+
@api_client.config.logger.debug 'Calling API: WebhookApi.delete_webhook ...'
|
|
108
|
+
end
|
|
109
|
+
# verify the required parameter 'webhook_id' is set
|
|
110
|
+
if @api_client.config.client_side_validation && webhook_id.nil?
|
|
111
|
+
fail ArgumentError, "Missing the required parameter 'webhook_id' when calling WebhookApi.delete_webhook"
|
|
112
|
+
end
|
|
113
|
+
# resource path
|
|
114
|
+
local_var_path = '/account/webhook/{webhook_id}'.sub('{' + 'webhook_id' + '}', CGI.escape(webhook_id.to_s))
|
|
115
|
+
|
|
116
|
+
# query parameters
|
|
117
|
+
query_params = opts[:query_params] || {}
|
|
118
|
+
|
|
119
|
+
# header parameters
|
|
120
|
+
header_params = opts[:header_params] || {}
|
|
121
|
+
# HTTP header 'Accept' (if needed)
|
|
122
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
|
|
123
|
+
|
|
124
|
+
# form parameters
|
|
125
|
+
form_params = opts[:form_params] || {}
|
|
126
|
+
|
|
127
|
+
# http body (model)
|
|
128
|
+
post_body = opts[:debug_body]
|
|
129
|
+
|
|
130
|
+
# return_type
|
|
131
|
+
return_type = opts[:debug_return_type] || 'DeleteWebhookResponse'
|
|
132
|
+
|
|
133
|
+
# auth_names
|
|
134
|
+
auth_names = opts[:debug_auth_names] || ['accountAuth']
|
|
135
|
+
|
|
136
|
+
new_options = opts.merge(
|
|
137
|
+
:operation => :"WebhookApi.delete_webhook",
|
|
138
|
+
:header_params => header_params,
|
|
139
|
+
:query_params => query_params,
|
|
140
|
+
:form_params => form_params,
|
|
141
|
+
:body => post_body,
|
|
142
|
+
:auth_names => auth_names,
|
|
143
|
+
:return_type => return_type
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
|
|
147
|
+
if @api_client.config.debugging
|
|
148
|
+
@api_client.config.logger.debug "API called: WebhookApi#delete_webhook\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
|
149
|
+
end
|
|
150
|
+
return data, status_code, headers
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
# List Webhooks
|
|
154
|
+
# Retrieves a list of all webhooks, their endpoints, and the events for which they are active.
|
|
155
|
+
# @param [Hash] opts the optional parameters
|
|
156
|
+
# @option opts [Integer] :limit Number of records to return per request.
|
|
157
|
+
# @option opts [Integer] :offset Number of initial records to skip.
|
|
158
|
+
# @option opts [String] :search Case insensitive search against webhook URL.
|
|
159
|
+
# @return [Array<Webhook>]
|
|
160
|
+
def get_all_webhooks(opts = {})
|
|
161
|
+
data, _status_code, _headers = get_all_webhooks_with_http_info(opts)
|
|
162
|
+
data
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
# List Webhooks
|
|
166
|
+
# Retrieves a list of all webhooks, their endpoints, and the events for which they are active.
|
|
167
|
+
# @param [Hash] opts the optional parameters
|
|
168
|
+
# @option opts [Integer] :limit Number of records to return per request.
|
|
169
|
+
# @option opts [Integer] :offset Number of initial records to skip.
|
|
170
|
+
# @option opts [String] :search Case insensitive search against webhook URL.
|
|
171
|
+
# @return [Array<(Array<Webhook>, Integer, Hash)>] Array<Webhook> data, response status code and response headers
|
|
172
|
+
def get_all_webhooks_with_http_info(opts = {})
|
|
173
|
+
if @api_client.config.debugging
|
|
174
|
+
@api_client.config.logger.debug 'Calling API: WebhookApi.get_all_webhooks ...'
|
|
175
|
+
end
|
|
176
|
+
# resource path
|
|
177
|
+
local_var_path = '/account/webhook'
|
|
178
|
+
|
|
179
|
+
# query parameters
|
|
180
|
+
query_params = opts[:query_params] || {}
|
|
181
|
+
query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
|
|
182
|
+
query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
|
|
183
|
+
query_params[:'search'] = opts[:'search'] if !opts[:'search'].nil?
|
|
184
|
+
|
|
185
|
+
# header parameters
|
|
186
|
+
header_params = opts[:header_params] || {}
|
|
187
|
+
# HTTP header 'Accept' (if needed)
|
|
188
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
|
|
189
|
+
|
|
190
|
+
# form parameters
|
|
191
|
+
form_params = opts[:form_params] || {}
|
|
192
|
+
|
|
193
|
+
# http body (model)
|
|
194
|
+
post_body = opts[:debug_body]
|
|
195
|
+
|
|
196
|
+
# return_type
|
|
197
|
+
return_type = opts[:debug_return_type] || 'Array<Webhook>'
|
|
198
|
+
|
|
199
|
+
# auth_names
|
|
200
|
+
auth_names = opts[:debug_auth_names] || ['accountAuth']
|
|
201
|
+
|
|
202
|
+
new_options = opts.merge(
|
|
203
|
+
:operation => :"WebhookApi.get_all_webhooks",
|
|
204
|
+
:header_params => header_params,
|
|
205
|
+
:query_params => query_params,
|
|
206
|
+
:form_params => form_params,
|
|
207
|
+
:body => post_body,
|
|
208
|
+
:auth_names => auth_names,
|
|
209
|
+
:return_type => return_type
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
|
213
|
+
if @api_client.config.debugging
|
|
214
|
+
@api_client.config.logger.debug "API called: WebhookApi#get_all_webhooks\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
|
215
|
+
end
|
|
216
|
+
return data, status_code, headers
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
# Get Webhook
|
|
220
|
+
# Retrieves a specific webhook based on its ID.
|
|
221
|
+
# @param webhook_id [Integer] The ID of the webhook to retrieve.
|
|
222
|
+
# @param [Hash] opts the optional parameters
|
|
223
|
+
# @return [Webhook]
|
|
224
|
+
def get_webhook(webhook_id, opts = {})
|
|
225
|
+
data, _status_code, _headers = get_webhook_with_http_info(webhook_id, opts)
|
|
226
|
+
data
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
# Get Webhook
|
|
230
|
+
# Retrieves a specific webhook based on its ID.
|
|
231
|
+
# @param webhook_id [Integer] The ID of the webhook to retrieve.
|
|
232
|
+
# @param [Hash] opts the optional parameters
|
|
233
|
+
# @return [Array<(Webhook, Integer, Hash)>] Webhook data, response status code and response headers
|
|
234
|
+
def get_webhook_with_http_info(webhook_id, opts = {})
|
|
235
|
+
if @api_client.config.debugging
|
|
236
|
+
@api_client.config.logger.debug 'Calling API: WebhookApi.get_webhook ...'
|
|
237
|
+
end
|
|
238
|
+
# verify the required parameter 'webhook_id' is set
|
|
239
|
+
if @api_client.config.client_side_validation && webhook_id.nil?
|
|
240
|
+
fail ArgumentError, "Missing the required parameter 'webhook_id' when calling WebhookApi.get_webhook"
|
|
241
|
+
end
|
|
242
|
+
# resource path
|
|
243
|
+
local_var_path = '/account/webhook/{webhook_id}'.sub('{' + 'webhook_id' + '}', CGI.escape(webhook_id.to_s))
|
|
244
|
+
|
|
245
|
+
# query parameters
|
|
246
|
+
query_params = opts[:query_params] || {}
|
|
247
|
+
|
|
248
|
+
# header parameters
|
|
249
|
+
header_params = opts[:header_params] || {}
|
|
250
|
+
# HTTP header 'Accept' (if needed)
|
|
251
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
|
|
252
|
+
|
|
253
|
+
# form parameters
|
|
254
|
+
form_params = opts[:form_params] || {}
|
|
255
|
+
|
|
256
|
+
# http body (model)
|
|
257
|
+
post_body = opts[:debug_body]
|
|
258
|
+
|
|
259
|
+
# return_type
|
|
260
|
+
return_type = opts[:debug_return_type] || 'Webhook'
|
|
261
|
+
|
|
262
|
+
# auth_names
|
|
263
|
+
auth_names = opts[:debug_auth_names] || ['accountAuth']
|
|
264
|
+
|
|
265
|
+
new_options = opts.merge(
|
|
266
|
+
:operation => :"WebhookApi.get_webhook",
|
|
267
|
+
:header_params => header_params,
|
|
268
|
+
:query_params => query_params,
|
|
269
|
+
:form_params => form_params,
|
|
270
|
+
:body => post_body,
|
|
271
|
+
:auth_names => auth_names,
|
|
272
|
+
:return_type => return_type
|
|
273
|
+
)
|
|
274
|
+
|
|
275
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
|
276
|
+
if @api_client.config.debugging
|
|
277
|
+
@api_client.config.logger.debug "API called: WebhookApi#get_webhook\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
|
278
|
+
end
|
|
279
|
+
return data, status_code, headers
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
# Update Webhook
|
|
283
|
+
# Update the properties of an existing webhook.
|
|
284
|
+
# @param update_webhook [UpdateWebhook]
|
|
285
|
+
# @param webhook_id [Integer] ID of the webhook to update.
|
|
286
|
+
# @param [Hash] opts the optional parameters
|
|
287
|
+
# @return [Webhook]
|
|
288
|
+
def update_webhook(update_webhook, webhook_id, opts = {})
|
|
289
|
+
data, _status_code, _headers = update_webhook_with_http_info(update_webhook, webhook_id, opts)
|
|
290
|
+
data
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
# Update Webhook
|
|
294
|
+
# Update the properties of an existing webhook.
|
|
295
|
+
# @param update_webhook [UpdateWebhook]
|
|
296
|
+
# @param webhook_id [Integer] ID of the webhook to update.
|
|
297
|
+
# @param [Hash] opts the optional parameters
|
|
298
|
+
# @return [Array<(Webhook, Integer, Hash)>] Webhook data, response status code and response headers
|
|
299
|
+
def update_webhook_with_http_info(update_webhook, webhook_id, opts = {})
|
|
300
|
+
if @api_client.config.debugging
|
|
301
|
+
@api_client.config.logger.debug 'Calling API: WebhookApi.update_webhook ...'
|
|
302
|
+
end
|
|
303
|
+
# verify the required parameter 'update_webhook' is set
|
|
304
|
+
if @api_client.config.client_side_validation && update_webhook.nil?
|
|
305
|
+
fail ArgumentError, "Missing the required parameter 'update_webhook' when calling WebhookApi.update_webhook"
|
|
306
|
+
end
|
|
307
|
+
# verify the required parameter 'webhook_id' is set
|
|
308
|
+
if @api_client.config.client_side_validation && webhook_id.nil?
|
|
309
|
+
fail ArgumentError, "Missing the required parameter 'webhook_id' when calling WebhookApi.update_webhook"
|
|
310
|
+
end
|
|
311
|
+
# resource path
|
|
312
|
+
local_var_path = '/account/webhook/{webhook_id}'.sub('{' + 'webhook_id' + '}', CGI.escape(webhook_id.to_s))
|
|
313
|
+
|
|
314
|
+
# query parameters
|
|
315
|
+
query_params = opts[:query_params] || {}
|
|
316
|
+
|
|
317
|
+
# header parameters
|
|
318
|
+
header_params = opts[:header_params] || {}
|
|
319
|
+
# HTTP header 'Accept' (if needed)
|
|
320
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
|
|
321
|
+
# HTTP header 'Content-Type'
|
|
322
|
+
content_type = @api_client.select_header_content_type(['application/json'])
|
|
323
|
+
if !content_type.nil?
|
|
324
|
+
header_params['Content-Type'] = content_type
|
|
325
|
+
end
|
|
326
|
+
|
|
327
|
+
# form parameters
|
|
328
|
+
form_params = opts[:form_params] || {}
|
|
329
|
+
|
|
330
|
+
# http body (model)
|
|
331
|
+
post_body = opts[:debug_body] || @api_client.object_to_http_body(update_webhook)
|
|
332
|
+
|
|
333
|
+
# return_type
|
|
334
|
+
return_type = opts[:debug_return_type] || 'Webhook'
|
|
335
|
+
|
|
336
|
+
# auth_names
|
|
337
|
+
auth_names = opts[:debug_auth_names] || ['accountAuth']
|
|
338
|
+
|
|
339
|
+
new_options = opts.merge(
|
|
340
|
+
:operation => :"WebhookApi.update_webhook",
|
|
341
|
+
:header_params => header_params,
|
|
342
|
+
:query_params => query_params,
|
|
343
|
+
:form_params => form_params,
|
|
344
|
+
:body => post_body,
|
|
345
|
+
:auth_names => auth_names,
|
|
346
|
+
:return_type => return_type
|
|
347
|
+
)
|
|
348
|
+
|
|
349
|
+
data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
|
|
350
|
+
if @api_client.config.debugging
|
|
351
|
+
@api_client.config.logger.debug "API called: WebhookApi#update_webhook\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
|
352
|
+
end
|
|
353
|
+
return data, status_code, headers
|
|
354
|
+
end
|
|
355
|
+
end
|
|
356
|
+
end
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
=begin
|
|
2
2
|
#SendPost API
|
|
3
3
|
|
|
4
|
-
#Email API and SMTP relay to not just send and measure email sending, but also alert and optimise. We provide you with tools, expertise and support needed to reliably deliver emails to your customers inboxes on time, every time.
|
|
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
5
|
|
|
6
6
|
The version of the OpenAPI document: 1.0.0
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
|
-
|
|
9
|
+
Generator version: 7.13.0
|
|
10
10
|
|
|
11
11
|
=end
|
|
12
12
|
|
|
@@ -17,6 +17,7 @@ require 'tempfile'
|
|
|
17
17
|
require 'time'
|
|
18
18
|
require 'typhoeus'
|
|
19
19
|
|
|
20
|
+
|
|
20
21
|
module Sendpost
|
|
21
22
|
class ApiClient
|
|
22
23
|
# The Configuration object holding settings to be used in the API client.
|
|
@@ -45,9 +46,11 @@ module Sendpost
|
|
|
45
46
|
# Call an API with given options.
|
|
46
47
|
#
|
|
47
48
|
# @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
|
|
48
|
-
# the data deserialized from response body (
|
|
49
|
+
# the data deserialized from response body (may be a Tempfile or nil), response status code and response headers.
|
|
49
50
|
def call_api(http_method, path, opts = {})
|
|
50
51
|
request = build_request(http_method, path, opts)
|
|
52
|
+
tempfile = nil
|
|
53
|
+
(download_file(request) { tempfile = _1 }) if opts[:return_type] == 'File'
|
|
51
54
|
response = request.run
|
|
52
55
|
|
|
53
56
|
if @config.debugging
|
|
@@ -69,7 +72,9 @@ module Sendpost
|
|
|
69
72
|
end
|
|
70
73
|
end
|
|
71
74
|
|
|
72
|
-
if opts[:return_type]
|
|
75
|
+
if opts[:return_type] == 'File'
|
|
76
|
+
data = tempfile
|
|
77
|
+
elsif opts[:return_type]
|
|
73
78
|
data = deserialize(response, opts[:return_type])
|
|
74
79
|
else
|
|
75
80
|
data = nil
|
|
@@ -95,6 +100,7 @@ module Sendpost
|
|
|
95
100
|
form_params = opts[:form_params] || {}
|
|
96
101
|
follow_location = opts[:follow_location] || true
|
|
97
102
|
|
|
103
|
+
update_params_for_auth! header_params, query_params, opts[:auth_names]
|
|
98
104
|
|
|
99
105
|
# set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
|
|
100
106
|
_verify_ssl_host = @config.verify_ssl_host ? 2 : 0
|
|
@@ -124,9 +130,7 @@ module Sendpost
|
|
|
124
130
|
end
|
|
125
131
|
end
|
|
126
132
|
|
|
127
|
-
|
|
128
|
-
download_file(request) if opts[:return_type] == 'File'
|
|
129
|
-
request
|
|
133
|
+
Typhoeus::Request.new(url, req_opts)
|
|
130
134
|
end
|
|
131
135
|
|
|
132
136
|
# Builds the HTTP request body
|
|
@@ -164,6 +168,8 @@ module Sendpost
|
|
|
164
168
|
# process can use.
|
|
165
169
|
#
|
|
166
170
|
# @see Configuration#temp_folder_path
|
|
171
|
+
#
|
|
172
|
+
# @return [Tempfile] the tempfile generated
|
|
167
173
|
def download_file(request)
|
|
168
174
|
tempfile = nil
|
|
169
175
|
encoding = nil
|
|
@@ -178,20 +184,21 @@ module Sendpost
|
|
|
178
184
|
prefix = prefix + '-' unless prefix.end_with?('-')
|
|
179
185
|
encoding = response.body.encoding
|
|
180
186
|
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
|
|
181
|
-
@tempfile = tempfile
|
|
182
187
|
end
|
|
183
188
|
request.on_body do |chunk|
|
|
184
189
|
chunk.force_encoding(encoding)
|
|
185
190
|
tempfile.write(chunk)
|
|
186
191
|
end
|
|
187
|
-
request.on_complete do
|
|
188
|
-
if tempfile
|
|
189
|
-
tempfile.
|
|
190
|
-
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
|
|
191
|
-
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
|
|
192
|
-
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
|
|
193
|
-
"explicitly with `tempfile.delete`"
|
|
192
|
+
request.on_complete do
|
|
193
|
+
if !tempfile
|
|
194
|
+
fail ApiError.new("Failed to create the tempfile based on the HTTP response from the server: #{request.inspect}")
|
|
194
195
|
end
|
|
196
|
+
tempfile.close
|
|
197
|
+
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
|
|
198
|
+
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
|
|
199
|
+
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
|
|
200
|
+
"explicitly with `tempfile.delete`"
|
|
201
|
+
yield tempfile if block_given?
|
|
195
202
|
end
|
|
196
203
|
end
|
|
197
204
|
|
|
@@ -204,7 +211,7 @@ module Sendpost
|
|
|
204
211
|
# @param [String] mime MIME
|
|
205
212
|
# @return [Boolean] True if the MIME is application/json
|
|
206
213
|
def json_mime?(mime)
|
|
207
|
-
(mime == '*/*') || !(mime =~
|
|
214
|
+
(mime == '*/*') || !(mime =~ /^Application\/.*json(?!p)(;.*)?/i).nil?
|
|
208
215
|
end
|
|
209
216
|
|
|
210
217
|
# Deserialize the response to the given return type.
|
|
@@ -213,15 +220,10 @@ module Sendpost
|
|
|
213
220
|
# @param [String] return_type some examples: "User", "Array<User>", "Hash<String, Integer>"
|
|
214
221
|
def deserialize(response, return_type)
|
|
215
222
|
body = response.body
|
|
216
|
-
|
|
217
|
-
# handle file downloading - return the File instance processed in request callbacks
|
|
218
|
-
# note that response body is empty when the file is written in chunks in request on_body callback
|
|
219
|
-
return @tempfile if return_type == 'File'
|
|
220
|
-
|
|
221
223
|
return nil if body.nil? || body.empty?
|
|
222
224
|
|
|
223
225
|
# return response body directly for String return type
|
|
224
|
-
return body if return_type == 'String'
|
|
226
|
+
return body.to_s if return_type == 'String'
|
|
225
227
|
|
|
226
228
|
# ensuring a default content type
|
|
227
229
|
content_type = response.headers['Content-Type'] || 'application/json'
|
|
@@ -288,7 +290,7 @@ module Sendpost
|
|
|
288
290
|
# @param [String] filename the filename to be sanitized
|
|
289
291
|
# @return [String] the sanitized filename
|
|
290
292
|
def sanitize_filename(filename)
|
|
291
|
-
filename.
|
|
293
|
+
filename.split(/[\/\\]/).last
|
|
292
294
|
end
|
|
293
295
|
|
|
294
296
|
def build_request_url(path, opts = {})
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
=begin
|
|
2
2
|
#SendPost API
|
|
3
3
|
|
|
4
|
-
#Email API and SMTP relay to not just send and measure email sending, but also alert and optimise. We provide you with tools, expertise and support needed to reliably deliver emails to your customers inboxes on time, every time.
|
|
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
5
|
|
|
6
6
|
The version of the OpenAPI document: 1.0.0
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
|
-
|
|
9
|
+
Generator version: 7.13.0
|
|
10
10
|
|
|
11
11
|
=end
|
|
12
12
|
|