teamdrive_api 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2ba5238b1fa4ed98698e6a63451b942d8bf00b6c
4
- data.tar.gz: 8399fc3422dde2957af01fdda909237cbf52ab67
3
+ metadata.gz: 3907c9541d30a306e0115d2e0f1d057d57d06ffb
4
+ data.tar.gz: ee7502e5870a9d00ee1091d54dd3f9f3953b913c
5
5
  SHA512:
6
- metadata.gz: 5d00faa1441326182374f7b378afe03f6770f79d3df1f0d7e6e01e729ee45954f42c71d8b5277e916d8c9031f10528b7435c526f0415c9b0833114a0e89c521c
7
- data.tar.gz: d8142ecce1f780538cbce731aa19237678a0d269a0cd4281b258c9d9c47cea3edda0838eb93327334cd00db4a957f19a5f22a1f7bdfba3147099a6b4455d3fc0
6
+ metadata.gz: 961ca480bde4d9ef0bf034fd4c33b055bd7488a998f5e8b41746eb287f31abbcc35144e43cd808e1dc53332279eb38ae7a0a6582e8a74421b03afa2cfb815a80
7
+ data.tar.gz: 3210a0e0ed635772dd470548a3daa35cf486ac698780041442c22320659f8b263789d5b8cb2333b75fb3d12def3d26376b3273170c938eb7209c9fb88043dd23
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # TeamdriveApi
2
2
 
3
+ [![Documentation](http://img.shields.io/badge/docs-rdoc.info-blue.svg)](http://rubydoc.org/gems/teamdrive_api/frames)
3
4
  [![Gem Version](https://badge.fury.io/rb/teamdrive_api.svg)](http://badge.fury.io/rb/teamdrive_api)
4
5
  [![Build Status](https://travis-ci.org/mhutter/teamdrive_api.svg?branch=master)](https://travis-ci.org/mhutter/teamdrive_api)
5
6
  [![Code Climate](https://codeclimate.com/github/mhutter/teamdrive_api/badges/gpa.svg)](https://codeclimate.com/github/mhutter/teamdrive_api)
@@ -62,6 +62,7 @@ module TeamdriveApi
62
62
  res = res['teamdrive'].symbolize_keys
63
63
  unless res[:exception].nil?
64
64
  fail TeamdriveApi::Error.new res[:exception][:primarycode],
65
+ res[:exception][:secondarycode],
65
66
  res[:exception][:message]
66
67
  end
67
68
  res
@@ -1,9 +1,10 @@
1
1
  module TeamdriveApi
2
2
  # An exception raised by the TeamDrive API
3
3
  class Error < StandardError
4
- def initialize(code, msg)
5
- super msg
6
- @code, @msg = code, msg
4
+ attr_reader :code, :secondarycode, :message
5
+ def initialize(code, secondarycode, message)
6
+ super message
7
+ @code, @secondarycode, @message = code, secondarycode, message
7
8
  end
8
9
  end
9
10
  end
@@ -11,6 +11,17 @@ module TeamdriveApi
11
11
  @uri = URI.join(@host + '/', 'pbas/td2api/api/api.htm').to_s
12
12
  end
13
13
 
14
+ # Assign license to client (added in RegServ API 1.0.004)
15
+ #
16
+ # @param [String] username
17
+ # @param [String] number License Number
18
+ # @param [Array] devices optional list of devices the user posses. If empty, all of the user’s devices will be used
19
+ # @return [Boolean] success?
20
+ def assign_license_to_client(username, number, devices = [])
21
+ res = send_request :assignlicensetoclient, username: username, number: number, devices: devices
22
+ res[:intresult].eql?(0)
23
+ end
24
+
14
25
  # Assign user to license (added in RegServ API v1.0.003)
15
26
  #
16
27
  # @param [String] username
@@ -32,11 +43,36 @@ module TeamdriveApi
32
43
  # @option opts [String] :contactnumber An optional contact number. Added with v1.0.004
33
44
  # @option opts [String] :validuntil An optional valid-until date. Format must be +DD.MM.YYYY+. Added with v1.0.004
34
45
  # @option opts [String] :changeid An optional change id for license changes. Added with v1.0.004
35
- # @return [Boolean] success?
46
+ # @return [Hash] The created license?
36
47
  def create_license_without_user(opts = {})
37
48
  require_all of: [:productname, :type, :featurevalue], in_hash: opts
38
- res = send_request :createlicensewithoutuser, opts
39
- res[:intresult].eql?('0')
49
+ send_request :createlicensewithoutuser, opts
50
+ end
51
+
52
+ # Get default-license for a user
53
+ #
54
+ # @param [String] username
55
+ # @param [String] distributor (optional)
56
+ # @return [Hash] the license data
57
+ def get_default_license_for_user(username, distributor = nil)
58
+ res = send_request(:getdefaultlicense, {
59
+ username: username,
60
+ distributor: distributor
61
+ })
62
+ res[:licensedata]
63
+ end
64
+
65
+ # Get license data for a user
66
+ #
67
+ # @param [String] username
68
+ # @param [String] distributor (optional)
69
+ # @return [Hash] the license data
70
+ def get_license_data_for_user(username, distributor = nil)
71
+ res = send_request(:getlicensedata, {
72
+ username: username,
73
+ distributor: distributor
74
+ })
75
+ res[:licensedata]
40
76
  end
41
77
 
42
78
  # Get User Data
@@ -51,6 +87,28 @@ module TeamdriveApi
51
87
  })
52
88
  end
53
89
 
90
+ # Create a new Account
91
+ #
92
+ # @note The range of possible Usernames depend on the +RegNameComplexity+
93
+ # setting as described in the Registration Server documentation.
94
+ # Similary, the length of passwords can be restricted by the
95
+ # +ClientPasswordLength+ setting. However, these restriction only apply
96
+ # when creating a new account, they will not be checked when a user
97
+ # attempts to log in.
98
+ #
99
+ # @param [Hash] Data for the new user.
100
+ # @option opts [String] :username
101
+ # @option opts [String] :useremail
102
+ # @option opts [String] :password
103
+ # @option opts [String] :language
104
+ # @option opts [String] :reference
105
+ # @option opts [String] :department
106
+ # @option opts [String] :distributor
107
+ def register_user(opts = {})
108
+ send_request(:registeruser, opts)
109
+ end
110
+ alias_method :create_account, :register_user
111
+
54
112
  # Remove user (added in RegServ API v1.0.003)
55
113
  #
56
114
  # @param [String] username to be deleted
@@ -1,3 +1,3 @@
1
1
  module TeamdriveApi
2
- VERSION = '0.2.0'
2
+ VERSION = '0.3.0'
3
3
  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.2.0
4
+ version: 0.3.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-27 00:00:00.000000000 Z
11
+ date: 2015-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty