teamdrive_api 0.1.2 → 0.2.0
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/README.md +37 -2
- data/lib/teamdrive_api/core_ext/array.rb +15 -0
- data/lib/teamdrive_api/register.rb +9 -4
- data/lib/teamdrive_api/version.rb +1 -1
- data/lib/teamdrive_api.rb +1 -12
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ba5238b1fa4ed98698e6a63451b942d8bf00b6c
|
4
|
+
data.tar.gz: 8399fc3422dde2957af01fdda909237cbf52ab67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d00faa1441326182374f7b378afe03f6770f79d3df1f0d7e6e01e729ee45954f42c71d8b5277e916d8c9031f10528b7435c526f0415c9b0833114a0e89c521c
|
7
|
+
data.tar.gz: d8142ecce1f780538cbce731aa19237678a0d269a0cd4281b258c9d9c47cea3edda0838eb93327334cd00db4a957f19a5f22a1f7bdfba3147099a6b4455d3fc0
|
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# TeamdriveApi
|
2
2
|
|
3
|
+
[](http://badge.fury.io/rb/teamdrive_api)
|
3
4
|
[](https://travis-ci.org/mhutter/teamdrive_api)
|
4
5
|
[](https://codeclimate.com/github/mhutter/teamdrive_api)
|
5
6
|
[](https://codeclimate.com/github/mhutter/teamdrive_api)
|
@@ -33,17 +34,51 @@ api = TeamdriveApi::Register.new('example.com', 'd3b07384d113edec49eaa6238ad5ff0
|
|
33
34
|
|
34
35
|
api.remove_user 'foobar'
|
35
36
|
#=> true
|
37
|
+
|
38
|
+
api.search_user username: '$CODE-*'
|
39
|
+
#=> {:apiversion=>"1.0.005",
|
40
|
+
#=> :searchresult=>{:current=>"3", :maximum=>"50", :total=>"3"},
|
41
|
+
#=> :userlist=>
|
42
|
+
#=> {:user=>
|
43
|
+
#=> [{:userid=>"2",
|
44
|
+
#=> :username=>"$CODE-1002",
|
45
|
+
#=> :email=>"user2@example.com",
|
46
|
+
#=> :reference=>nil,
|
47
|
+
#=> :department=>nil,
|
48
|
+
#=> :language=>"en",
|
49
|
+
#=> :distributor=>"CODE",
|
50
|
+
#=> :usercreated=>"07/25/2014 15:06:41.00",
|
51
|
+
#=> :status=>"activated"},
|
52
|
+
#=> {:userid=>"10",
|
53
|
+
#=> :username=>"$CODE-1010",
|
54
|
+
#=> :email=>"user10@example.com",
|
55
|
+
#=> :reference=>nil,
|
56
|
+
#=> :department=>nil,
|
57
|
+
#=> :language=>"en",
|
58
|
+
#=> :distributor=>"CODE",
|
59
|
+
#=> :usercreated=>"10/01/2014 09:31:49.00",
|
60
|
+
#=> :status=>"activated"},
|
61
|
+
#=> {:userid=>"15",
|
62
|
+
#=> :username=>"$CODE-1015",
|
63
|
+
#=> :email=>"user15@example.com",
|
64
|
+
#=> :reference=>nil,
|
65
|
+
#=> :department=>nil,
|
66
|
+
#=> :language=>"en",
|
67
|
+
#=> :distributor=>"CODE",
|
68
|
+
#=> :usercreated=>"03/04/2015 13:39:09.00",
|
69
|
+
#=> :status=>"activated"}]}}
|
36
70
|
```
|
37
71
|
|
72
|
+
For more Information see {TeamdriveApi::Register}
|
73
|
+
|
38
74
|
## Development
|
39
75
|
|
40
76
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
41
77
|
|
42
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
43
78
|
|
44
79
|
## Contributing
|
45
80
|
|
46
|
-
1. Fork it ( https://github.com/
|
81
|
+
1. Fork it ( https://github.com/mhutter/teamdrive_api/fork )
|
47
82
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
48
83
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
49
84
|
4. Push to the branch (`git push origin my-new-feature`)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class Array
|
2
|
+
# Returns an Array with all elements' keys converted to symbols, as long as
|
3
|
+
# they respond to +symbolize_keys+.
|
4
|
+
def symbolize_keys
|
5
|
+
self.map { |e| e.symbolize_keys rescue e }
|
6
|
+
end
|
7
|
+
|
8
|
+
# Converts the keys of all elements to symbols, as long as the elements
|
9
|
+
# respond to +symbolize_keys!+
|
10
|
+
def symbolize_keys!
|
11
|
+
self.each do |e|
|
12
|
+
e.symbolize_keys! rescue nil
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -11,16 +11,17 @@ module TeamdriveApi
|
|
11
11
|
@uri = URI.join(@host + '/', 'pbas/td2api/api/api.htm').to_s
|
12
12
|
end
|
13
13
|
|
14
|
-
# Assign user to license (added in
|
14
|
+
# Assign user to license (added in RegServ API v1.0.003)
|
15
15
|
#
|
16
16
|
# @param [String] username
|
17
17
|
# @param [String] number License Number
|
18
|
+
# @return [Boolean] success?
|
18
19
|
def assign_user_to_license(username, number)
|
19
20
|
res = send_request :assignusertolicense, username: username, number: number
|
20
21
|
res[:intresult].eql?('0')
|
21
22
|
end
|
22
23
|
|
23
|
-
# Create license without user (added in
|
24
|
+
# Create license without user (added in RegServ API v1.0.003)
|
24
25
|
#
|
25
26
|
# @param [Hash] opts license options
|
26
27
|
# @option opts [String] :productname +server+, +client+
|
@@ -31,6 +32,7 @@ module TeamdriveApi
|
|
31
32
|
# @option opts [String] :contactnumber An optional contact number. Added with v1.0.004
|
32
33
|
# @option opts [String] :validuntil An optional valid-until date. Format must be +DD.MM.YYYY+. Added with v1.0.004
|
33
34
|
# @option opts [String] :changeid An optional change id for license changes. Added with v1.0.004
|
35
|
+
# @return [Boolean] success?
|
34
36
|
def create_license_without_user(opts = {})
|
35
37
|
require_all of: [:productname, :type, :featurevalue], in_hash: opts
|
36
38
|
res = send_request :createlicensewithoutuser, opts
|
@@ -40,7 +42,8 @@ module TeamdriveApi
|
|
40
42
|
# Get User Data
|
41
43
|
#
|
42
44
|
# @param [String] username
|
43
|
-
# @param [String] distributor (optional, added in API
|
45
|
+
# @param [String] distributor (optional, added in RegServ API v1.0.003)
|
46
|
+
# @return [Hash] the user data
|
44
47
|
def get_user_data(username, distributor = nil)
|
45
48
|
send_request(:getuserdata, {
|
46
49
|
username: username,
|
@@ -48,12 +51,13 @@ module TeamdriveApi
|
|
48
51
|
})
|
49
52
|
end
|
50
53
|
|
51
|
-
# Remove user (added in
|
54
|
+
# Remove user (added in RegServ API v1.0.003)
|
52
55
|
#
|
53
56
|
# @param [String] username to be deleted
|
54
57
|
# @param [Boolean] delete the user's license aswell
|
55
58
|
# @param [String] distributor will only be used if allowed by the API (see
|
56
59
|
# +APIAllowSettingDistributor+ in the Teamdrive Register docs).
|
60
|
+
# @return [Boolean] success?
|
57
61
|
def remove_user(username, delete_license = false, distributor = nil)
|
58
62
|
res = send_request :removeuser,
|
59
63
|
username: username,
|
@@ -71,6 +75,7 @@ module TeamdriveApi
|
|
71
75
|
# @option query [String] :startid (0)
|
72
76
|
# @option query [Boolean] :showdevice (false)
|
73
77
|
# @option query [Boolean] :onlyownusers (false)
|
78
|
+
# @return [Hash] list of users
|
74
79
|
def search_user(query = {})
|
75
80
|
require_one of: [:username, :email], in_hash: query
|
76
81
|
query = {
|
data/lib/teamdrive_api.rb
CHANGED
@@ -1,20 +1,9 @@
|
|
1
1
|
require 'teamdrive_api/version'
|
2
|
+
require 'teamdrive_api/core_ext/array'
|
2
3
|
require 'teamdrive_api/core_ext/hash'
|
3
4
|
require 'teamdrive_api/error'
|
4
5
|
require 'teamdrive_api/base'
|
5
6
|
require 'teamdrive_api/register'
|
6
7
|
|
7
8
|
module TeamdriveApi
|
8
|
-
# extend self
|
9
|
-
#
|
10
|
-
# # default options
|
11
|
-
# @options = {
|
12
|
-
# api_version: '1.0.005',
|
13
|
-
# register_path: 'pbas/td2api/api/api.htm'
|
14
|
-
# }
|
15
|
-
#
|
16
|
-
# # The options hash. See {file:README.md#options the options documentation}.
|
17
|
-
# #
|
18
|
-
# # @return [{Symbol => Object}]
|
19
|
-
# attr_accessor :options
|
20
9
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: teamdrive_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Manuel Hutter
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -126,6 +126,7 @@ files:
|
|
126
126
|
- bin/setup
|
127
127
|
- lib/teamdrive_api.rb
|
128
128
|
- lib/teamdrive_api/base.rb
|
129
|
+
- lib/teamdrive_api/core_ext/array.rb
|
129
130
|
- lib/teamdrive_api/core_ext/hash.rb
|
130
131
|
- lib/teamdrive_api/error.rb
|
131
132
|
- lib/teamdrive_api/register.rb
|
@@ -156,3 +157,4 @@ signing_key:
|
|
156
157
|
specification_version: 4
|
157
158
|
summary: TeamDrive API Client
|
158
159
|
test_files: []
|
160
|
+
has_rdoc:
|