mxhero-api 0.1.26 → 0.1.27

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- M2NiMTVjOWRlNTVkMDE0MjcwZDEzYjQ4OTg4NmJkZWIxN2Y5N2ViMA==
4
+ OGMwODUzYjE4OTAzNzhkZjVlYmQ3ZDA1YTM1MWI3NDIyYWZmZDU3Mw==
5
5
  data.tar.gz: !binary |-
6
- ZWE1MzVkZjZkZDk1ZjlhOTYwYTU2YmM5YTI1YzRlYjI4ZjAyNWJkNw==
6
+ ZWIxNjFhNmI2M2UyYzhkYTZhYjJlNzk3MDY2YWQxNGUyMzEwZDEwMg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NDQzMDVlMDA0NWMwODA1MDViZGUzMGM0YWM1NzkwZjk3Zjc0ZjAyMjdlNjQz
10
- ZWU0NDY0MWQ0YzVjY2RlNzcwZjk3OWU2NzI3ZjBlOWJkNTEwOWZhODlhMDhl
11
- Y2IyY2QwNGIxYjEwY2YzYjgxZDc4NzMzMjAyNzBhMjRiZTZjMzg=
9
+ N2FkMjM4MGE1ZjI0Y2QxZThkMTA5MDBjZmVhYjQ1Y2EzYWJkYjY2ZmM5OTBm
10
+ ODcwNTg0MGI1YmJhMTIzZThhMzRmMmUzYjIxMzk4NDRjNjVhNTZmNzAyYmUz
11
+ MjkwYWM1NDExMTZlMzE4OGExMWU1YmFmNWJmMTIyMGMwMGYxOWI=
12
12
  data.tar.gz: !binary |-
13
- ZTBmYmI5NTgwMzk1MjVlZjg3ZmU5NzhkZTdlZDUzY2JjOGU4YjA3OTk2M2Nl
14
- MmMxN2JkMDkyYjk5YzI4NzY3YzBkYzBiMzhmNmM2NmMwMDEyNmM1NjlhYThm
15
- MGJmNjlkYzkwMjY5MTUxZTZlYTg1NTEwMmZjNjQzNGIzOTUyMTM=
13
+ NjVkZDhkMjBhNjM4ODQzYjU1MGU1ZmZiZDhjM2Q3MTA0ZWNmMmVlMGVhZWMw
14
+ Yjk1OWNiY2Y2YTcxODQxMWY1OTMyNmUzYzYyZTA3M2M2Y2YyOTRmMTRjNjVm
15
+ YmY3YmFiYTllOThiYjNlN2YzNjBkNWJiZGI4YTczOWQyMDkzZjU=
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.26
1
+ 0.1.27
@@ -366,10 +366,26 @@ module MxHero::API
366
366
  parse_response(response).success?
367
367
  end
368
368
 
369
+ # Obtain the list of domains to one user
370
+ # @return [Array<String>|nil] when the user exist but don't have domains the list is empty.
371
+ # If the user isn't exist then return nil
372
+ def user_domains(user)
373
+ domains = nil
374
+ response = call(:get, user_domains_url(user))
375
+ if response.status == 200
376
+ content = json_parse(response.content)
377
+ domains = content.map { |info| info[:domain] }
378
+ end
379
+ domains
380
+ end
369
381
 
370
382
  # --------------------------------------------------------------------------------------------------------------------------------
371
383
  private
372
-
384
+
385
+ def user_domains_url(user)
386
+ service_url + "/users/#{user}/domains"
387
+ end
388
+
373
389
  # Fetch an element from an URL. That element maybe not found
374
390
  # @return a Hash when the element exist. Or return nil when not found.
375
391
  #
@@ -1,22 +1,22 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: mxhero-api 0.1.26 ruby lib
2
+ # stub: mxhero-api 0.1.27 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "mxhero-api"
6
- s.version = "0.1.26"
6
+ s.version = "0.1.27"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
9
9
  s.authors = ["Maximiliano Dello Russo", "Juan Pablo Royo", "mxHero"]
10
- s.date = "2014-01-09"
10
+ s.date = "2014-01-13"
11
11
  s.description = "A gem to provide easy access to the API of MxHero platform (http://www.mxhero.com/)"
12
12
  s.email = ["maxidr@mxhero.com", "juanpablo.royo@gmail.com", "mxhero@mxhero.com"]
13
- s.files = [".gitignore", ".rvmrc", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "VERSION", "lib/communication.rb", "lib/directories.rb", "lib/dto.rb", "lib/groups.rb", "lib/mxhero-api.rb", "lib/resource.rb", "lib/resources/account.rb", "lib/resources/domain.rb", "lib/resources/group.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/all_groups.yml", "test/fixtures/api/create_directory.yml", "test/fixtures/api/create_rule_for_domain.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/fetch_directory.yml", "test/fixtures/api/ldap_info.yml", "test/fixtures/api/move_to_trial.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/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/domain.rb", "test/helper.rb", "test/test_directories.rb", "test/test_domain.rb", "test/test_dto.rb", "test/test_feature.rb", "test/test_groups.rb", "test/test_mxhero_api.rb", "test/test_mxhero_api_response.rb", "test/test_resource.rb"]
13
+ s.files = [".gitignore", ".rvmrc", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "VERSION", "lib/communication.rb", "lib/directories.rb", "lib/dto.rb", "lib/groups.rb", "lib/mxhero-api.rb", "lib/resource.rb", "lib/resources/account.rb", "lib/resources/domain.rb", "lib/resources/group.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/all_groups.yml", "test/fixtures/api/create_directory.yml", "test/fixtures/api/create_rule_for_domain.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/fetch_directory.yml", "test/fixtures/api/ldap_info.yml", "test/fixtures/api/move_to_trial.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/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/user_domains.yml", "test/fixtures/domain.rb", "test/helper.rb", "test/test_directories.rb", "test/test_domain.rb", "test/test_dto.rb", "test/test_feature.rb", "test/test_groups.rb", "test/test_mxhero_api.rb", "test/test_mxhero_api_response.rb", "test/test_resource.rb"]
14
14
  s.homepage = "http://github.com/mxhero/mxhero-api"
15
15
  s.licenses = ["GPL-3"]
16
16
  s.require_paths = ["lib"]
17
17
  s.rubygems_version = "2.1.9"
18
18
  s.summary = "A MxHero API client for ruby"
19
- 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/all_groups.yml", "test/fixtures/api/create_directory.yml", "test/fixtures/api/create_rule_for_domain.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/fetch_directory.yml", "test/fixtures/api/ldap_info.yml", "test/fixtures/api/move_to_trial.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/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/domain.rb", "test/helper.rb", "test/test_directories.rb", "test/test_domain.rb", "test/test_dto.rb", "test/test_feature.rb", "test/test_groups.rb", "test/test_mxhero_api.rb", "test/test_mxhero_api_response.rb", "test/test_resource.rb"]
19
+ 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/all_groups.yml", "test/fixtures/api/create_directory.yml", "test/fixtures/api/create_rule_for_domain.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/fetch_directory.yml", "test/fixtures/api/ldap_info.yml", "test/fixtures/api/move_to_trial.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/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/user_domains.yml", "test/fixtures/domain.rb", "test/helper.rb", "test/test_directories.rb", "test/test_domain.rb", "test/test_dto.rb", "test/test_feature.rb", "test/test_groups.rb", "test/test_mxhero_api.rb", "test/test_mxhero_api_response.rb", "test/test_resource.rb"]
20
20
 
21
21
  if s.respond_to? :specification_version then
22
22
  s.specification_version = 4
@@ -0,0 +1,111 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://admin:password@test.mxhero.com/webapi/api/v1/users/mxhero@mxhero.com/domains
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ Content-Type:
13
+ - application/json
14
+ Authorization:
15
+ - Basic YWRtaW46cGFzc3dvcmQ=
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: !binary |-
20
+ T0s=
21
+ headers:
22
+ !binary "RGF0ZQ==":
23
+ - !binary |-
24
+ RnJpLCAxMCBKYW4gMjAxNCAyMTozODoxMCBHTVQ=
25
+ !binary "U2VydmVy":
26
+ - !binary |-
27
+ QXBhY2hlLzIuMi4xNCAoVWJ1bnR1KQ==
28
+ !binary "VHJhbnNmZXItRW5jb2Rpbmc=":
29
+ - !binary |-
30
+ Y2h1bmtlZA==
31
+ !binary "Q29udGVudC1UeXBl":
32
+ - !binary |-
33
+ YXBwbGljYXRpb24vanNvbg==
34
+ body:
35
+ encoding: US-ASCII
36
+ string: ! '[{"domain":"mxhero.com","created":1389384042000,"updated":1389384042000,"metadata":null},{"domain":"stage.mxhero.com","created":1389384084000,"updated":1389384084000,"metadata":null}]'
37
+ http_version:
38
+ recorded_at: Fri, 10 Jan 2014 21:38:10 GMT
39
+ - request:
40
+ method: get
41
+ uri: http://admin:password@test.mxhero.com/webapi/api/v1/users/admin/domains
42
+ body:
43
+ encoding: US-ASCII
44
+ string: ''
45
+ headers:
46
+ Accept:
47
+ - application/json
48
+ Content-Type:
49
+ - application/json
50
+ Authorization:
51
+ - Basic YWRtaW46cGFzc3dvcmQ=
52
+ response:
53
+ status:
54
+ code: 200
55
+ message: !binary |-
56
+ T0s=
57
+ headers:
58
+ !binary "RGF0ZQ==":
59
+ - !binary |-
60
+ RnJpLCAxMCBKYW4gMjAxNCAyMTozODoxMCBHTVQ=
61
+ !binary "U2VydmVy":
62
+ - !binary |-
63
+ QXBhY2hlLzIuMi4xNCAoVWJ1bnR1KQ==
64
+ !binary "VHJhbnNmZXItRW5jb2Rpbmc=":
65
+ - !binary |-
66
+ Y2h1bmtlZA==
67
+ !binary "Q29udGVudC1UeXBl":
68
+ - !binary |-
69
+ YXBwbGljYXRpb24vanNvbg==
70
+ body:
71
+ encoding: US-ASCII
72
+ string: ! '[]'
73
+ http_version:
74
+ recorded_at: Fri, 10 Jan 2014 21:38:10 GMT
75
+ - request:
76
+ method: get
77
+ uri: http://admin:password@test.mxhero.com/webapi/api/v1/users/not_existent_account/domains
78
+ body:
79
+ encoding: US-ASCII
80
+ string: ''
81
+ headers:
82
+ Accept:
83
+ - application/json
84
+ Content-Type:
85
+ - application/json
86
+ Authorization:
87
+ - Basic YWRtaW46cGFzc3dvcmQ=
88
+ response:
89
+ status:
90
+ code: 404
91
+ message: !binary |-
92
+ Tm90IEZvdW5k
93
+ headers:
94
+ !binary "RGF0ZQ==":
95
+ - !binary |-
96
+ RnJpLCAxMCBKYW4gMjAxNCAyMTozODoxNiBHTVQ=
97
+ !binary "U2VydmVy":
98
+ - !binary |-
99
+ QXBhY2hlLzIuMi4xNCAoVWJ1bnR1KQ==
100
+ !binary "VHJhbnNmZXItRW5jb2Rpbmc=":
101
+ - !binary |-
102
+ Y2h1bmtlZA==
103
+ !binary "Q29udGVudC1UeXBl":
104
+ - !binary |-
105
+ YXBwbGljYXRpb24vanNvbg==
106
+ body:
107
+ encoding: US-ASCII
108
+ string: ! '{"status":404,"code":404,"message":"user.not.found","developerMessage":"user.not.found","moreInfoUrl":"mailto:support@mxhero.com"}'
109
+ http_version:
110
+ recorded_at: Fri, 10 Jan 2014 21:38:15 GMT
111
+ recorded_with: VCR 2.5.0
@@ -303,6 +303,18 @@ class MxHeroAPITest < MiniTest::Unit::TestCase
303
303
  end
304
304
  end
305
305
 
306
+ def test_user_domains
307
+ VCR.use_cassette('user_domains') do
308
+ domains = @api.user_domains('mxhero@mxhero.com')
309
+ assert domains.all? { |domain| ['mxhero.com', 'stage.mxhero.com'].include?(domain) }
310
+
311
+ domains = @api.user_domains('admin')
312
+ assert domains.empty?
313
+
314
+ domains = @api.user_domains('not_existent_account')
315
+ assert domains.nil?
316
+ end
317
+ end
306
318
 
307
319
  private
308
320
 
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: 0.1.26
4
+ version: 0.1.27
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: 2014-01-09 00:00:00.000000000 Z
13
+ date: 2014-01-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: vcr
@@ -118,6 +118,7 @@ files:
118
118
  - test/fixtures/api/update_accounts_properties_scope.yml
119
119
  - test/fixtures/api/update_directory.yml
120
120
  - test/fixtures/api/update_rule.yml
121
+ - test/fixtures/api/user_domains.yml
121
122
  - test/fixtures/domain.rb
122
123
  - test/helper.rb
123
124
  - test/test_directories.rb
@@ -190,6 +191,7 @@ test_files:
190
191
  - test/fixtures/api/update_accounts_properties_scope.yml
191
192
  - test/fixtures/api/update_directory.yml
192
193
  - test/fixtures/api/update_rule.yml
194
+ - test/fixtures/api/user_domains.yml
193
195
  - test/fixtures/domain.rb
194
196
  - test/helper.rb
195
197
  - test/test_directories.rb