mailosaur 5.0.2 → 5.0.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/LICENSE +1 -1
- data/README.md +0 -39
- data/lib/Mailosaur/analysis.rb +14 -161
- data/lib/Mailosaur/files.rb +21 -253
- data/lib/Mailosaur/messages.rb +63 -567
- data/lib/Mailosaur/models/attachment.rb +10 -77
- data/lib/Mailosaur/models/base_model.rb +16 -0
- data/lib/Mailosaur/models/forwarding_rule.rb +8 -61
- data/lib/Mailosaur/models/image.rb +6 -45
- data/lib/Mailosaur/models/link.rb +6 -45
- data/lib/Mailosaur/models/message.rb +21 -173
- data/lib/Mailosaur/models/message_address.rb +7 -53
- data/lib/Mailosaur/models/message_content.rb +9 -71
- data/lib/Mailosaur/models/message_header.rb +6 -45
- data/lib/Mailosaur/models/message_list_result.rb +6 -45
- data/lib/Mailosaur/models/message_summary.rb +20 -162
- data/lib/Mailosaur/models/metadata.rb +6 -45
- data/lib/Mailosaur/models/search_criteria.rb +7 -53
- data/lib/Mailosaur/models/server.rb +11 -94
- data/lib/Mailosaur/models/server_create_options.rb +5 -37
- data/lib/Mailosaur/models/server_list_result.rb +6 -45
- data/lib/Mailosaur/models/spam_analysis_result.rb +7 -48
- data/lib/Mailosaur/models/spam_assassin_rule.rb +7 -53
- data/lib/Mailosaur/models/spam_filter_results.rb +6 -46
- data/lib/Mailosaur/module_definition.rb +0 -5
- data/lib/Mailosaur/servers.rb +52 -465
- data/lib/Mailosaur/version.rb +1 -6
- data/lib/mailosaur.rb +32 -16
- metadata +49 -42
- data/lib/Mailosaur/mailosaur_base_client.rb +0 -120
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0ac89c532d7f0519c3a2d620af601b75e7b83dffc3df92e842acb7de6610d2a1
|
4
|
+
data.tar.gz: f1dc7d047492d560f764fbf3f3ac7937e26a29f4ce163c744f017562cbba4e33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc72c693120dc3a6730d96c7666a4100bd000a6ef237470df762737cc0bfb00a6b7979e5be9ba273e11a92dd8ab68e19a14dd42a83d6ed2ea9d14fe7d78e7eec
|
7
|
+
data.tar.gz: 8c6982baaee8c5c733ed3816440340a746606512acf1f0d1e523aca08f11129ffab06481ffef676f484273952460f86caa8b2fec529f959489e08f9d63322810
|
data/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
MIT License
|
2
2
|
|
3
|
-
Copyright (c)
|
3
|
+
Copyright (c) 2019 Mailosaur Ltd (https://mailosaur.com)
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
@@ -14,45 +14,6 @@ gem install mailosaur
|
|
14
14
|
|
15
15
|
[Mailosaur's documentation](https://mailosaur.com/docs) includes all the information and usage examples you'll need.
|
16
16
|
|
17
|
-
## Building
|
18
|
-
|
19
|
-
1. Install [Node.js](https://nodejs.org/) (LTS)
|
20
|
-
|
21
|
-
2. Install [AutoRest](https://github.com/Azure/autorest) using `npm`
|
22
|
-
|
23
|
-
```
|
24
|
-
# Depending on your configuration you may need to be elevated or root to run this. (on OSX/Linux use 'sudo')
|
25
|
-
npm install -g autorest
|
26
|
-
```
|
27
|
-
|
28
|
-
3. Run the build script
|
29
|
-
|
30
|
-
```
|
31
|
-
./build.sh
|
32
|
-
```
|
33
|
-
|
34
|
-
### AutoRest Configuration
|
35
|
-
|
36
|
-
This project uses [AutoRest](https://github.com/Azure/autorest), below is the configuration that the `autorest` command will automatically pick up.
|
37
|
-
|
38
|
-
> see https://aka.ms/autorest
|
39
|
-
|
40
|
-
```yaml
|
41
|
-
input-file: https://mailosaur.com/swagger/latest/swagger.json
|
42
|
-
```
|
43
|
-
|
44
|
-
```yaml
|
45
|
-
ruby:
|
46
|
-
output-folder: lib
|
47
|
-
add-credentials: true
|
48
|
-
sync-methods: essential
|
49
|
-
use-internal-constructors: true
|
50
|
-
override-client-name: MailosaurBaseClient
|
51
|
-
namespace: Mailosaur
|
52
|
-
package-name: Mailosaur
|
53
|
-
package-version: 5.0.2
|
54
|
-
```
|
55
|
-
|
56
17
|
## Running tests
|
57
18
|
|
58
19
|
Once you've cloned this repository locally, you can simply run:
|
data/lib/Mailosaur/analysis.rb
CHANGED
@@ -1,97 +1,16 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# Code generated by Microsoft (R) AutoRest Code Generator.
|
3
|
-
# Changes may cause incorrect behavior and will be lost if the code is
|
4
|
-
# regenerated.
|
5
|
-
|
6
1
|
module Mailosaur
|
7
|
-
#
|
8
|
-
# # Introduction
|
9
|
-
#
|
10
|
-
# This is an overview of the Mailosaur API. This API a RESTful JSON interface
|
11
|
-
# with predictable, resource-oriented URLs. We make use of HTTP response
|
12
|
-
# codes to indicate
|
13
|
-
# API errors.
|
14
|
-
#
|
15
|
-
# We use built-in HTTP features, like HTTP authentication and HTTP verbs,
|
16
|
-
# which are understood
|
17
|
-
# by off-the-shelf HTTP clients.
|
18
|
-
#
|
19
|
-
# [Official client libraries](/docs/client-libraries/) available for most
|
20
|
-
# popular languages.
|
21
|
-
#
|
22
|
-
# # Authentication
|
23
|
-
#
|
24
|
-
# Authenticate your account when using the API by including your API key in
|
25
|
-
# the request.
|
26
|
-
# You can [manage your API keys](/app/account/api-access/) in the Mailosaur
|
27
|
-
# UI. Your API key carrys many privileges,
|
28
|
-
# so be sure to keep it secret! Do not share your API key in
|
29
|
-
# publicly-accessible areas such
|
30
|
-
# GitHub, client-side code, and so on.
|
31
|
-
#
|
32
|
-
# All API requests must be made over HTTPS. Calls made over plain HTTP will
|
33
|
-
# fail.
|
34
|
-
# API requests without authentication will also fail.
|
35
|
-
#
|
36
|
-
# # Errors
|
37
|
-
#
|
38
|
-
# ## HTTP status codes
|
39
|
-
#
|
40
|
-
# Mailosaur uses conventional HTTP response codes to indicate the success or
|
41
|
-
# failure of an
|
42
|
-
# API request. In general, codes in the `2xx` range indicate success, codes
|
43
|
-
# in the `4xx` range
|
44
|
-
# indicate an error that failed given the information provided (e.g., a
|
45
|
-
# required parameter
|
46
|
-
# was omitted), and codes in the `5xx` range indicate an error with
|
47
|
-
# Mailosaur's servers (give us a shout in the unlikely event that you see one
|
48
|
-
# of those).
|
49
|
-
#
|
50
|
-
# | Code | Description |
|
51
|
-
# |---|---|
|
52
|
-
# | 200 - OK | Request was successful. |
|
53
|
-
# | 204 - No Content | Request was successful, no response content. |
|
54
|
-
# | 400 - Bad Request | The request could be handled, often due to missing a
|
55
|
-
# required parameter. |
|
56
|
-
# | 401 - Unauthorized | No valid API key provided. |
|
57
|
-
# | 404 - Not Found | The requested resource doesn't exist. |
|
58
|
-
# | 5XX - Server Errors | Something went wrong at Mailosaur. (Give us a
|
59
|
-
# shout). |
|
60
|
-
#
|
61
|
-
# ## Error handling
|
62
|
-
#
|
63
|
-
# In of an error the server will return as much information as possible. In
|
64
|
-
# the case of a `401` or
|
65
|
-
# `404` error the status code gives as much information as you'd need. But
|
66
|
-
# for `400` errors
|
67
|
-
# Mailosaur will return a JSON object containing the structure below.
|
68
|
-
#
|
69
|
-
# Note that our client libraries convert responses to appropriate
|
70
|
-
# language-specific objects.
|
71
|
-
#
|
72
|
-
# | Property | Description |
|
73
|
-
# |---|---|
|
74
|
-
# | `type` | The type of error returned. Can be: api_connection_error,
|
75
|
-
# api_error, authentication_error, card_error, idempotency_error
|
76
|
-
# invalid_request_error, or rate_limit_error. |
|
77
|
-
# | `message` | A human-readable message providing more details about the
|
78
|
-
# error. |
|
79
|
-
# | `parameters` | A JSON object containing a key for each property name at
|
80
|
-
# fault, with a human-readable message per field |
|
81
|
-
# | `model` | The request model that we sent and failed to be processed |
|
82
|
-
#
|
83
2
|
class Analysis
|
84
3
|
|
85
4
|
#
|
86
5
|
# Creates and initializes a new instance of the Analysis class.
|
87
|
-
# @param client
|
6
|
+
# @param conn client connection.
|
88
7
|
#
|
89
|
-
def initialize(
|
90
|
-
@
|
8
|
+
def initialize(conn)
|
9
|
+
@conn = conn
|
91
10
|
end
|
92
11
|
|
93
|
-
# @return [
|
94
|
-
attr_reader :
|
12
|
+
# @return [Connection] the client connection.
|
13
|
+
attr_reader :conn
|
95
14
|
|
96
15
|
#
|
97
16
|
# Perform a spam test
|
@@ -99,86 +18,20 @@ module Mailosaur
|
|
99
18
|
# Perform spam testing on the specified email
|
100
19
|
#
|
101
20
|
# @param email The identifier of the email to be analyzed.
|
102
|
-
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
103
|
-
# will be added to the HTTP request.
|
104
21
|
#
|
105
22
|
# @return [SpamAnalysisResult] operation results.
|
106
23
|
#
|
107
|
-
def spam(email
|
108
|
-
response =
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
#
|
115
|
-
# Perform spam testing on the specified email
|
116
|
-
#
|
117
|
-
# @param email The identifier of the email to be analyzed.
|
118
|
-
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
119
|
-
# will be added to the HTTP request.
|
120
|
-
#
|
121
|
-
# @return [MsRest::HttpOperationResponse] HTTP response information.
|
122
|
-
#
|
123
|
-
def spam_with_http_info(email, custom_headers:nil)
|
124
|
-
spam_async(email, custom_headers:custom_headers).value!
|
125
|
-
end
|
126
|
-
|
127
|
-
#
|
128
|
-
# Perform a spam test
|
129
|
-
#
|
130
|
-
# Perform spam testing on the specified email
|
131
|
-
#
|
132
|
-
# @param email The identifier of the email to be analyzed.
|
133
|
-
# @param [Hash{String => String}] A hash of custom headers that will be added
|
134
|
-
# to the HTTP request.
|
135
|
-
#
|
136
|
-
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
137
|
-
#
|
138
|
-
def spam_async(email, custom_headers:nil)
|
139
|
-
fail ArgumentError, 'email is nil' if email.nil?
|
140
|
-
|
141
|
-
|
142
|
-
request_headers = {}
|
143
|
-
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
144
|
-
path_template = 'api/analysis/spam/{email}'
|
145
|
-
|
146
|
-
request_url = @base_url || @client.base_url
|
147
|
-
|
148
|
-
options = {
|
149
|
-
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
150
|
-
path_params: {'email' => email},
|
151
|
-
headers: request_headers.merge(custom_headers || {}),
|
152
|
-
base_url: request_url
|
153
|
-
}
|
154
|
-
promise = @client.make_request_async(:get, path_template, options)
|
155
|
-
|
156
|
-
promise = promise.then do |result|
|
157
|
-
http_response = result.response
|
158
|
-
status_code = http_response.status
|
159
|
-
response_content = http_response.body
|
160
|
-
unless status_code == 200
|
161
|
-
error_model = JSON.load(response_content)
|
162
|
-
mailosaur_error = Mailosaur::MailosaurError.new('Operation returned an invalid status code \'' + status_code.to_s + '\'', error_model)
|
163
|
-
raise mailosaur_error
|
164
|
-
end
|
165
|
-
|
166
|
-
# Deserialize Response
|
167
|
-
if status_code == 200
|
168
|
-
begin
|
169
|
-
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
170
|
-
result_mapper = Mailosaur::Models::SpamAnalysisResult.mapper()
|
171
|
-
result.body = @client.deserialize(result_mapper, parsed_response)
|
172
|
-
rescue Exception => e
|
173
|
-
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
result
|
24
|
+
def spam(email)
|
25
|
+
response = conn.get 'api/analysis/spam/' + email
|
26
|
+
|
27
|
+
unless response.status == 200
|
28
|
+
error_model = JSON.load(response.body)
|
29
|
+
mailosaur_error = Mailosaur::MailosaurError.new('Operation returned an invalid status code \'' + response.status.to_s + '\'', error_model)
|
30
|
+
raise mailosaur_error
|
178
31
|
end
|
179
32
|
|
180
|
-
|
33
|
+
model = JSON.load(response.body)
|
34
|
+
Mailosaur::Models::SpamAnalysisResult.new(model)
|
181
35
|
end
|
182
|
-
|
183
36
|
end
|
184
37
|
end
|
data/lib/Mailosaur/files.rb
CHANGED
@@ -1,97 +1,16 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# Code generated by Microsoft (R) AutoRest Code Generator.
|
3
|
-
# Changes may cause incorrect behavior and will be lost if the code is
|
4
|
-
# regenerated.
|
5
|
-
|
6
1
|
module Mailosaur
|
7
|
-
#
|
8
|
-
# # Introduction
|
9
|
-
#
|
10
|
-
# This is an overview of the Mailosaur API. This API a RESTful JSON interface
|
11
|
-
# with predictable, resource-oriented URLs. We make use of HTTP response
|
12
|
-
# codes to indicate
|
13
|
-
# API errors.
|
14
|
-
#
|
15
|
-
# We use built-in HTTP features, like HTTP authentication and HTTP verbs,
|
16
|
-
# which are understood
|
17
|
-
# by off-the-shelf HTTP clients.
|
18
|
-
#
|
19
|
-
# [Official client libraries](/docs/client-libraries/) available for most
|
20
|
-
# popular languages.
|
21
|
-
#
|
22
|
-
# # Authentication
|
23
|
-
#
|
24
|
-
# Authenticate your account when using the API by including your API key in
|
25
|
-
# the request.
|
26
|
-
# You can [manage your API keys](/app/account/api-access/) in the Mailosaur
|
27
|
-
# UI. Your API key carrys many privileges,
|
28
|
-
# so be sure to keep it secret! Do not share your API key in
|
29
|
-
# publicly-accessible areas such
|
30
|
-
# GitHub, client-side code, and so on.
|
31
|
-
#
|
32
|
-
# All API requests must be made over HTTPS. Calls made over plain HTTP will
|
33
|
-
# fail.
|
34
|
-
# API requests without authentication will also fail.
|
35
|
-
#
|
36
|
-
# # Errors
|
37
|
-
#
|
38
|
-
# ## HTTP status codes
|
39
|
-
#
|
40
|
-
# Mailosaur uses conventional HTTP response codes to indicate the success or
|
41
|
-
# failure of an
|
42
|
-
# API request. In general, codes in the `2xx` range indicate success, codes
|
43
|
-
# in the `4xx` range
|
44
|
-
# indicate an error that failed given the information provided (e.g., a
|
45
|
-
# required parameter
|
46
|
-
# was omitted), and codes in the `5xx` range indicate an error with
|
47
|
-
# Mailosaur's servers (give us a shout in the unlikely event that you see one
|
48
|
-
# of those).
|
49
|
-
#
|
50
|
-
# | Code | Description |
|
51
|
-
# |---|---|
|
52
|
-
# | 200 - OK | Request was successful. |
|
53
|
-
# | 204 - No Content | Request was successful, no response content. |
|
54
|
-
# | 400 - Bad Request | The request could be handled, often due to missing a
|
55
|
-
# required parameter. |
|
56
|
-
# | 401 - Unauthorized | No valid API key provided. |
|
57
|
-
# | 404 - Not Found | The requested resource doesn't exist. |
|
58
|
-
# | 5XX - Server Errors | Something went wrong at Mailosaur. (Give us a
|
59
|
-
# shout). |
|
60
|
-
#
|
61
|
-
# ## Error handling
|
62
|
-
#
|
63
|
-
# In of an error the server will return as much information as possible. In
|
64
|
-
# the case of a `401` or
|
65
|
-
# `404` error the status code gives as much information as you'd need. But
|
66
|
-
# for `400` errors
|
67
|
-
# Mailosaur will return a JSON object containing the structure below.
|
68
|
-
#
|
69
|
-
# Note that our client libraries convert responses to appropriate
|
70
|
-
# language-specific objects.
|
71
|
-
#
|
72
|
-
# | Property | Description |
|
73
|
-
# |---|---|
|
74
|
-
# | `type` | The type of error returned. Can be: api_connection_error,
|
75
|
-
# api_error, authentication_error, card_error, idempotency_error
|
76
|
-
# invalid_request_error, or rate_limit_error. |
|
77
|
-
# | `message` | A human-readable message providing more details about the
|
78
|
-
# error. |
|
79
|
-
# | `parameters` | A JSON object containing a key for each property name at
|
80
|
-
# fault, with a human-readable message per field |
|
81
|
-
# | `model` | The request model that we sent and failed to be processed |
|
82
|
-
#
|
83
2
|
class Files
|
84
3
|
|
85
4
|
#
|
86
5
|
# Creates and initializes a new instance of the Files class.
|
87
|
-
# @param client
|
6
|
+
# @param client connection.
|
88
7
|
#
|
89
|
-
def initialize(
|
90
|
-
@
|
8
|
+
def initialize(conn)
|
9
|
+
@conn = conn
|
91
10
|
end
|
92
11
|
|
93
|
-
# @return [
|
94
|
-
attr_reader :
|
12
|
+
# @return [Connection] the client connection.
|
13
|
+
attr_reader :conn
|
95
14
|
|
96
15
|
#
|
97
16
|
# Download an attachment
|
@@ -100,94 +19,19 @@ module Mailosaur
|
|
100
19
|
# required attachment.
|
101
20
|
#
|
102
21
|
# @param id The identifier of the attachment to be downloaded.
|
103
|
-
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
104
|
-
# will be added to the HTTP request.
|
105
22
|
#
|
106
23
|
# @return [NOT_IMPLEMENTED] operation results.
|
107
24
|
#
|
108
|
-
def get_attachment(id
|
109
|
-
response =
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
#
|
116
|
-
# Downloads a single attachment. Simply supply the unique identifier for the
|
117
|
-
# required attachment.
|
118
|
-
#
|
119
|
-
# @param id The identifier of the attachment to be downloaded.
|
120
|
-
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
121
|
-
# will be added to the HTTP request.
|
122
|
-
#
|
123
|
-
# @return [MsRest::HttpOperationResponse] HTTP response information.
|
124
|
-
#
|
125
|
-
def get_attachment_with_http_info(id, custom_headers:nil)
|
126
|
-
get_attachment_async(id, custom_headers:custom_headers).value!
|
127
|
-
end
|
128
|
-
|
129
|
-
#
|
130
|
-
# Download an attachment
|
131
|
-
#
|
132
|
-
# Downloads a single attachment. Simply supply the unique identifier for the
|
133
|
-
# required attachment.
|
134
|
-
#
|
135
|
-
# @param id The identifier of the attachment to be downloaded.
|
136
|
-
# @param [Hash{String => String}] A hash of custom headers that will be added
|
137
|
-
# to the HTTP request.
|
138
|
-
#
|
139
|
-
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
140
|
-
#
|
141
|
-
def get_attachment_async(id, custom_headers:nil)
|
142
|
-
fail ArgumentError, 'id is nil' if id.nil?
|
143
|
-
|
144
|
-
|
145
|
-
request_headers = {}
|
146
|
-
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
147
|
-
path_template = 'api/files/attachments/{id}'
|
148
|
-
|
149
|
-
request_url = @base_url || @client.base_url
|
150
|
-
|
151
|
-
options = {
|
152
|
-
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
153
|
-
path_params: {'id' => id},
|
154
|
-
headers: request_headers.merge(custom_headers || {}),
|
155
|
-
base_url: request_url
|
156
|
-
}
|
157
|
-
promise = @client.make_request_async(:get, path_template, options)
|
158
|
-
|
159
|
-
promise = promise.then do |result|
|
160
|
-
http_response = result.response
|
161
|
-
status_code = http_response.status
|
162
|
-
response_content = http_response.body
|
163
|
-
unless status_code == 200
|
164
|
-
error_model = JSON.load(response_content)
|
165
|
-
mailosaur_error = Mailosaur::MailosaurError.new('Operation returned an invalid status code \'' + status_code.to_s + '\'', error_model)
|
166
|
-
raise mailosaur_error
|
167
|
-
end
|
168
|
-
|
169
|
-
# Deserialize Response
|
170
|
-
if status_code == 200
|
171
|
-
begin
|
172
|
-
parsed_response = response_content
|
173
|
-
result_mapper = {
|
174
|
-
client_side_validation: true,
|
175
|
-
required: false,
|
176
|
-
serialized_name: 'parsed_response',
|
177
|
-
type: {
|
178
|
-
name: 'Stream'
|
179
|
-
}
|
180
|
-
}
|
181
|
-
result.body = @client.deserialize(result_mapper, parsed_response)
|
182
|
-
rescue Exception => e
|
183
|
-
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
result
|
25
|
+
def get_attachment(id)
|
26
|
+
response = conn.get 'api/files/attachments/' + id
|
27
|
+
|
28
|
+
unless response.status == 200
|
29
|
+
error_model = JSON.load(response.body)
|
30
|
+
mailosaur_error = Mailosaur::MailosaurError.new('Operation returned an invalid status code \'' + response.status.to_s + '\'', error_model)
|
31
|
+
raise mailosaur_error
|
188
32
|
end
|
189
33
|
|
190
|
-
|
34
|
+
response.body
|
191
35
|
end
|
192
36
|
|
193
37
|
#
|
@@ -197,95 +41,19 @@ module Mailosaur
|
|
197
41
|
# unique identifier for the required email.
|
198
42
|
#
|
199
43
|
# @param id The identifier of the email to be downloaded.
|
200
|
-
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
201
|
-
# will be added to the HTTP request.
|
202
44
|
#
|
203
45
|
# @return [NOT_IMPLEMENTED] operation results.
|
204
46
|
#
|
205
|
-
def get_email(id
|
206
|
-
response =
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
#
|
213
|
-
# Downloads an EML file representing the specified email. Simply supply the
|
214
|
-
# unique identifier for the required email.
|
215
|
-
#
|
216
|
-
# @param id The identifier of the email to be downloaded.
|
217
|
-
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
218
|
-
# will be added to the HTTP request.
|
219
|
-
#
|
220
|
-
# @return [MsRest::HttpOperationResponse] HTTP response information.
|
221
|
-
#
|
222
|
-
def get_email_with_http_info(id, custom_headers:nil)
|
223
|
-
get_email_async(id, custom_headers:custom_headers).value!
|
224
|
-
end
|
225
|
-
|
226
|
-
#
|
227
|
-
# Download EML
|
228
|
-
#
|
229
|
-
# Downloads an EML file representing the specified email. Simply supply the
|
230
|
-
# unique identifier for the required email.
|
231
|
-
#
|
232
|
-
# @param id The identifier of the email to be downloaded.
|
233
|
-
# @param [Hash{String => String}] A hash of custom headers that will be added
|
234
|
-
# to the HTTP request.
|
235
|
-
#
|
236
|
-
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
237
|
-
#
|
238
|
-
def get_email_async(id, custom_headers:nil)
|
239
|
-
fail ArgumentError, 'id is nil' if id.nil?
|
240
|
-
|
241
|
-
|
242
|
-
request_headers = {}
|
243
|
-
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
244
|
-
path_template = 'api/files/email/{id}'
|
245
|
-
|
246
|
-
request_url = @base_url || @client.base_url
|
247
|
-
|
248
|
-
options = {
|
249
|
-
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
250
|
-
path_params: {'id' => id},
|
251
|
-
headers: request_headers.merge(custom_headers || {}),
|
252
|
-
base_url: request_url
|
253
|
-
}
|
254
|
-
promise = @client.make_request_async(:get, path_template, options)
|
255
|
-
|
256
|
-
promise = promise.then do |result|
|
257
|
-
http_response = result.response
|
258
|
-
status_code = http_response.status
|
259
|
-
response_content = http_response.body
|
260
|
-
unless status_code == 200
|
261
|
-
error_model = JSON.load(response_content)
|
262
|
-
mailosaur_error = Mailosaur::MailosaurError.new('Operation returned an invalid status code \'' + status_code.to_s + '\'', error_model)
|
263
|
-
raise mailosaur_error
|
264
|
-
end
|
265
|
-
|
266
|
-
# Deserialize Response
|
267
|
-
if status_code == 200
|
268
|
-
begin
|
269
|
-
parsed_response = response_content
|
270
|
-
result_mapper = {
|
271
|
-
client_side_validation: true,
|
272
|
-
required: false,
|
273
|
-
serialized_name: 'parsed_response',
|
274
|
-
type: {
|
275
|
-
name: 'Stream'
|
276
|
-
}
|
277
|
-
}
|
278
|
-
result.body = @client.deserialize(result_mapper, parsed_response)
|
279
|
-
rescue Exception => e
|
280
|
-
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
281
|
-
end
|
282
|
-
end
|
283
|
-
|
284
|
-
result
|
47
|
+
def get_email(id)
|
48
|
+
response = conn.get 'api/files/email/' + id
|
49
|
+
|
50
|
+
unless response.status == 200
|
51
|
+
error_model = JSON.load(response.body)
|
52
|
+
mailosaur_error = Mailosaur::MailosaurError.new('Operation returned an invalid status code \'' + response.status.to_s + '\'', error_model)
|
53
|
+
raise mailosaur_error
|
285
54
|
end
|
286
55
|
|
287
|
-
|
56
|
+
response.body
|
288
57
|
end
|
289
|
-
|
290
58
|
end
|
291
59
|
end
|