mailosaur 3.0.1 → 5.0.1.pre
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 +14 -13
- data/README.md +42 -8
- data/lib/Mailosaur/analysis.rb +184 -0
- data/lib/Mailosaur/files.rb +291 -0
- data/lib/Mailosaur/mailosaur_base_client.rb +120 -0
- data/lib/Mailosaur/mailosaur_error.rb +23 -0
- data/lib/Mailosaur/messages.rb +673 -0
- data/lib/Mailosaur/models/attachment.rb +99 -0
- data/lib/Mailosaur/models/forwarding_rule.rb +78 -0
- data/lib/Mailosaur/models/image.rb +55 -0
- data/lib/Mailosaur/models/link.rb +55 -0
- data/lib/Mailosaur/models/message.rb +219 -0
- data/lib/Mailosaur/models/message_address.rb +66 -0
- data/lib/Mailosaur/models/message_content.rb +84 -0
- data/lib/Mailosaur/models/message_header.rb +55 -0
- data/lib/Mailosaur/models/message_list_result.rb +54 -0
- data/lib/Mailosaur/models/message_summary.rb +199 -0
- data/lib/Mailosaur/models/metadata.rb +52 -0
- data/lib/Mailosaur/models/search_criteria.rb +69 -0
- data/lib/Mailosaur/models/server.rb +118 -0
- data/lib/Mailosaur/models/server_create_options.rb +44 -0
- data/lib/Mailosaur/models/server_list_result.rb +54 -0
- data/lib/Mailosaur/models/spam_analysis_result.rb +56 -0
- data/lib/Mailosaur/models/spam_assassin_rule.rb +66 -0
- data/lib/Mailosaur/models/spam_filter_results.rb +53 -0
- data/lib/Mailosaur/module_definition.rb +6 -0
- data/lib/Mailosaur/servers.rb +542 -0
- data/lib/Mailosaur/version.rb +8 -0
- data/lib/mailosaur.rb +52 -108
- metadata +78 -46
- data/lib/helper.rb +0 -6
- data/lib/mailosaur/attachment.rb +0 -10
- data/lib/mailosaur/email.rb +0 -23
- data/lib/mailosaur/email_address.rb +0 -9
- data/lib/mailosaur/email_data.rb +0 -13
- data/lib/mailosaur/image.rb +0 -8
- data/lib/mailosaur/link.rb +0 -8
- data/lib/mailosaur/message_generator.rb +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2772f46b22f0d06dc15d344da11a920d4ef5e0a3
|
4
|
+
data.tar.gz: f15a8d95db05af6cdc6a7adc0349f6b2848a11a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06123714d9199f2cde600f72f7fe15514110df7e2d0e917976fa1e2f4f9d61970440d48eddeb9a143174d84affbfdc181f17b0fc64b1d1573d73c33be048dfff
|
7
|
+
data.tar.gz: 53983c63b008a4a0719830c49cd3817ce8216c8b4c8ef11656ae7d38dd5ce9bac729d0f7c02687239601c17f92d6496f4d1d02935b730c27e82754635c8069e5
|
data/LICENSE
CHANGED
@@ -1,20 +1,21 @@
|
|
1
|
-
|
1
|
+
MIT License
|
2
2
|
|
3
|
-
Copyright (c)
|
3
|
+
Copyright (c) 2018 Mailosaur Ltd (https://mailosaur.com)
|
4
4
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
this software and associated documentation files (the "Software"), to deal
|
7
|
-
the Software without restriction, including without limitation the rights
|
8
|
-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
the Software, and to permit persons to whom the Software is
|
10
|
-
subject to the following conditions:
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
11
|
|
12
12
|
The above copyright notice and this permission notice shall be included in all
|
13
13
|
copies or substantial portions of the Software.
|
14
14
|
|
15
15
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -14,6 +14,45 @@ 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.1
|
54
|
+
```
|
55
|
+
|
17
56
|
## Running tests
|
18
57
|
|
19
58
|
Once you've cloned this repository locally, you can simply run:
|
@@ -21,17 +60,12 @@ Once you've cloned this repository locally, you can simply run:
|
|
21
60
|
```
|
22
61
|
bundle install
|
23
62
|
|
24
|
-
export
|
25
|
-
export
|
63
|
+
export MAILOSAUR_API_KEY=your_api_key
|
64
|
+
export MAILOSAUR_SERVER=server_id
|
26
65
|
|
27
|
-
bundle exec rake
|
66
|
+
bundle exec rake test
|
28
67
|
```
|
29
68
|
|
30
69
|
## Contacting us
|
31
70
|
|
32
71
|
You can get us at [support@mailosaur.com](mailto:support@mailosaur.com)
|
33
|
-
|
34
|
-
## License
|
35
|
-
|
36
|
-
Copyright (c) 2016 Mailosaur Ltd
|
37
|
-
Distributed under MIT license.
|
@@ -0,0 +1,184 @@
|
|
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
|
+
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
|
+
class Analysis
|
84
|
+
|
85
|
+
#
|
86
|
+
# Creates and initializes a new instance of the Analysis class.
|
87
|
+
# @param client service class for accessing basic functionality.
|
88
|
+
#
|
89
|
+
def initialize(client)
|
90
|
+
@client = client
|
91
|
+
end
|
92
|
+
|
93
|
+
# @return [MailosaurBaseClient] reference to the MailosaurBaseClient
|
94
|
+
attr_reader :client
|
95
|
+
|
96
|
+
#
|
97
|
+
# Perform a spam test
|
98
|
+
#
|
99
|
+
# Perform spam testing on the specified email
|
100
|
+
#
|
101
|
+
# @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
|
+
#
|
105
|
+
# @return [SpamAnalysisResult] operation results.
|
106
|
+
#
|
107
|
+
def spam(email, custom_headers:nil)
|
108
|
+
response = spam_async(email, custom_headers:custom_headers).value!
|
109
|
+
response.body unless response.nil?
|
110
|
+
end
|
111
|
+
|
112
|
+
#
|
113
|
+
# Perform a spam test
|
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
|
178
|
+
end
|
179
|
+
|
180
|
+
promise.execute
|
181
|
+
end
|
182
|
+
|
183
|
+
end
|
184
|
+
end
|
@@ -0,0 +1,291 @@
|
|
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
|
+
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
|
+
class Files
|
84
|
+
|
85
|
+
#
|
86
|
+
# Creates and initializes a new instance of the Files class.
|
87
|
+
# @param client service class for accessing basic functionality.
|
88
|
+
#
|
89
|
+
def initialize(client)
|
90
|
+
@client = client
|
91
|
+
end
|
92
|
+
|
93
|
+
# @return [MailosaurBaseClient] reference to the MailosaurBaseClient
|
94
|
+
attr_reader :client
|
95
|
+
|
96
|
+
#
|
97
|
+
# Download an attachment
|
98
|
+
#
|
99
|
+
# Downloads a single attachment. Simply supply the unique identifier for the
|
100
|
+
# required attachment.
|
101
|
+
#
|
102
|
+
# @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
|
+
#
|
106
|
+
# @return [NOT_IMPLEMENTED] operation results.
|
107
|
+
#
|
108
|
+
def get_attachment(id, custom_headers:nil)
|
109
|
+
response = get_attachment_async(id, custom_headers:custom_headers).value!
|
110
|
+
response.body unless response.nil?
|
111
|
+
end
|
112
|
+
|
113
|
+
#
|
114
|
+
# Download an attachment
|
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
|
188
|
+
end
|
189
|
+
|
190
|
+
promise.execute
|
191
|
+
end
|
192
|
+
|
193
|
+
#
|
194
|
+
# Download EML
|
195
|
+
#
|
196
|
+
# Downloads an EML file representing the specified email. Simply supply the
|
197
|
+
# unique identifier for the required email.
|
198
|
+
#
|
199
|
+
# @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
|
+
#
|
203
|
+
# @return [NOT_IMPLEMENTED] operation results.
|
204
|
+
#
|
205
|
+
def get_email(id, custom_headers:nil)
|
206
|
+
response = get_email_async(id, custom_headers:custom_headers).value!
|
207
|
+
response.body unless response.nil?
|
208
|
+
end
|
209
|
+
|
210
|
+
#
|
211
|
+
# Download EML
|
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
|
285
|
+
end
|
286
|
+
|
287
|
+
promise.execute
|
288
|
+
end
|
289
|
+
|
290
|
+
end
|
291
|
+
end
|