teamdrive_api 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +50 -0
- data/Rakefile +8 -0
- data/bin/console +10 -0
- data/bin/setup +7 -0
- data/lib/teamdrive_api/base.rb +54 -0
- data/lib/teamdrive_api/core_ext/hash.rb +34 -0
- data/lib/teamdrive_api/error.rb +9 -0
- data/lib/teamdrive_api/register.rb +28 -0
- data/lib/teamdrive_api/version.rb +3 -0
- data/lib/teamdrive_api.rb +20 -0
- data/teamdrive_api.gemspec +33 -0
- metadata +144 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1b52d696a6b145a267406dc5855d29db39b55d54
|
4
|
+
data.tar.gz: 7bb13316c5320564084708ded4def7f4b8d9b0fb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d82dcdf0eaa231103b7c9c4a0d2f85cc423c0c9b656ac3e05818c19405362c9916d3f37f2938eb10d341187c6f6da00408a665ef1bb2c62c998c73c556e4230c
|
7
|
+
data.tar.gz: 7625087e1f50d7b585f6f109dd7080bd58797c98126fb2c495a93dcf0769dac8f0f3aef19610d03d859c90794b81da56497db987476a2b195b1b97aeccc20add
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Manuel Hutter
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# TeamdriveApi
|
2
|
+
|
3
|
+
Client library for the TeamDrive XML API.
|
4
|
+
|
5
|
+
## Project State
|
6
|
+
|
7
|
+
Currently only supports the RegServer API
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'teamdrive_api'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install teamdrive_api
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
api = TeamdriveApi::Register.new('example.com', 'd3b07384d113edec49eaa6238ad5ff00', '1.0.005')
|
29
|
+
|
30
|
+
api.remove_user 'foobar'
|
31
|
+
#=> true
|
32
|
+
```
|
33
|
+
|
34
|
+
## Development
|
35
|
+
|
36
|
+
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.
|
37
|
+
|
38
|
+
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).
|
39
|
+
|
40
|
+
## Contributing
|
41
|
+
|
42
|
+
1. Fork it ( https://github.com/[my-github-username]/teamdrive_api/fork )
|
43
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
44
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
45
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
46
|
+
5. Create a new Pull Request
|
47
|
+
|
48
|
+
## Trademarks
|
49
|
+
|
50
|
+
All trademarks named within this project are, without limitation, subject to the regulations of the trademark laws in each case, and as appropriate to ownership rights of the respective registered owners.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "teamdrive_api"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
require "pry"
|
10
|
+
Pry.start
|
data/bin/setup
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'digest'
|
2
|
+
require 'httparty'
|
3
|
+
require 'uri'
|
4
|
+
|
5
|
+
module TeamdriveApi
|
6
|
+
class Base # :nodoc:
|
7
|
+
include ::HTTParty
|
8
|
+
attr_reader :uri
|
9
|
+
format :xml
|
10
|
+
|
11
|
+
def initialize(host, api_checksum_salt, api_version)
|
12
|
+
@api_checksum_salt, @api_version = api_checksum_salt, api_version
|
13
|
+
@host = host.start_with?('http') ? host : 'https://' + host
|
14
|
+
end
|
15
|
+
|
16
|
+
# Generates the XML payload for the RPC
|
17
|
+
def payload_for(command, query = {})
|
18
|
+
out = ''
|
19
|
+
out << %q{<?xml version='1.0' encoding='UTF-8' ?>}
|
20
|
+
out << '<teamdrive>'
|
21
|
+
out << "<apiversion>#{@api_version}</apiversion>"
|
22
|
+
out << "<command>#{command}</command>"
|
23
|
+
out << "<requesttime>#{Time.now.to_i}</requesttime>"
|
24
|
+
query.each do |k,v|
|
25
|
+
next if v.nil?
|
26
|
+
v = v.to_s
|
27
|
+
v = %w{true false}.include?(v) ? '$' + v : v
|
28
|
+
out << "<#{k}>#{v}</#{k}>"
|
29
|
+
end
|
30
|
+
out << '</teamdrive>'
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def send_request(command, data = {})
|
36
|
+
body = payload_for(command, data)
|
37
|
+
res = self.class.post @uri,
|
38
|
+
headers: { 'User-Agent' => "TeamdriveApi v#{TeamdriveApi::VERSION}" },
|
39
|
+
body: body,
|
40
|
+
query: {
|
41
|
+
checksum: Digest::MD5.hexdigest(body + @api_checksum_salt)
|
42
|
+
}
|
43
|
+
|
44
|
+
res = res['teamdrive'].symbolize_keys
|
45
|
+
unless res[:exception].nil?
|
46
|
+
fail TeamdriveApi::Error.new(
|
47
|
+
res[:exception][:primarycode],
|
48
|
+
res[:exception][:message]
|
49
|
+
)
|
50
|
+
end
|
51
|
+
res
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class Hash
|
2
|
+
# Returns a new hash with all keys converted to symbols, as long as
|
3
|
+
# they respond to +to_sym+.
|
4
|
+
#
|
5
|
+
# hash = { 'name' => 'Rob', 'age' => '28' }
|
6
|
+
#
|
7
|
+
# hash.symbolize_keys
|
8
|
+
# # => {:name=>"Rob", :age=>"28"}
|
9
|
+
#
|
10
|
+
# Borrowed from ActiveSupport.
|
11
|
+
def symbolize_keys
|
12
|
+
result = self.class.new
|
13
|
+
each_key do |key|
|
14
|
+
new_key = key.to_sym rescue key
|
15
|
+
new_value = self[key].symbolize_keys rescue self[key]
|
16
|
+
result[new_key] = new_value
|
17
|
+
end
|
18
|
+
result
|
19
|
+
end
|
20
|
+
|
21
|
+
# Destructively converts all keys to symbols, as long as they respond
|
22
|
+
# to +to_sym+. Same as +symbolize_keys+, but modifies +self+.
|
23
|
+
#
|
24
|
+
# Borrowed from ActiveSupport.
|
25
|
+
def symbolize_keys!
|
26
|
+
keys.each do |key|
|
27
|
+
new_key = key.to_sym rescue key
|
28
|
+
old_value = delete(key)
|
29
|
+
new_value = old_value.symbolize_keys! rescue old_value
|
30
|
+
self[new_key] = new_value
|
31
|
+
end
|
32
|
+
self
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module TeamdriveApi
|
2
|
+
# API Client for the TeamDrive Register Server. See the TeamDrive Register docs for more informations on specific commands.
|
3
|
+
class Register < Base
|
4
|
+
# Create a new Register API Client.
|
5
|
+
#
|
6
|
+
# @param [String] host the API Server
|
7
|
+
# @param [String] api_checksum_salt the +APIChecksumSalt+ system setting ("Edit Settings -> RegServer").
|
8
|
+
# @param [String] api_version optionally overwrite the api_version
|
9
|
+
def initialize(host, api_checksum_salt, api_version = '1.0.005')
|
10
|
+
super
|
11
|
+
@uri = URI.join(@host + '/', 'pbas/td2api/api/api.htm').to_s
|
12
|
+
end
|
13
|
+
|
14
|
+
# Remove user (added in +1.0.003+)
|
15
|
+
#
|
16
|
+
# @param [String] username to be deleted
|
17
|
+
# @param [Boolean] delete the user's license aswell
|
18
|
+
# @param [String] distributor will only be used if allowed by the API (see +APIAllowSettingDistributor+ in the Teamdrive Register docs).
|
19
|
+
def remove_user(username, delete_license = false, distributor = nil)
|
20
|
+
res = send_request :removeuser, {
|
21
|
+
username: username,
|
22
|
+
delete_license: delete_license,
|
23
|
+
distributor: distributor
|
24
|
+
}
|
25
|
+
return res[:intresult].eql?('0')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'teamdrive_api/version'
|
2
|
+
require 'teamdrive_api/core_ext/hash'
|
3
|
+
require 'teamdrive_api/error'
|
4
|
+
require 'teamdrive_api/base'
|
5
|
+
require 'teamdrive_api/register'
|
6
|
+
|
7
|
+
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
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'teamdrive_api/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "teamdrive_api"
|
8
|
+
spec.version = TeamdriveApi::VERSION
|
9
|
+
spec.authors = ["Manuel Hutter"]
|
10
|
+
spec.email = ["git@mhutter.net"]
|
11
|
+
|
12
|
+
if spec.respond_to?(:metadata)
|
13
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com' to prevent pushes to rubygems.org, or delete to allow pushes to any server."
|
14
|
+
end
|
15
|
+
|
16
|
+
spec.summary = %q{TeamDrive API Client}
|
17
|
+
spec.description = %q{Client library for the TeamDrive XML API. Currently only supports the RegServer API}
|
18
|
+
spec.homepage = "https://github.com/mhutter/teamdrive_api"
|
19
|
+
spec.license = "MIT"
|
20
|
+
|
21
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
|
+
spec.bindir = "exe"
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.add_runtime_dependency "httparty", "~> 0.13"
|
27
|
+
|
28
|
+
spec.add_development_dependency "bundler", "~> 1.8"
|
29
|
+
spec.add_development_dependency "minitest", "~> 5.5"
|
30
|
+
spec.add_development_dependency "pry", "~> 0.10"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
spec.add_development_dependency "webmock", "~> 1.20"
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: teamdrive_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Manuel Hutter
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.13'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.8'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.8'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.5'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.10'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.10'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: webmock
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.20'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.20'
|
97
|
+
description: Client library for the TeamDrive XML API. Currently only supports the
|
98
|
+
RegServer API
|
99
|
+
email:
|
100
|
+
- git@mhutter.net
|
101
|
+
executables: []
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- ".gitignore"
|
106
|
+
- ".travis.yml"
|
107
|
+
- Gemfile
|
108
|
+
- LICENSE.txt
|
109
|
+
- README.md
|
110
|
+
- Rakefile
|
111
|
+
- bin/console
|
112
|
+
- bin/setup
|
113
|
+
- lib/teamdrive_api.rb
|
114
|
+
- lib/teamdrive_api/base.rb
|
115
|
+
- lib/teamdrive_api/core_ext/hash.rb
|
116
|
+
- lib/teamdrive_api/error.rb
|
117
|
+
- lib/teamdrive_api/register.rb
|
118
|
+
- lib/teamdrive_api/version.rb
|
119
|
+
- teamdrive_api.gemspec
|
120
|
+
homepage: https://github.com/mhutter/teamdrive_api
|
121
|
+
licenses:
|
122
|
+
- MIT
|
123
|
+
metadata: {}
|
124
|
+
post_install_message:
|
125
|
+
rdoc_options: []
|
126
|
+
require_paths:
|
127
|
+
- lib
|
128
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
requirements: []
|
139
|
+
rubyforge_project:
|
140
|
+
rubygems_version: 2.4.6
|
141
|
+
signing_key:
|
142
|
+
specification_version: 4
|
143
|
+
summary: TeamDrive API Client
|
144
|
+
test_files: []
|