mailosaur 3.0.1 → 5.0.1.pre
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -0,0 +1,120 @@
|
|
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
|
+
# A service client - single point of access to the REST API.
|
9
|
+
#
|
10
|
+
class MailosaurBaseClient < MsRest::ServiceClient
|
11
|
+
include MsRest::Serialization
|
12
|
+
|
13
|
+
# @return [String] the base URI of the service.
|
14
|
+
attr_accessor :base_url
|
15
|
+
|
16
|
+
# @return Subscription credentials which uniquely identify client
|
17
|
+
# subscription.
|
18
|
+
attr_accessor :credentials
|
19
|
+
|
20
|
+
# @return [Analysis] analysis
|
21
|
+
attr_reader :analysis
|
22
|
+
|
23
|
+
# @return [Files] files
|
24
|
+
attr_reader :files
|
25
|
+
|
26
|
+
# @return [Messages] messages
|
27
|
+
attr_reader :messages
|
28
|
+
|
29
|
+
# @return [Servers] servers
|
30
|
+
attr_reader :servers
|
31
|
+
|
32
|
+
#
|
33
|
+
# Creates initializes a new instance of the MailosaurBaseClient class.
|
34
|
+
# @param credentials [MsRest::ServiceClientCredentials] credentials to authorize HTTP requests made by the service client.
|
35
|
+
# @param base_url [String] the base URI of the service.
|
36
|
+
# @param options [Array] filters to be applied to the HTTP requests.
|
37
|
+
#
|
38
|
+
def initialize(credentials = nil, base_url = nil, options = nil)
|
39
|
+
super(credentials, options)
|
40
|
+
@base_url = base_url || 'https://mailosaur.com/'
|
41
|
+
|
42
|
+
fail ArgumentError, 'invalid type of credentials input parameter' unless credentials.is_a?(MsRest::ServiceClientCredentials) unless credentials.nil?
|
43
|
+
@credentials = credentials
|
44
|
+
|
45
|
+
@analysis = Analysis.new(self)
|
46
|
+
@files = Files.new(self)
|
47
|
+
@messages = Messages.new(self)
|
48
|
+
@servers = Servers.new(self)
|
49
|
+
add_telemetry
|
50
|
+
end
|
51
|
+
|
52
|
+
#
|
53
|
+
# Makes a request and returns the body of the response.
|
54
|
+
# @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete.
|
55
|
+
# @param path [String] the path, relative to {base_url}.
|
56
|
+
# @param options [Hash{String=>String}] specifying any request options like :body.
|
57
|
+
# @return [Hash{String=>String}] containing the body of the response.
|
58
|
+
# Example:
|
59
|
+
#
|
60
|
+
# request_content = "{'location':'westus','tags':{'tag1':'val1','tag2':'val2'}}"
|
61
|
+
# path = "/path"
|
62
|
+
# options = {
|
63
|
+
# body: request_content,
|
64
|
+
# query_params: {'api-version' => '2016-02-01'}
|
65
|
+
# }
|
66
|
+
# result = @client.make_request(:put, path, options)
|
67
|
+
#
|
68
|
+
def make_request(method, path, options = {})
|
69
|
+
result = make_request_with_http_info(method, path, options)
|
70
|
+
result.body unless result.nil?
|
71
|
+
end
|
72
|
+
|
73
|
+
#
|
74
|
+
# Makes a request and returns the operation response.
|
75
|
+
# @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete.
|
76
|
+
# @param path [String] the path, relative to {base_url}.
|
77
|
+
# @param options [Hash{String=>String}] specifying any request options like :body.
|
78
|
+
# @return [MsRest::HttpOperationResponse] Operation response containing the request, response and status.
|
79
|
+
#
|
80
|
+
def make_request_with_http_info(method, path, options = {})
|
81
|
+
result = make_request_async(method, path, options).value!
|
82
|
+
result.body = result.response.body.to_s.empty? ? nil : JSON.load(result.response.body)
|
83
|
+
result
|
84
|
+
end
|
85
|
+
|
86
|
+
#
|
87
|
+
# Makes a request asynchronously.
|
88
|
+
# @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete.
|
89
|
+
# @param path [String] the path, relative to {base_url}.
|
90
|
+
# @param options [Hash{String=>String}] specifying any request options like :body.
|
91
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
92
|
+
#
|
93
|
+
def make_request_async(method, path, options = {})
|
94
|
+
fail ArgumentError, 'method is nil' if method.nil?
|
95
|
+
fail ArgumentError, 'path is nil' if path.nil?
|
96
|
+
|
97
|
+
request_url = options[:base_url] || @base_url
|
98
|
+
if(!options[:headers].nil? && !options[:headers]['Content-Type'].nil?)
|
99
|
+
@request_headers['Content-Type'] = options[:headers]['Content-Type']
|
100
|
+
end
|
101
|
+
|
102
|
+
request_headers = @request_headers
|
103
|
+
options.merge!({headers: request_headers.merge(options[:headers] || {})})
|
104
|
+
options.merge!({credentials: @credentials}) unless @credentials.nil?
|
105
|
+
|
106
|
+
super(request_url, method, path, options)
|
107
|
+
end
|
108
|
+
|
109
|
+
|
110
|
+
private
|
111
|
+
#
|
112
|
+
# Adds telemetry information.
|
113
|
+
#
|
114
|
+
def add_telemetry
|
115
|
+
sdk_information = 'Mailosaur'
|
116
|
+
sdk_information = "#{sdk_information}/5.0.1"
|
117
|
+
add_user_agent_information(sdk_information)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Mailosaur
|
4
|
+
class MailosaurError < StandardError
|
5
|
+
attr_reader :type
|
6
|
+
attr_reader :messages
|
7
|
+
attr_reader :model
|
8
|
+
|
9
|
+
def initialize(message, error_model)
|
10
|
+
super(message)
|
11
|
+
|
12
|
+
@type = nil
|
13
|
+
@messages = nil
|
14
|
+
@model = nil
|
15
|
+
|
16
|
+
unless error_model.nil?
|
17
|
+
@type = error_model["type"]
|
18
|
+
@messages = error_model["messages"]
|
19
|
+
@model = error_model["model"]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|