mxhero-api 1.2.3 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/VERSION +1 -1
- data/lib/communication.rb +7 -2
- data/lib/directories.rb +8 -0
- data/lib/email-sync.rb +10 -4
- data/lib/groups.rb +5 -4
- data/lib/mxhero-api.rb +4 -1
- data/lib/pst-converter.rb +4 -3
- data/mxhero-api.gemspec +5 -5
- data/test/test_directories.rb +1 -1
- data/test/test_mxhero_api.rb +5 -3
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
YWViNTg2OTAxMGRhYTcwOWI3NjMyMGZjMDE3YmQ3NWZmZGM3MDQ2OQ==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8800db8f5e087ccdd0fd7fd4c43f5474dc171dd4
|
4
|
+
data.tar.gz: 8c0b46da34e57ad57c9fa0dd2867202f83d2ebe3
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
MDc1OWZjNzY0N2RlN2Q3ZWYzZjE2NDZkYWIxZTAxYmIxZTJhODc4ZTA3OTIw
|
11
|
-
N2FkMGZlODEwMWMzOTk3YTViNGVjOGQxYWNlNTE1MjBiZGMxYTk=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NzdiNzA2YzQxNWIwZmQ2MTg1M2M3YjI4MzY1ZDgyMTBlY2E3MTFhNThkMWU0
|
14
|
-
NjY2ZDkzNTE5MzE2OTMwY2NhZjc3MWM4OTRhMTA5ZmM5MmU5ZWZiMzc5NGQ1
|
15
|
-
MWIxNjQyMjUzZTE1OTc0MWE1ZTJlYzJlMDU2YTI4N2ZiMWI5Yzg=
|
6
|
+
metadata.gz: c6834f989014a08b9f8f86e11bec96a225a84c9d2b17b7b7fcbb92128207204baf67930fdcdd6b25a53c6e228e1767fb04c40bd323bb0c19dbadf3bf5ea185c8
|
7
|
+
data.tar.gz: c5c92864a2c0d2aec795a2fc968d03825d10bc0db33674173bb720740541f16b813c8a295648b30dd7b8f07b50a18cda10cbb99d3440a07cb3b23153b3614cc0
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.2.
|
1
|
+
1.2.4
|
data/lib/communication.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'httpclient'
|
2
2
|
require 'json'
|
3
3
|
require_relative 'response'
|
4
|
+
require 'base64'
|
4
5
|
|
5
6
|
module MxHero
|
6
7
|
module API
|
@@ -15,7 +16,7 @@ module MxHero
|
|
15
16
|
# @return [HTTP::Message](http://www.rubydoc.info/gems/httpclient/HTTP/Message)
|
16
17
|
def call(method, url, body = nil, more_options = {})
|
17
18
|
unless @client
|
18
|
-
@client ||= HTTPClient.new
|
19
|
+
@client ||= HTTPClient.new(:force_basic_auth => true)
|
19
20
|
end
|
20
21
|
@client.set_auth(url, @username, @password)
|
21
22
|
response = @client.request(method, url, nil, body, headers)
|
@@ -28,7 +29,11 @@ module MxHero
|
|
28
29
|
|
29
30
|
# Default headers
|
30
31
|
def headers
|
31
|
-
|
32
|
+
{
|
33
|
+
'Accept' => 'application/json',
|
34
|
+
'Content-Type' => 'application/json',
|
35
|
+
"Authorization" => "Basic " + ::Base64.encode64(@username + ':' + @password).gsub("\n",''),
|
36
|
+
}.merge(@as_user ? { "X-MxHero-As-User" => @as_user } : {})
|
32
37
|
end
|
33
38
|
|
34
39
|
# @return [Hash]
|
data/lib/directories.rb
CHANGED
@@ -98,12 +98,20 @@ module MxHero::API
|
|
98
98
|
|
99
99
|
attr_reader :domain
|
100
100
|
|
101
|
+
# @param [String] domain
|
102
|
+
# @param [Hash] config the options of configuration
|
103
|
+
# @option config [String] :api_url The URL to consume the API
|
104
|
+
# @option config [String] :username The username for access the API
|
105
|
+
# @option config [String] :password The password for the user that access the API
|
106
|
+
# @option config [Boolean] :verbose (false) If true puts information about http operations
|
107
|
+
# @option config [String] :as_user Send to the API to indentify the end user (app user email)
|
101
108
|
def initialize(domain, config = {})
|
102
109
|
@domain = domain
|
103
110
|
@service_url = config[:api_url]
|
104
111
|
@username = config[:username]
|
105
112
|
@password = config[:password]
|
106
113
|
@verbose = config[:verbose] || false
|
114
|
+
@as_user = config[:as_user]
|
107
115
|
end
|
108
116
|
|
109
117
|
|
data/lib/email-sync.rb
CHANGED
@@ -10,13 +10,19 @@ module MxHero::API
|
|
10
10
|
include Communication
|
11
11
|
include Urls
|
12
12
|
|
13
|
-
#attr_reader :domain
|
14
13
|
|
14
|
+
# @param [Hash] config the options of configuration
|
15
|
+
# @option config [String] :api_url The URL to consume the API
|
16
|
+
# @option config [String] :username The username for access the API
|
17
|
+
# @option config [String] :password The password for the user that access the API
|
18
|
+
# @option config [Boolean] :verbose (false) If true puts information about http operations
|
19
|
+
# @option config [String] :as_user Send to the API to indentify the end user (app user email)
|
15
20
|
def initialize(config = {})
|
16
21
|
@service_url = config[:api_url]
|
17
|
-
@username
|
18
|
-
@password
|
19
|
-
@verbose
|
22
|
+
@username = config[:username]
|
23
|
+
@password = config[:password]
|
24
|
+
@verbose = config[:verbose] || false
|
25
|
+
@as_user = config[:as_user]
|
20
26
|
end
|
21
27
|
|
22
28
|
def all(domain, params = {})
|
data/lib/groups.rb
CHANGED
@@ -24,11 +24,12 @@ module MxHero::API
|
|
24
24
|
attr_reader :domain
|
25
25
|
|
26
26
|
def initialize(domain, config = {})
|
27
|
-
@domain
|
27
|
+
@domain = domain
|
28
28
|
@service_url = config[:api_url]
|
29
|
-
@username
|
30
|
-
@password
|
31
|
-
@verbose
|
29
|
+
@username = config[:username]
|
30
|
+
@password = config[:password]
|
31
|
+
@verbose = config[:verbose] || false
|
32
|
+
@as_user = config[:as_user]
|
32
33
|
end
|
33
34
|
|
34
35
|
# Retrieve all the groups
|
data/lib/mxhero-api.rb
CHANGED
@@ -30,11 +30,13 @@ module MxHero::API
|
|
30
30
|
# @option config [String] :username The username for access the API
|
31
31
|
# @option config [String] :password The password for the user that access the API
|
32
32
|
# @option config [Boolean] :verbose (false) If true puts information about http operations
|
33
|
+
# @option config [String] :as_user Send to the API to indentify the end user (app user email)
|
33
34
|
def initialize(config = {})
|
34
35
|
@service_url = config[:api_url]
|
35
36
|
@username = config[:username]
|
36
37
|
@password = config[:password]
|
37
38
|
@verbose = config[:verbose] || false
|
39
|
+
@as_user = config[:as_user]
|
38
40
|
end
|
39
41
|
|
40
42
|
# Expose directories api
|
@@ -42,7 +44,8 @@ module MxHero::API
|
|
42
44
|
# @return MxHero::API::Directories
|
43
45
|
def directories(domain)
|
44
46
|
@directories ||= Directories.new(domain, api_url: @service_url,
|
45
|
-
username: @username, password: @password,
|
47
|
+
username: @username, password: @password,
|
48
|
+
verbose: @verbose, as_user: @as_user)
|
46
49
|
end
|
47
50
|
|
48
51
|
# Find a rule by domain and ID
|
data/lib/pst-converter.rb
CHANGED
@@ -14,9 +14,10 @@ module MxHero::API
|
|
14
14
|
|
15
15
|
def initialize(config = {})
|
16
16
|
@service_url = config[:api_url]
|
17
|
-
@username
|
18
|
-
@password
|
19
|
-
@verbose
|
17
|
+
@username = config[:username]
|
18
|
+
@password = config[:password]
|
19
|
+
@verbose = config[:verbose] || false
|
20
|
+
@as_user = config[:as_user]
|
20
21
|
end
|
21
22
|
|
22
23
|
# Retrieve all tasks for {account} in status {status}
|
data/mxhero-api.gemspec
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: mxhero-api 1.2.
|
2
|
+
# stub: mxhero-api 1.2.4 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "mxhero-api"
|
6
|
-
s.version = "1.2.
|
6
|
+
s.version = "1.2.4"
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
9
|
+
s.require_paths = ["lib"]
|
9
10
|
s.authors = ["Maximiliano Dello Russo", "Juan Pablo Royo", "mxHero"]
|
10
|
-
s.date = "2017-
|
11
|
+
s.date = "2017-03-02"
|
11
12
|
s.description = "A gem to provide easy access to the API of MxHero platform (http://www.mxhero.com/)"
|
12
13
|
s.email = ["maxidr@mxhero.com", "juanpablo.royo@gmail.com", "mxhero@mxhero.com"]
|
13
14
|
s.files = [".gitignore", ".ruby-gemset", ".ruby-version", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "VERSION", "lib/communication.rb", "lib/directories.rb", "lib/dto.rb", "lib/email-sync.rb", "lib/groups.rb", "lib/mxhero-api.rb", "lib/pst-converter.rb", "lib/resource.rb", "lib/resources/account.rb", "lib/resources/domain.rb", "lib/resources/group.rb", "lib/response.rb", "lib/urls.rb", "mxhero-api.gemspec", "test/fixtures/api/account_properties.yml", "test/fixtures/api/account_properties_not_found.yml", "test/fixtures/api/accounts.yml", "test/fixtures/api/accounts_filtered.yml", "test/fixtures/api/accounts_from_domain.yml", "test/fixtures/api/accounts_from_domain_paginated.yml", "test/fixtures/api/accounts_without_group.yml", "test/fixtures/api/add_an_inexistent_account_to_group.yml", "test/fixtures/api/add_and_remove_account.yml", "test/fixtures/api/add_feature.yml", "test/fixtures/api/all_groups.yml", "test/fixtures/api/associate_user_domain.yml", "test/fixtures/api/create_directory.yml", "test/fixtures/api/create_domain.yml", "test/fixtures/api/create_rule_for_domain.yml", "test/fixtures/api/create_user.yml", "test/fixtures/api/delete_directory.yml", "test/fixtures/api/delete_group.yml", "test/fixtures/api/delete_rule.yml", "test/fixtures/api/domain_by_id.yml", "test/fixtures/api/domain_by_id_not_found.yml", "test/fixtures/api/domain_rule.yml", "test/fixtures/api/domains.yml", "test/fixtures/api/emailsync_delete.yml", "test/fixtures/api/emailsync_fetch_all.yml", "test/fixtures/api/emailsync_task_by_id.yml", "test/fixtures/api/fetch_directory.yml", "test/fixtures/api/fetch_user.yml", "test/fixtures/api/ldap_info.yml", "test/fixtures/api/move_to_trial.yml", "test/fixtures/api/pst_inactive_tasks.yml", "test/fixtures/api/refresh_directory.yml", "test/fixtures/api/remove_account_from_group_twice.yml", "test/fixtures/api/remove_inexistente_account_from_group.yml", "test/fixtures/api/rule_status.yml", "test/fixtures/api/rules_for_domain.yml", "test/fixtures/api/rules_for_domain_by_component.yml", "test/fixtures/api/save_group.yml", "test/fixtures/api/system_properties.yml", "test/fixtures/api/system_properties_create.yml", "test/fixtures/api/system_properties_element.yml", "test/fixtures/api/test_domain.yml", "test/fixtures/api/update_account_properties.yml", "test/fixtures/api/update_accounts_group_scope.yml", "test/fixtures/api/update_accounts_properties_scope.yml", "test/fixtures/api/update_directory.yml", "test/fixtures/api/update_rule.yml", "test/fixtures/api/update_user.yml", "test/fixtures/api/user_domains.yml", "test/fixtures/api/users_for_domain.yml", "test/fixtures/api/validate_user_credential.yml", "test/fixtures/domain.rb", "test/helper.rb", "test/test_directories.rb", "test/test_domain.rb", "test/test_dto.rb", "test/test_emailsync.rb", "test/test_feature.rb", "test/test_groups.rb", "test/test_mxhero_api.rb", "test/test_mxhero_api_response.rb", "test/test_pst-converter.rb", "test/test_resource.rb"]
|
14
15
|
s.homepage = "http://github.com/mxhero/mxhero-api"
|
15
16
|
s.licenses = ["GPL-3"]
|
16
|
-
s.require_paths = ["lib"]
|
17
17
|
s.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
18
|
-
s.rubygems_version = "2.1
|
18
|
+
s.rubygems_version = "2.5.1"
|
19
19
|
s.summary = "A MxHero API client for ruby"
|
20
20
|
s.test_files = ["test/fixtures/api/account_properties.yml", "test/fixtures/api/account_properties_not_found.yml", "test/fixtures/api/accounts.yml", "test/fixtures/api/accounts_filtered.yml", "test/fixtures/api/accounts_from_domain.yml", "test/fixtures/api/accounts_from_domain_paginated.yml", "test/fixtures/api/accounts_without_group.yml", "test/fixtures/api/add_an_inexistent_account_to_group.yml", "test/fixtures/api/add_and_remove_account.yml", "test/fixtures/api/add_feature.yml", "test/fixtures/api/all_groups.yml", "test/fixtures/api/associate_user_domain.yml", "test/fixtures/api/create_directory.yml", "test/fixtures/api/create_domain.yml", "test/fixtures/api/create_rule_for_domain.yml", "test/fixtures/api/create_user.yml", "test/fixtures/api/delete_directory.yml", "test/fixtures/api/delete_group.yml", "test/fixtures/api/delete_rule.yml", "test/fixtures/api/domain_by_id.yml", "test/fixtures/api/domain_by_id_not_found.yml", "test/fixtures/api/domain_rule.yml", "test/fixtures/api/domains.yml", "test/fixtures/api/emailsync_delete.yml", "test/fixtures/api/emailsync_fetch_all.yml", "test/fixtures/api/emailsync_task_by_id.yml", "test/fixtures/api/fetch_directory.yml", "test/fixtures/api/fetch_user.yml", "test/fixtures/api/ldap_info.yml", "test/fixtures/api/move_to_trial.yml", "test/fixtures/api/pst_inactive_tasks.yml", "test/fixtures/api/refresh_directory.yml", "test/fixtures/api/remove_account_from_group_twice.yml", "test/fixtures/api/remove_inexistente_account_from_group.yml", "test/fixtures/api/rule_status.yml", "test/fixtures/api/rules_for_domain.yml", "test/fixtures/api/rules_for_domain_by_component.yml", "test/fixtures/api/save_group.yml", "test/fixtures/api/system_properties.yml", "test/fixtures/api/system_properties_create.yml", "test/fixtures/api/system_properties_element.yml", "test/fixtures/api/test_domain.yml", "test/fixtures/api/update_account_properties.yml", "test/fixtures/api/update_accounts_group_scope.yml", "test/fixtures/api/update_accounts_properties_scope.yml", "test/fixtures/api/update_directory.yml", "test/fixtures/api/update_rule.yml", "test/fixtures/api/update_user.yml", "test/fixtures/api/user_domains.yml", "test/fixtures/api/users_for_domain.yml", "test/fixtures/api/validate_user_credential.yml", "test/fixtures/domain.rb", "test/helper.rb", "test/test_directories.rb", "test/test_domain.rb", "test/test_dto.rb", "test/test_emailsync.rb", "test/test_feature.rb", "test/test_groups.rb", "test/test_mxhero_api.rb", "test/test_mxhero_api_response.rb", "test/test_pst-converter.rb", "test/test_resource.rb"]
|
21
21
|
|
data/test/test_directories.rb
CHANGED
@@ -116,7 +116,7 @@ class DirectoriesTest < MiniTest::Test
|
|
116
116
|
override: true, dn_authenticate: 'dn_autheticate message'
|
117
117
|
}
|
118
118
|
directory.update_properties changes
|
119
|
-
changes.keys.each { |prop| assert_equal
|
119
|
+
changes.keys.each { |prop| assert_equal(changes[prop], directory.send(prop)) }
|
120
120
|
end
|
121
121
|
|
122
122
|
def test_initialize_properties
|
data/test/test_mxhero_api.rb
CHANGED
@@ -3,7 +3,7 @@ require_relative 'helper'
|
|
3
3
|
class MxHeroAPITest < Minitest::Test
|
4
4
|
|
5
5
|
def setup
|
6
|
-
@api = MxHero::API::Client.new(username: TEST_API_USER, password: TEST_API_PASSWORD, verbose: false, api_url: TEST_API_URL)
|
6
|
+
@api = MxHero::API::Client.new(username: TEST_API_USER, password: TEST_API_PASSWORD, verbose: false, api_url: TEST_API_URL, as_user: 'tester@mxhero.com')
|
7
7
|
end
|
8
8
|
|
9
9
|
def domain
|
@@ -18,6 +18,7 @@ class MxHeroAPITest < Minitest::Test
|
|
18
18
|
assert api.verbose?, 'Verbose state must be changed'
|
19
19
|
end
|
20
20
|
|
21
|
+
|
21
22
|
def test_update_rule
|
22
23
|
VCR.use_cassette('update_rule') do
|
23
24
|
rules = obtain_rules(domain)
|
@@ -35,6 +36,7 @@ class MxHeroAPITest < Minitest::Test
|
|
35
36
|
end
|
36
37
|
end
|
37
38
|
|
39
|
+
=begin
|
38
40
|
def test_rule_status
|
39
41
|
VCR.use_cassette('rule_status') do
|
40
42
|
mx_domain = 'mxhero.com'
|
@@ -169,7 +171,7 @@ class MxHeroAPITest < Minitest::Test
|
|
169
171
|
def test_delete_rule
|
170
172
|
VCR.use_cassette('delete_rule') do
|
171
173
|
rules = obtain_rules(domain)
|
172
|
-
one_rule = rules.first
|
174
|
+
one_rule = rules.first
|
173
175
|
response = @api.delete_rule(domain, one_rule[:id])
|
174
176
|
assert response
|
175
177
|
end
|
@@ -423,7 +425,7 @@ class MxHeroAPITest < Minitest::Test
|
|
423
425
|
refute @api.valid_user_credentials?('inexistent.user', 'xxx')
|
424
426
|
end
|
425
427
|
end
|
426
|
-
|
428
|
+
=end
|
427
429
|
private
|
428
430
|
|
429
431
|
def delete_all_rules
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mxhero-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maximiliano Dello Russo
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2017-
|
13
|
+
date: 2017-03-02 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: vcr
|
@@ -63,9 +63,9 @@ executables: []
|
|
63
63
|
extensions: []
|
64
64
|
extra_rdoc_files: []
|
65
65
|
files:
|
66
|
-
- .gitignore
|
67
|
-
- .ruby-gemset
|
68
|
-
- .ruby-version
|
66
|
+
- ".gitignore"
|
67
|
+
- ".ruby-gemset"
|
68
|
+
- ".ruby-version"
|
69
69
|
- Gemfile
|
70
70
|
- LICENSE.txt
|
71
71
|
- README.md
|
@@ -158,17 +158,17 @@ require_paths:
|
|
158
158
|
- lib
|
159
159
|
required_ruby_version: !ruby/object:Gem::Requirement
|
160
160
|
requirements:
|
161
|
-
- -
|
161
|
+
- - ">="
|
162
162
|
- !ruby/object:Gem::Version
|
163
163
|
version: 2.3.0
|
164
164
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
165
|
requirements:
|
166
|
-
- -
|
166
|
+
- - ">="
|
167
167
|
- !ruby/object:Gem::Version
|
168
168
|
version: '0'
|
169
169
|
requirements: []
|
170
170
|
rubyforge_project:
|
171
|
-
rubygems_version: 2.1
|
171
|
+
rubygems_version: 2.5.1
|
172
172
|
signing_key:
|
173
173
|
specification_version: 4
|
174
174
|
summary: A MxHero API client for ruby
|