mailinator_client 1.0.0 → 1.0.1
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/.gitignore +23 -0
- data/.markdownlint.json +11 -0
- data/.ruby-version +1 -0
- data/.travis.yml +7 -0
- data/Gemfile +2 -0
- data/LICENSE +21 -0
- data/README.md +101 -0
- data/Rakefile +12 -0
- data/docs/domains.md +32 -0
- data/docs/messages.md +176 -0
- data/docs/rules.md +95 -0
- data/docs/stats.md +32 -0
- data/lib/mailinator_client.rb +46 -0
- data/lib/mailinator_client/client.rb +75 -0
- data/lib/mailinator_client/domains.rb +87 -0
- data/lib/mailinator_client/error.rb +34 -0
- data/lib/mailinator_client/messages.rb +371 -0
- data/lib/mailinator_client/rules.rb +221 -0
- data/lib/mailinator_client/stats.rb +82 -0
- data/lib/mailinator_client/utils.rb +44 -0
- data/lib/mailinator_client/version.rb +25 -0
- data/mailinator_client.gemspec +25 -0
- data/test/mailinator_client_api_test.rb +132 -0
- data/test/test_helper.rb +16 -0
- metadata +30 -4
@@ -0,0 +1,221 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
#
|
3
|
+
# Copyright (c) 2020 Manybrain, Inc.
|
4
|
+
#
|
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
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
13
|
+
# copies or substantial portions of the Software.
|
14
|
+
#
|
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
|
+
# 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.
|
22
|
+
|
23
|
+
require "json"
|
24
|
+
|
25
|
+
module MailinatorClient
|
26
|
+
|
27
|
+
# Class containing all the actions for the Rules Resource
|
28
|
+
class Rules
|
29
|
+
|
30
|
+
def initialize(client)
|
31
|
+
@client = client
|
32
|
+
end
|
33
|
+
|
34
|
+
# Creates a Rule. Note that in the examples, ":domain_id" can be one of your private domains.
|
35
|
+
#
|
36
|
+
# Authentication:
|
37
|
+
# The client must be configured with a valid api
|
38
|
+
# access token to call this action.
|
39
|
+
#
|
40
|
+
# Parameters:
|
41
|
+
# * {string} domainId - The Domain name or the Domain id
|
42
|
+
# * {string} ruleToPost - The Rule object (https://manybrain.github.io/m8rdocs/#create-rule)
|
43
|
+
#
|
44
|
+
# Responses:
|
45
|
+
# * Rule (https://manybrain.github.io/m8rdocs/#create-rule)
|
46
|
+
def create_rule(params = {})
|
47
|
+
params = Utils.symbolize_hash_keys(params)
|
48
|
+
query_params = { }
|
49
|
+
headers = {}
|
50
|
+
body = nil
|
51
|
+
|
52
|
+
raise ArgumentError.new("domain id is required") unless params.has_key?(:domainId)
|
53
|
+
raise ArgumentError.new("ruleToPost is required") unless params.has_key?(:ruleToPost)
|
54
|
+
|
55
|
+
body = params[:ruleToPost] if params.has_key?(:ruleToPost)
|
56
|
+
|
57
|
+
path = "/domains/#{params[:domainId]}/rules"
|
58
|
+
|
59
|
+
@client.request(
|
60
|
+
method: :post,
|
61
|
+
path: path,
|
62
|
+
query: query_params,
|
63
|
+
headers: headers,
|
64
|
+
body: body)
|
65
|
+
end
|
66
|
+
|
67
|
+
# Enables an existing Rule
|
68
|
+
#
|
69
|
+
# Authentication:
|
70
|
+
# The client must be configured with a valid api
|
71
|
+
# access token to call this action.
|
72
|
+
#
|
73
|
+
# Parameters:
|
74
|
+
# * {string} domainId - The Domain name or the Domain id
|
75
|
+
# * {string} ruleId - The Rule id
|
76
|
+
#
|
77
|
+
# Responses:
|
78
|
+
# * Status (https://manybrain.github.io/m8rdocs/#enable-rule)
|
79
|
+
def enable_rule(params = {})
|
80
|
+
params = Utils.symbolize_hash_keys(params)
|
81
|
+
query_params = { }
|
82
|
+
headers = {}
|
83
|
+
body = nil
|
84
|
+
|
85
|
+
raise ArgumentError.new("domain id is required") unless params.has_key?(:domainId)
|
86
|
+
raise ArgumentError.new("rule id is required") unless params.has_key?(:ruleId)
|
87
|
+
|
88
|
+
path = "/domains/#{params[:domainId]}/rules/#{params[:ruleId]}/enable"
|
89
|
+
|
90
|
+
@client.request(
|
91
|
+
method: :put,
|
92
|
+
path: path,
|
93
|
+
query: query_params,
|
94
|
+
headers: headers,
|
95
|
+
body: body)
|
96
|
+
end
|
97
|
+
|
98
|
+
# Disables an existing Rule
|
99
|
+
#
|
100
|
+
# Authentication:
|
101
|
+
# The client must be configured with a valid api
|
102
|
+
# access token to call this action.
|
103
|
+
#
|
104
|
+
# Parameters:
|
105
|
+
# * {string} domainId - The Domain name or the Domain id
|
106
|
+
# * {string} ruleId - The Rule id
|
107
|
+
#
|
108
|
+
# Responses:
|
109
|
+
# * Status (https://manybrain.github.io/m8rdocs/#disable-rule)
|
110
|
+
def disable_rule(params = {})
|
111
|
+
params = Utils.symbolize_hash_keys(params)
|
112
|
+
query_params = { }
|
113
|
+
headers = {}
|
114
|
+
body = nil
|
115
|
+
|
116
|
+
raise ArgumentError.new("domain id is required") unless params.has_key?(:domainId)
|
117
|
+
raise ArgumentError.new("rule id is required") unless params.has_key?(:ruleId)
|
118
|
+
|
119
|
+
path = "/domains/#{params[:domainId]}/rules/#{params[:ruleId]}/disable"
|
120
|
+
|
121
|
+
@client.request(
|
122
|
+
method: :put,
|
123
|
+
path: path,
|
124
|
+
query: query_params,
|
125
|
+
headers: headers,
|
126
|
+
body: body)
|
127
|
+
end
|
128
|
+
|
129
|
+
# Fetches all Rules for a Domain.
|
130
|
+
#
|
131
|
+
# Authentication:
|
132
|
+
# The client must be configured with a valid api
|
133
|
+
# access token to call this action.
|
134
|
+
#
|
135
|
+
# Parameters:
|
136
|
+
# * {string} domainId - The Domain name or the Domain id
|
137
|
+
#
|
138
|
+
# Responses:
|
139
|
+
# * Collection of rules (https://manybrain.github.io/m8rdocs/#get-all-rules)
|
140
|
+
def get_all_rules(params = {})
|
141
|
+
params = Utils.symbolize_hash_keys(params)
|
142
|
+
query_params = { }
|
143
|
+
headers = {}
|
144
|
+
body = nil
|
145
|
+
|
146
|
+
raise ArgumentError.new("domain id is required") unless params.has_key?(:domainId)
|
147
|
+
|
148
|
+
path = "/domains/#{params[:domainId]}/rules"
|
149
|
+
|
150
|
+
@client.request(
|
151
|
+
method: :get,
|
152
|
+
path: path,
|
153
|
+
query: query_params,
|
154
|
+
headers: headers,
|
155
|
+
body: body)
|
156
|
+
end
|
157
|
+
|
158
|
+
# Fetches a specific rule for a Domain.
|
159
|
+
#
|
160
|
+
# Authentication:
|
161
|
+
# The client must be configured with a valid api
|
162
|
+
# access token to call this action.
|
163
|
+
#
|
164
|
+
# Parameters:
|
165
|
+
# * {string} domainId - The Domain name or the Domain id
|
166
|
+
# * {string} ruleId - The Domain name or the Rule id
|
167
|
+
#
|
168
|
+
# Responses:
|
169
|
+
# * Rule (https://manybrain.github.io/m8rdocs/#get-rule)
|
170
|
+
def get_rule(params = {})
|
171
|
+
params = Utils.symbolize_hash_keys(params)
|
172
|
+
query_params = { }
|
173
|
+
headers = {}
|
174
|
+
body = nil
|
175
|
+
|
176
|
+
raise ArgumentError.new("domain id is required") unless params.has_key?(:domainId)
|
177
|
+
raise ArgumentError.new("rule id is required") unless params.has_key?(:ruleId)
|
178
|
+
|
179
|
+
path = "/domains/#{params[:domainId]}/rules/#{params[:ruleId]}"
|
180
|
+
|
181
|
+
@client.request(
|
182
|
+
method: :get,
|
183
|
+
path: path,
|
184
|
+
query: query_params,
|
185
|
+
headers: headers,
|
186
|
+
body: body)
|
187
|
+
end
|
188
|
+
|
189
|
+
# Deletes a specific rule for a Domain.
|
190
|
+
#
|
191
|
+
# Authentication:
|
192
|
+
# The client must be configured with a valid api
|
193
|
+
# access token to call this action.
|
194
|
+
#
|
195
|
+
# Parameters:
|
196
|
+
# * {string} domainId - The Domain name or the Domain id
|
197
|
+
# * {string} ruleId - The Rule id
|
198
|
+
#
|
199
|
+
# Responses:
|
200
|
+
# * Status (https://manybrain.github.io/m8rdocs/#delete-rule)
|
201
|
+
def delete_rule(params = {})
|
202
|
+
params = Utils.symbolize_hash_keys(params)
|
203
|
+
query_params = { }
|
204
|
+
headers = {}
|
205
|
+
body = nil
|
206
|
+
|
207
|
+
raise ArgumentError.new("domain id is required") unless params.has_key?(:domainId)
|
208
|
+
raise ArgumentError.new("rule id is required") unless params.has_key?(:ruleId)
|
209
|
+
|
210
|
+
path = "/domains/#{params[:domainId]}/rules/#{params[:ruleId]}"
|
211
|
+
|
212
|
+
@client.request(
|
213
|
+
method: :delete,
|
214
|
+
path: path,
|
215
|
+
query: query_params,
|
216
|
+
headers: headers,
|
217
|
+
body: body)
|
218
|
+
end
|
219
|
+
|
220
|
+
end
|
221
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
#
|
3
|
+
# Copyright (c) 2020 Manybrain, Inc.
|
4
|
+
#
|
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
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
13
|
+
# copies or substantial portions of the Software.
|
14
|
+
#
|
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
|
+
# 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.
|
22
|
+
|
23
|
+
require "json"
|
24
|
+
|
25
|
+
module MailinatorClient
|
26
|
+
|
27
|
+
# Class containing all the actions for the Stats Resource
|
28
|
+
class Stats
|
29
|
+
|
30
|
+
def initialize(client)
|
31
|
+
@client = client
|
32
|
+
end
|
33
|
+
|
34
|
+
# Retrieves stats of team
|
35
|
+
#
|
36
|
+
# Authentication:
|
37
|
+
# The client must be configured with a valid api
|
38
|
+
# access token to call this action.
|
39
|
+
#
|
40
|
+
# Responses:
|
41
|
+
# * Collection of team stats (https://manybrain.github.io/m8rdocs/#get-all-domains)
|
42
|
+
def get_team_stats()
|
43
|
+
query_params = { }
|
44
|
+
headers = {}
|
45
|
+
body = nil
|
46
|
+
|
47
|
+
path = "/team/stats"
|
48
|
+
|
49
|
+
@client.request(
|
50
|
+
method: :get,
|
51
|
+
path: path,
|
52
|
+
query: query_params,
|
53
|
+
headers: headers,
|
54
|
+
body: body)
|
55
|
+
end
|
56
|
+
|
57
|
+
# Retrieves team info
|
58
|
+
#
|
59
|
+
# Authentication:
|
60
|
+
# The client must be configured with a valid api
|
61
|
+
# access token to call this action.
|
62
|
+
#
|
63
|
+
# Responses:
|
64
|
+
# * Team info (https://manybrain.github.io/m8rdocs/#stats-api)
|
65
|
+
def get_team(params = {})
|
66
|
+
params = Utils.symbolize_hash_keys(params)
|
67
|
+
query_params = { }
|
68
|
+
headers = {}
|
69
|
+
body = nil
|
70
|
+
|
71
|
+
path = "/team"
|
72
|
+
|
73
|
+
@client.request(
|
74
|
+
method: :get,
|
75
|
+
path: path,
|
76
|
+
query: query_params,
|
77
|
+
headers: headers,
|
78
|
+
body: body)
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
#
|
3
|
+
# Copyright (c) 2020 Manybrain, Inc.
|
4
|
+
#
|
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
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
13
|
+
# copies or substantial portions of the Software.
|
14
|
+
#
|
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
|
+
# 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.
|
22
|
+
|
23
|
+
module MailinatorClient
|
24
|
+
class Utils
|
25
|
+
def self.symbolize_hash_keys(hash)
|
26
|
+
Hash[hash.dup.map { |k, v| [k.to_sym, v] }]
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.fix_query_arrays(value)
|
30
|
+
if value.respond_to?(:to_ary)
|
31
|
+
value = value.to_ary.map.with_index.to_a.to_h.invert
|
32
|
+
end
|
33
|
+
|
34
|
+
if value.respond_to?(:to_hash)
|
35
|
+
value = value.to_hash
|
36
|
+
value.each do |k, v|
|
37
|
+
value[k] = fix_query_arrays(v)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
value
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
#
|
3
|
+
# Copyright (c) 2020 Manybrain, Inc.
|
4
|
+
#
|
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
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
13
|
+
# copies or substantial portions of the Software.
|
14
|
+
#
|
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
|
+
# 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.
|
22
|
+
|
23
|
+
module MailinatorClient
|
24
|
+
VERSION = "1.0.1"
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
$LOAD_PATH.push(File.expand_path("../lib", __FILE__))
|
2
|
+
require "mailinator_client/version"
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.name = "mailinator_client"
|
6
|
+
gem.authors = ["Marian Melnychuk"]
|
7
|
+
gem.email = ["marian.melnychuk@gmail.com"]
|
8
|
+
gem.summary = %q{Provides a simple ruby wrapper around the Mailinator REST API}
|
9
|
+
gem.description = %q{Easily use the Mailinator through its REST API with Ruby}
|
10
|
+
gem.homepage = "https://github.com/manybrain/mailinator-ruby-client"
|
11
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
|
+
gem.files = `git ls-files`.split("\n")
|
13
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
|
+
gem.require_paths = ["lib"]
|
15
|
+
gem.version = MailinatorClient::VERSION
|
16
|
+
gem.licenses = ["MIT"]
|
17
|
+
|
18
|
+
gem.required_ruby_version = ">= 2.1"
|
19
|
+
|
20
|
+
gem.add_dependency "httparty", "~> 0.14.0"
|
21
|
+
|
22
|
+
gem.add_development_dependency "minitest", "~> 5.9"
|
23
|
+
gem.add_development_dependency "rake", "~> 12"
|
24
|
+
gem.add_development_dependency "webmock", "~> 2.3"
|
25
|
+
end
|
@@ -0,0 +1,132 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/test_helper")
|
2
|
+
|
3
|
+
class MailinatorClientApiTest < MiniTest::Test
|
4
|
+
|
5
|
+
describe "test api functionality" do
|
6
|
+
before do
|
7
|
+
@auth_token = "MAILINATOR_TEST_API_TOKEN"
|
8
|
+
@inboxAll = "*"
|
9
|
+
@inbox = "MAILINATOR_TEST_INBOX"
|
10
|
+
@teamSMSNumber = "MAILINATOR_TEST_PHONE_NUMBER"
|
11
|
+
@messageIdWithAttachment = "MAILINATOR_TEST_MESSAGE_WITH_ATTACHMENT_ID"
|
12
|
+
@attachmentId = "MAILINATOR_TEST_ATTACHMENT_ID"
|
13
|
+
@deleteDomain = "MAILINATOR_TEST_DELETE_DOMAIN"
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should correctly do manipulation with mailinator data" do
|
17
|
+
|
18
|
+
client = MailinatorClient::Client.new(auth_token: @auth_token)
|
19
|
+
|
20
|
+
response = client.domains.get_domains
|
21
|
+
assert response != nil, "Expected get domains response to not be nil"
|
22
|
+
assert response["domains"] != nil, "Expected response domains to not be nil"
|
23
|
+
@domain = response["domains"][0]
|
24
|
+
@domainId = @domain["_id"]
|
25
|
+
@domainName = @domain["name"]
|
26
|
+
|
27
|
+
response = client.domains.get_domain(domainId:@domainId)
|
28
|
+
assert response != nil, "Expected get domain response to not be nil"
|
29
|
+
|
30
|
+
ruleToPost = {
|
31
|
+
name: "RuleName",
|
32
|
+
priority: 15,
|
33
|
+
description: "Description",
|
34
|
+
conditions: [
|
35
|
+
{
|
36
|
+
operation: "PREFIX",
|
37
|
+
condition_data: {
|
38
|
+
field: "to",
|
39
|
+
value: "raul"
|
40
|
+
}
|
41
|
+
}
|
42
|
+
],
|
43
|
+
enabled: true,
|
44
|
+
match: "ANY",
|
45
|
+
actions: [
|
46
|
+
{
|
47
|
+
action: "WEBHOOK",
|
48
|
+
action_data: {
|
49
|
+
url: "https://www.google.com"
|
50
|
+
}
|
51
|
+
}
|
52
|
+
]
|
53
|
+
}
|
54
|
+
|
55
|
+
response = client.rules.create_rule(domainId:@domainId, ruleToPost: ruleToPost)
|
56
|
+
assert response != nil, "Expected get create rule response to not be nil"
|
57
|
+
assert response["_id"] != nil, "Expected response rule id to not be nil"
|
58
|
+
|
59
|
+
response = client.rules.get_all_rules(domainId:@domainId)
|
60
|
+
assert response != nil, "Expected get all rules response to not be nil"
|
61
|
+
assert response["rules"] != nil, "Expected response rules to not be nil"
|
62
|
+
@rule = response["rules"][0]
|
63
|
+
@ruleId = @rule["_id"]
|
64
|
+
|
65
|
+
response = client.rules.enable_rule(domainId:@domainId, ruleId: @ruleId)
|
66
|
+
assert response != nil, "Expected enable rule response to not be nil"
|
67
|
+
assert response["status"] == "ok", "Expected enable rule response to be ok"
|
68
|
+
|
69
|
+
response = client.rules.disable_rule(domainId:@domainId, ruleId: @ruleId)
|
70
|
+
assert response != nil, "Expected disable rule response to not be nil"
|
71
|
+
assert response["status"] == "ok", "Expected disable rule response to be ok"
|
72
|
+
|
73
|
+
response = client.rules.get_rule(domainId:@domainId, ruleId: @ruleId)
|
74
|
+
assert response != nil, "Expected disable rule response to not be nil"
|
75
|
+
assert response["_id"] != nil, "Expected get rule response to not be nil"
|
76
|
+
|
77
|
+
response = client.rules.delete_rule(domainId:@deleteDomain, ruleId: @ruleId)
|
78
|
+
assert response != nil, "Expected delete rule response to not be nil"
|
79
|
+
assert response["status"] == "ok", "Expected delete rule response to be ok"
|
80
|
+
|
81
|
+
response = client.messages.fetch_inbox(domain:@domainName, inbox: @inboxAll, skip: 0, limit: 50, sort: "ascending", decodeSubject: false)
|
82
|
+
assert response != nil, "Expected fetch inbox response to not be nil"
|
83
|
+
assert response["msgs"] != nil, "Expected response fetch inbox messages to not be nil"
|
84
|
+
@message = response["msgs"][0]
|
85
|
+
@messageId = @message["id"]
|
86
|
+
|
87
|
+
response = client.messages.fetch_message(domain:@domainName, inbox: @inboxAll, messageId: @messageId)
|
88
|
+
assert response != nil, "Expected fetch message response to not be nil"
|
89
|
+
|
90
|
+
response = client.messages.fetch_sms_message(domain:@domainName, inbox: @inboxAll, teamSmsNumber: @teamSMSNumber)
|
91
|
+
assert response != nil, "Expected fetch sms message response to not be nil"
|
92
|
+
|
93
|
+
response = client.messages.fetch_attachments(domain:@domainName, inbox: @inbox, messageId: @messageIdWithAttachment)
|
94
|
+
assert response != nil, "Expected fetch attachments response to not be nil"
|
95
|
+
|
96
|
+
response = client.messages.fetch_attachment(domain:@domainName, inbox: @inbox, messageId: @messageIdWithAttachment, attachmentId: @attachmentId)
|
97
|
+
assert response != nil, "Expected fetch attachment response to not be nil"
|
98
|
+
|
99
|
+
response = client.messages.fetch_message_links(domain:@domainName, inbox: @inboxAll, messageId: @messageId)
|
100
|
+
assert response != nil, "Expected fetch message links response to not be nil"
|
101
|
+
assert response["links"] != nil, "Expected fetch message links links response to not be nil"
|
102
|
+
|
103
|
+
response = client.messages.delete_message(domain:@deleteDomain, inbox: @inbox, messageId: @messageId)
|
104
|
+
assert response != nil, "Expected delete message response to not be nil"
|
105
|
+
assert response["status"] == "ok", "Expected delete message response to be ok"
|
106
|
+
|
107
|
+
response = client.messages.delete_all_inbox_messages(domain:@deleteDomain, inbox: @inbox)
|
108
|
+
assert response != nil, "Expected delete all inbox messages response to not be nil"
|
109
|
+
assert response["status"] == "ok", "Expected delete all inbox messages response to be ok"
|
110
|
+
|
111
|
+
response = client.messages.delete_all_domain_messages(domain:@deleteDomain)
|
112
|
+
assert response != nil, "Expected delete all domain messages response to not be nil"
|
113
|
+
assert response["status"] == "ok", "Expected delete all domain messages response to be ok"
|
114
|
+
|
115
|
+
messageToPost = {
|
116
|
+
subject:"Testing ruby message",
|
117
|
+
from:"test_email_ruby@test.com",
|
118
|
+
text:"I love Ruby!"
|
119
|
+
}
|
120
|
+
response = client.messages.inject_message(domain:@domainName, inbox: @inboxAll, messageToPost: messageToPost)
|
121
|
+
assert response != nil, "Expected inject message response to not be nil"
|
122
|
+
assert response["status"] == "ok", "Expected inject message response to be ok"
|
123
|
+
|
124
|
+
response = client.stats.get_team_stats
|
125
|
+
assert response != nil, "Expected response to not be nil"
|
126
|
+
assert response["stats"] != nil, "Expected response stats to not be nil"
|
127
|
+
|
128
|
+
response = client.stats.get_team
|
129
|
+
assert response != nil, "Expected response to not be nil"
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|