mxhero-api 0.1.56 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c0924d7f874b2a4f49b8d93c434e7517316fc6f5
4
- data.tar.gz: 584781346abf7f021dd93a6f7d6fc0e5ec969ddf
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NGRlY2NjNmI1NjQ1NWQ5Y2E4MGRlNGM4OGMxN2FlNjA0OTg4YTQ0Yg==
5
+ data.tar.gz: !binary |-
6
+ ZDEwY2MwMTJlMTRhMDU4ZmM4YTdkYTljNDViZTY3NmU5NTI2YThhZA==
5
7
  SHA512:
6
- metadata.gz: 97fe711c5811627767b2b105a79c2b521092d9d42ce2bc326fc07893ca7685fcd9f5d1539484fb1559e475e4b700af5f52f629b638481096ed973301eca6c00c
7
- data.tar.gz: 6b9f3957e2e2883fd12b08bfccbd68ce308222844bdbe92dafb5d02f6ef2b5b758f261acb75b7cda214ce48f5a4c829f78465a1b4b797788ca649547eeb0026c
8
+ metadata.gz: !binary |-
9
+ YzBiY2Y1ZTNlNDYwYTMwMWE0YzQxNGRmZWYyNThhMjMzMDVhMzAzN2YyYzgy
10
+ MWVmYjI0ODdkMGEwOTkwMzllZGMzZWJjNTAzMDdiZmY4NzMwNGRlYmM2M2Fh
11
+ OTQzY2Y2ZDBiYzRmMmQxZTNjNTM3ZGUzOTgyM2UwYzc0OTk2OTg=
12
+ data.tar.gz: !binary |-
13
+ YmNkNGY2MDNlYTJiY2M1YWNkZjIyOTA1Y2E4NmJiMDk1NzVlNDI1N2M3Mzcw
14
+ ZTNlMmVjOGVhNDAzZjE0ZjE5Zjk4YjJhMGQzZGM4NzYxYWIzZmE5MTY3ZDk2
15
+ NDg5NGUxZGRjZDc1MzRjNjk3MWQ1NDUwYzhiMDEzNzEyMDEwODU=
data/Gemfile CHANGED
@@ -6,6 +6,7 @@ gem 'version'
6
6
 
7
7
  group :test do
8
8
  gem 'simplecov', :require => false
9
+ gem 'minitest'
9
10
  end
10
11
 
11
12
  # Specify your gem's dependencies in mxhero-api.gemspec
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.56
1
+ 1.0.0
@@ -9,6 +9,7 @@ require 'urls'
9
9
  require 'groups'
10
10
  require 'dto'
11
11
  require 'directories'
12
+ require 'pst-converter'
12
13
  require 'resource'
13
14
  require 'resources/account'
14
15
  require 'resources/domain'
@@ -606,13 +607,6 @@ module MxHero::API
606
607
  out.to_json
607
608
  end
608
609
 
609
- # @return [MxHero::API::Response] a response object
610
- def parse_response(response, opts = { on_empty: nil })
611
- json = response.content
612
- hash = json.nil? || json.empty? ? opts[:on_empty] : json_parse(json)
613
- Response.new(response.code, hash)
614
- end
615
-
616
610
  def rules_for_domain_url(domain)
617
611
  service_url + "/domains/#{domain}/rules"
618
612
  end
@@ -643,6 +637,14 @@ module MxHero::API
643
637
  service_url + "/system/properties/#{fixed_key}"
644
638
  end
645
639
 
640
+ # @return [MxHero::API::Response] a response object
641
+ def parse_response(response, opts = { on_empty: nil })
642
+ json = response.content
643
+ hash = json.nil? || json.empty? ? opts[:on_empty] : json_parse(json)
644
+ Response.new(response.code, hash)
645
+ end
646
+
647
+
646
648
 
647
649
  end
648
650
 
@@ -0,0 +1,67 @@
1
+ # encoding: utf-8
2
+ require_relative 'communication'
3
+ require_relative 'urls'
4
+
5
+ require 'open-uri'
6
+ require 'delegate'
7
+
8
+ module MxHero::API
9
+
10
+
11
+ class PSTConverter
12
+ include Communication
13
+ include Urls
14
+
15
+ def initialize(config = {})
16
+ @service_url = config[:api_url]
17
+ @username = config[:username]
18
+ @password = config[:password]
19
+ @verbose = config[:verbose] || false
20
+ end
21
+
22
+ # Retrieve all tasks for {account} in status {status}
23
+ #
24
+ # @param [String] account The account to search tasks for
25
+ # @return [MxHero::API::Response] response
26
+ ['active', 'inactive'].each do |status|
27
+ define_method("#{status}_tasks") do |account|
28
+ response = call(:get, url_pst_status(account, status), throw_exception: false)
29
+ parse_response(response, on_empty: [])
30
+ end
31
+ end
32
+
33
+ def delete(account, id)
34
+ response = call(:delete, url_pst_id(account, id), throw_exception: false)
35
+ response.status == 200
36
+ end
37
+
38
+ def save(account, task)
39
+ response = call(:post, url_pst(account), task.to_json, throw_exception: false)
40
+ response.status == 201
41
+ end
42
+
43
+ private
44
+
45
+ def url_pst(account)
46
+ "#{service_url}/pst/#{account}"
47
+ end
48
+
49
+ def url_pst_id(account, id)
50
+ "#{url_pst(account)}/#{id}"
51
+ end
52
+
53
+ def url_pst_status(account, status)
54
+ "#{url_pst(account)}/#{status}"
55
+ end
56
+
57
+ # @return [MxHero::API::Response] a response object
58
+ def parse_response(response, opts = { on_empty: nil })
59
+ json = response.content
60
+ hash = json.nil? || json.empty? ? opts[:on_empty] : json_parse(json)
61
+ Response.new(response.code, hash)
62
+ end
63
+
64
+
65
+ end
66
+
67
+ end
@@ -1,21 +1,21 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: mxhero-api 0.1.56 ruby lib
2
+ # stub: mxhero-api 1.0.0 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "mxhero-api"
6
- s.version = "0.1.56"
6
+ s.version = "1.0.0"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
9
- s.require_paths = ["lib"]
10
9
  s.authors = ["Maximiliano Dello Russo", "Juan Pablo Royo", "mxHero"]
11
- s.date = "2016-04-01"
10
+ s.date = "2016-04-20"
12
11
  s.description = "A gem to provide easy access to the API of MxHero platform (http://www.mxhero.com/)"
13
12
  s.email = ["maxidr@mxhero.com", "juanpablo.royo@gmail.com", "mxhero@mxhero.com"]
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/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/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/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/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_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", ".ruby-gemset", ".ruby-version", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "VERSION", "lib/communication.rb", "lib/directories.rb", "lib/dto.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/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/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/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_feature.rb", "test/test_groups.rb", "test/test_mxhero_api.rb", "test/test_mxhero_api_response.rb", "test/test_resource.rb"]
15
14
  s.homepage = "http://github.com/mxhero/mxhero-api"
16
15
  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.5.1"
18
+ s.rubygems_version = "2.1.9"
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/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/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_feature.rb", "test/test_groups.rb", "test/test_mxhero_api.rb", "test/test_mxhero_api_response.rb", "test/test_resource.rb"]
21
21
 
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.56
4
+ version: 1.0.0
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: 2016-04-01 00:00:00.000000000 Z
13
+ date: 2016-04-20 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
@@ -76,6 +76,7 @@ files:
76
76
  - lib/dto.rb
77
77
  - lib/groups.rb
78
78
  - lib/mxhero-api.rb
79
+ - lib/pst-converter.rb
79
80
  - lib/resource.rb
80
81
  - lib/resources/account.rb
81
82
  - lib/resources/domain.rb
@@ -149,17 +150,17 @@ require_paths:
149
150
  - lib
150
151
  required_ruby_version: !ruby/object:Gem::Requirement
151
152
  requirements:
152
- - - ">="
153
+ - - ! '>='
153
154
  - !ruby/object:Gem::Version
154
155
  version: 2.3.0
155
156
  required_rubygems_version: !ruby/object:Gem::Requirement
156
157
  requirements:
157
- - - ">="
158
+ - - ! '>='
158
159
  - !ruby/object:Gem::Version
159
160
  version: '0'
160
161
  requirements: []
161
162
  rubyforge_project:
162
- rubygems_version: 2.5.1
163
+ rubygems_version: 2.1.9
163
164
  signing_key:
164
165
  specification_version: 4
165
166
  summary: A MxHero API client for ruby