sendpost_ruby_sdk 2.0.0 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 77a55c11cce40b33b2c880f6d42bb5a53749cc3627f219ff7c38955438a75804
4
- data.tar.gz: 37790210a165536fd65424d90b9777b3956eb383cc3d06cb2181699a23129323
3
+ metadata.gz: ea2afe741869ffcf484e04f9b24c8f61ea0583ea5a74cc2cd3f376a95b9f4c8e
4
+ data.tar.gz: 3390eed8208d41d806541f655a3c31960357d8ec43073c829f19c4f63fa65e52
5
5
  SHA512:
6
- metadata.gz: b07232b856c4fa46be8fd3afeb4c222c0ff7800d05bcd0f0d3e7658efb4ea5b8b056e578e7f34484cf2ca83e6b764b671d08d1da7c488b1c6d529ba6240acc8f
7
- data.tar.gz: 61c58aa090f5dfdbdb17f20fb764e7c0fb87e5396c65240afed94d23ce4db5fba1666a3913848ac6245a5169028bd534f3f97d506af6ef4271477c604cb96c59
6
+ metadata.gz: 7367a3dc46dc42b9252d81e35483aaf21d6f279524731cdb35bb243d894222da0e7aab6056861222419729ea282c9b959fa94faec0b8ca1bc22248034edafdae
7
+ data.tar.gz: d27af0cc99ee9169195ca8ada9054891ca3f743554cfa37dc77468845483e4fa5cbb1873be754629584100ade5ba8ddb47be6a3061f0207e96f7f98afb478274
data/README.md CHANGED
@@ -520,7 +520,10 @@ puts "Suppressions added successfully"
520
520
  #### List Suppressions
521
521
 
522
522
  ```ruby
523
- suppressions = suppression_api.get_suppression_list
523
+ to_date = Date.today
524
+ from_date = to_date - 7
525
+
526
+ suppressions = suppression_api.get_suppression_list(from_date, to_date)
524
527
 
525
528
  suppressions.each do |suppression|
526
529
  puts "Email: #{suppression.email}"
data/docs/DomainSpf.md ADDED
@@ -0,0 +1,22 @@
1
+ # Sendpost::DomainSpf
2
+
3
+ ## Properties
4
+
5
+ | Name | Type | Description | Notes |
6
+ | ---- | ---- | ----------- | ----- |
7
+ | **host** | **String** | | [optional] |
8
+ | **type** | **String** | | [optional] |
9
+ | **text_value** | **String** | | [optional] |
10
+
11
+ ## Example
12
+
13
+ ```ruby
14
+ require 'sendpost_ruby_sdk'
15
+
16
+ instance = Sendpost::DomainSpf.new(
17
+ host: sp-bounce.example.com,
18
+ type: CNAME,
19
+ text_value: sp.sendpost.info
20
+ )
21
+ ```
22
+
data/docs/StatStat.md ADDED
@@ -0,0 +1,38 @@
1
+ # Sendpost::StatStat
2
+
3
+ ## Properties
4
+
5
+ | Name | Type | Description | Notes |
6
+ | ---- | ---- | ----------- | ----- |
7
+ | **processed** | **Integer** | Number of emails accepted by SendPost API. | [optional] |
8
+ | **sent** | **Integer** | Number of emails sent. | [optional] |
9
+ | **delivered** | **Integer** | Number of emails we were able to successfully deliver at SMTP without encountering any error | [optional] |
10
+ | **dropped** | **Integer** | Number of emails drop without attempting to deliver either because the email is invalid or email in in existing suppression list | [optional] |
11
+ | **smtp_dropped** | **Integer** | Number of emails dropped by SMTP. | [optional] |
12
+ | **hard_bounced** | **Integer** | Number of emails where we got SMTP hard bounce error code by the recipient mail provider | [optional] |
13
+ | **soft_bounced** | **Integer** | 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. | [optional] |
14
+ | **opened** | **Integer** | Number of emails opened by recipients | [optional] |
15
+ | **clicked** | **Integer** | Number of email links clicked by recipients | [optional] |
16
+ | **unsubscribed** | **Integer** | Number of email recipients who unsubscribed from receiving further emails | [optional] |
17
+ | **spam** | **Integer** | Number of email recipients who marked emails as spam | [optional] |
18
+
19
+ ## Example
20
+
21
+ ```ruby
22
+ require 'sendpost_ruby_sdk'
23
+
24
+ instance = Sendpost::StatStat.new(
25
+ processed: 225,
26
+ sent: 220,
27
+ delivered: 200,
28
+ dropped: 10,
29
+ smtp_dropped: 5,
30
+ hard_bounced: 10,
31
+ soft_bounced: 5,
32
+ opened: 150,
33
+ clicked: 130,
34
+ unsubscribed: 6,
35
+ spam: 2
36
+ )
37
+ ```
38
+
@@ -35,7 +35,8 @@ module Sendpost
35
35
 
36
36
  attr_accessor :unsubscribed
37
37
 
38
- attr_accessor :spams
38
+ # Number of spam complaints
39
+ attr_accessor :spam
39
40
 
40
41
  # Attribute mapping from ruby-style variable name to JSON key.
41
42
  def self.attribute_map
@@ -50,7 +51,7 @@ module Sendpost
50
51
  :'opened' => :'opened',
51
52
  :'clicked' => :'clicked',
52
53
  :'unsubscribed' => :'unsubscribed',
53
- :'spams' => :'spams'
54
+ :'spam' => :'spam'
54
55
  }
55
56
  end
56
57
 
@@ -77,7 +78,7 @@ module Sendpost
77
78
  :'opened' => :'Integer',
78
79
  :'clicked' => :'Integer',
79
80
  :'unsubscribed' => :'Integer',
80
- :'spams' => :'Integer'
81
+ :'spam' => :'Integer'
81
82
  }
82
83
  end
83
84
 
@@ -143,8 +144,8 @@ module Sendpost
143
144
  self.unsubscribed = attributes[:'unsubscribed']
144
145
  end
145
146
 
146
- if attributes.key?(:'spams')
147
- self.spams = attributes[:'spams']
147
+ if attributes.key?(:'spam')
148
+ self.spam = attributes[:'spam']
148
149
  end
149
150
  end
150
151
 
@@ -178,7 +179,7 @@ module Sendpost
178
179
  opened == o.opened &&
179
180
  clicked == o.clicked &&
180
181
  unsubscribed == o.unsubscribed &&
181
- spams == o.spams
182
+ spam == o.spam
182
183
  end
183
184
 
184
185
  # @see the `==` method
@@ -190,7 +191,7 @@ module Sendpost
190
191
  # Calculates hash code according to all attributes.
191
192
  # @return [Integer] Hash code
192
193
  def hash
193
- [processed, sent, delivered, dropped, smtp_dropped, hard_bounced, soft_bounced, opened, clicked, unsubscribed, spams].hash
194
+ [processed, sent, delivered, dropped, smtp_dropped, hard_bounced, soft_bounced, opened, clicked, unsubscribed, spam].hash
194
195
  end
195
196
 
196
197
  # Builds the object from hash
@@ -23,6 +23,8 @@ module Sendpost
23
23
 
24
24
  attr_accessor :dkim
25
25
 
26
+ attr_accessor :spf
27
+
26
28
  attr_accessor :return_path
27
29
 
28
30
  attr_accessor :track
@@ -35,6 +37,12 @@ module Sendpost
35
37
  # Status of DKIM verification ( true or false )
36
38
  attr_accessor :dkim_verified
37
39
 
40
+ # Status of SPF verification ( true or false )
41
+ attr_accessor :spf_verified
42
+
43
+ # Status of Mailbox verification ( true or false )
44
+ attr_accessor :mailbox_verified
45
+
38
46
  # Status of DMARC verification ( true or false)
39
47
  attr_accessor :dmarc_verified
40
48
 
@@ -76,11 +84,14 @@ module Sendpost
76
84
  :'id' => :'id',
77
85
  :'name' => :'name',
78
86
  :'dkim' => :'dkim',
87
+ :'spf' => :'spf',
79
88
  :'return_path' => :'returnPath',
80
89
  :'track' => :'track',
81
90
  :'dmarc' => :'dmarc',
82
91
  :'dkim_config' => :'dkimConfig',
83
92
  :'dkim_verified' => :'dkimVerified',
93
+ :'spf_verified' => :'spfVerified',
94
+ :'mailbox_verified' => :'mailboxVerified',
84
95
  :'dmarc_verified' => :'dmarcVerified',
85
96
  :'return_path_verified' => :'returnPathVerified',
86
97
  :'track_verified' => :'trackVerified',
@@ -112,11 +123,14 @@ module Sendpost
112
123
  :'id' => :'Integer',
113
124
  :'name' => :'String',
114
125
  :'dkim' => :'DomainDkim',
126
+ :'spf' => :'DomainSpf',
115
127
  :'return_path' => :'DomainReturnPath',
116
128
  :'track' => :'DomainTrack',
117
129
  :'dmarc' => :'DomainDmarc',
118
130
  :'dkim_config' => :'String',
119
131
  :'dkim_verified' => :'Boolean',
132
+ :'spf_verified' => :'Boolean',
133
+ :'mailbox_verified' => :'Boolean',
120
134
  :'dmarc_verified' => :'Boolean',
121
135
  :'return_path_verified' => :'Boolean',
122
136
  :'track_verified' => :'Boolean',
@@ -166,6 +180,10 @@ module Sendpost
166
180
  self.dkim = attributes[:'dkim']
167
181
  end
168
182
 
183
+ if attributes.key?(:'spf')
184
+ self.spf = attributes[:'spf']
185
+ end
186
+
169
187
  if attributes.key?(:'return_path')
170
188
  self.return_path = attributes[:'return_path']
171
189
  end
@@ -186,6 +204,14 @@ module Sendpost
186
204
  self.dkim_verified = attributes[:'dkim_verified']
187
205
  end
188
206
 
207
+ if attributes.key?(:'spf_verified')
208
+ self.spf_verified = attributes[:'spf_verified']
209
+ end
210
+
211
+ if attributes.key?(:'mailbox_verified')
212
+ self.mailbox_verified = attributes[:'mailbox_verified']
213
+ end
214
+
189
215
  if attributes.key?(:'dmarc_verified')
190
216
  self.dmarc_verified = attributes[:'dmarc_verified']
191
217
  end
@@ -258,11 +284,14 @@ module Sendpost
258
284
  id == o.id &&
259
285
  name == o.name &&
260
286
  dkim == o.dkim &&
287
+ spf == o.spf &&
261
288
  return_path == o.return_path &&
262
289
  track == o.track &&
263
290
  dmarc == o.dmarc &&
264
291
  dkim_config == o.dkim_config &&
265
292
  dkim_verified == o.dkim_verified &&
293
+ spf_verified == o.spf_verified &&
294
+ mailbox_verified == o.mailbox_verified &&
266
295
  dmarc_verified == o.dmarc_verified &&
267
296
  return_path_verified == o.return_path_verified &&
268
297
  track_verified == o.track_verified &&
@@ -286,7 +315,7 @@ module Sendpost
286
315
  # Calculates hash code according to all attributes.
287
316
  # @return [Integer] Hash code
288
317
  def hash
289
- [id, name, dkim, return_path, track, dmarc, dkim_config, dkim_verified, dmarc_verified, return_path_verified, track_verified, verified, domain_registered_date, created, gpt_verified, gpt, dmarc_failure_reason, dkim_failure_reason, track_failure_reason, return_path_failure_reason].hash
318
+ [id, name, dkim, spf, return_path, track, dmarc, dkim_config, dkim_verified, spf_verified, mailbox_verified, dmarc_verified, return_path_verified, track_verified, verified, domain_registered_date, created, gpt_verified, gpt, dmarc_failure_reason, dkim_failure_reason, track_failure_reason, return_path_failure_reason].hash
290
319
  end
291
320
 
292
321
  # Builds the object from hash
@@ -0,0 +1,239 @@
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
+ # SPF record host, type and value
18
+ class DomainSpf
19
+ attr_accessor :host
20
+
21
+ attr_accessor :type
22
+
23
+ attr_accessor :text_value
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'host' => :'host',
29
+ :'type' => :'type',
30
+ :'text_value' => :'textValue'
31
+ }
32
+ end
33
+
34
+ # Returns attribute mapping this model knows about
35
+ def self.acceptable_attribute_map
36
+ attribute_map
37
+ end
38
+
39
+ # Returns all the JSON keys this model knows about
40
+ def self.acceptable_attributes
41
+ acceptable_attribute_map.values
42
+ end
43
+
44
+ # Attribute type mapping.
45
+ def self.openapi_types
46
+ {
47
+ :'host' => :'String',
48
+ :'type' => :'String',
49
+ :'text_value' => :'String'
50
+ }
51
+ end
52
+
53
+ # List of attributes with nullable: true
54
+ def self.openapi_nullable
55
+ Set.new([
56
+ ])
57
+ end
58
+
59
+ # Initializes the object
60
+ # @param [Hash] attributes Model attributes in the form of hash
61
+ def initialize(attributes = {})
62
+ if (!attributes.is_a?(Hash))
63
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Sendpost::DomainSpf` initialize method"
64
+ end
65
+
66
+ # check to see if the attribute exists and convert string to symbol for hash key
67
+ acceptable_attribute_map = self.class.acceptable_attribute_map
68
+ attributes = attributes.each_with_object({}) { |(k, v), h|
69
+ if (!acceptable_attribute_map.key?(k.to_sym))
70
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Sendpost::DomainSpf`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
71
+ end
72
+ h[k.to_sym] = v
73
+ }
74
+
75
+ if attributes.key?(:'host')
76
+ self.host = attributes[:'host']
77
+ end
78
+
79
+ if attributes.key?(:'type')
80
+ self.type = attributes[:'type']
81
+ end
82
+
83
+ if attributes.key?(:'text_value')
84
+ self.text_value = attributes[:'text_value']
85
+ end
86
+ end
87
+
88
+ # Show invalid properties with the reasons. Usually used together with valid?
89
+ # @return Array for valid properties with the reasons
90
+ def list_invalid_properties
91
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
92
+ invalid_properties = Array.new
93
+ invalid_properties
94
+ end
95
+
96
+ # Check to see if the all the properties in the model are valid
97
+ # @return true if the model is valid
98
+ def valid?
99
+ warn '[DEPRECATED] the `valid?` method is obsolete'
100
+ true
101
+ end
102
+
103
+ # Checks equality by comparing each attribute.
104
+ # @param [Object] Object to be compared
105
+ def ==(o)
106
+ return true if self.equal?(o)
107
+ self.class == o.class &&
108
+ host == o.host &&
109
+ type == o.type &&
110
+ text_value == o.text_value
111
+ end
112
+
113
+ # @see the `==` method
114
+ # @param [Object] Object to be compared
115
+ def eql?(o)
116
+ self == o
117
+ end
118
+
119
+ # Calculates hash code according to all attributes.
120
+ # @return [Integer] Hash code
121
+ def hash
122
+ [host, type, text_value].hash
123
+ end
124
+
125
+ # Builds the object from hash
126
+ # @param [Hash] attributes Model attributes in the form of hash
127
+ # @return [Object] Returns the model itself
128
+ def self.build_from_hash(attributes)
129
+ return nil unless attributes.is_a?(Hash)
130
+ attributes = attributes.transform_keys(&:to_sym)
131
+ transformed_hash = {}
132
+ openapi_types.each_pair do |key, type|
133
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
134
+ transformed_hash["#{key}"] = nil
135
+ elsif type =~ /\AArray<(.*)>/i
136
+ # check to ensure the input is an array given that the attribute
137
+ # is documented as an array but the input is not
138
+ if attributes[attribute_map[key]].is_a?(Array)
139
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
140
+ end
141
+ elsif !attributes[attribute_map[key]].nil?
142
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
143
+ end
144
+ end
145
+ new(transformed_hash)
146
+ end
147
+
148
+ # Deserializes the data based on type
149
+ # @param string type Data type
150
+ # @param string value Value to be deserialized
151
+ # @return [Object] Deserialized data
152
+ def self._deserialize(type, value)
153
+ case type.to_sym
154
+ when :Time
155
+ Time.parse(value)
156
+ when :Date
157
+ Date.parse(value)
158
+ when :String
159
+ value.to_s
160
+ when :Integer
161
+ value.to_i
162
+ when :Float
163
+ value.to_f
164
+ when :Boolean
165
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
166
+ true
167
+ else
168
+ false
169
+ end
170
+ when :Object
171
+ # generic object (usually a Hash), return directly
172
+ value
173
+ when /\AArray<(?<inner_type>.+)>\z/
174
+ inner_type = Regexp.last_match[:inner_type]
175
+ value.map { |v| _deserialize(inner_type, v) }
176
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
177
+ k_type = Regexp.last_match[:k_type]
178
+ v_type = Regexp.last_match[:v_type]
179
+ {}.tap do |hash|
180
+ value.each do |k, v|
181
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
182
+ end
183
+ end
184
+ else # model
185
+ # models (e.g. Pet) or oneOf
186
+ klass = Sendpost.const_get(type)
187
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
188
+ end
189
+ end
190
+
191
+ # Returns the string representation of the object
192
+ # @return [String] String presentation of the object
193
+ def to_s
194
+ to_hash.to_s
195
+ end
196
+
197
+ # to_body is an alias to to_hash (backward compatibility)
198
+ # @return [Hash] Returns the object in the form of hash
199
+ def to_body
200
+ to_hash
201
+ end
202
+
203
+ # Returns the object in the form of hash
204
+ # @return [Hash] Returns the object in the form of hash
205
+ def to_hash
206
+ hash = {}
207
+ self.class.attribute_map.each_pair do |attr, param|
208
+ value = self.send(attr)
209
+ if value.nil?
210
+ is_nullable = self.class.openapi_nullable.include?(attr)
211
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
212
+ end
213
+
214
+ hash[param] = _to_hash(value)
215
+ end
216
+ hash
217
+ end
218
+
219
+ # Outputs non-array value in the form of hash
220
+ # For object, use to_hash. Otherwise, just return the value
221
+ # @param [Object] value Any valid value
222
+ # @return [Hash] Returns the value in the form of hash
223
+ def _to_hash(value)
224
+ if value.is_a?(Array)
225
+ value.compact.map { |v| _to_hash(v) }
226
+ elsif value.is_a?(Hash)
227
+ {}.tap do |hash|
228
+ value.each { |k, v| hash[k] = _to_hash(v) }
229
+ end
230
+ elsif value.respond_to? :to_hash
231
+ value.to_hash
232
+ else
233
+ value
234
+ end
235
+ end
236
+
237
+ end
238
+
239
+ end