Class: TeamdriveApi::Register

Inherits:
Base
  • Object
show all
Defined in:
lib/teamdrive_api/register.rb

Overview

API Client for the TeamDrive Register Server. See the TeamDrive Register docs for more informations on specific commands.

Instance Attribute Summary

Attributes inherited from Base

#uri

Instance Method Summary collapse

Methods inherited from Base

#initialize, #payload_for

Constructor Details

This class inherits a constructor from TeamdriveApi::Base

Instance Method Details

#assign_license_to_client(username, number, devices = nil) ⇒ Boolean

Assign license to client (added in RegServ API 1.0.004)

Parameters:

  • username (String)
  • number (String)

    License Number

  • devices (Array) (defaults to: nil)

    optional list of devices the user posses. If empty, all of the user’s devices will be used

Returns:

  • (Boolean)

    success?



12
13
14
15
16
17
18
19
# File 'lib/teamdrive_api/register.rb', line 12

def assign_license_to_client(username, number, devices = nil)
  res = send_request :assignlicensetoclient,
                     username: username,
                     number: number,
                     devices: devices

  res[:intresult].eql?('0')
end

#assign_user_to_license(username, number) ⇒ Boolean

Assign user to license (added in RegServ API v1.0.003)

Parameters:

  • username (String)
  • number (String)

    License Number

Returns:

  • (Boolean)

    success?



26
27
28
29
30
31
32
# File 'lib/teamdrive_api/register.rb', line 26

def assign_user_to_license(username, number)
  res = send_request :assignusertolicense,
                     username: username,
                     number: number

  res[:intresult].eql?('0')
end

#create_license(opts = {}) ⇒ String

Create a license and assign it to a user.

Parameters:

  • opts (Hash) (defaults to: {})

    license options

Options Hash (opts):

  • :username (String)

    User to assign license to

  • :productname (String)

    server, client

  • :type (String)

    monthly / yearly / permanent

  • :featurevalue (String)

    one of webdavs, personal, professional, enterprise

  • :limit (String)

    Amount, only for client licenses. Optional.

  • :licensereference (String)

    An optional external reference. Added with v1.0.004

  • :contactnumber (String)

    An optional contact number. Added with v1.0.004

  • :validuntil (String)

    An optional valid-until date. Format must be MM/DD/YYYY. Added with v1.0.004

  • :changeid (String)

    An optional change id for license changes. Added with v1.0.004

Returns:

  • (String)

    The license number of the created license



52
53
54
55
56
57
# File 'lib/teamdrive_api/register.rb', line 52

def create_license(opts = {})
  require_all of: [:username, :productname, :type, :featurevalue],
              in_hash: opts
  res = send_request :createlicense, opts
  res[:licensedata][:number]
end

#create_license_without_user(opts = {}) ⇒ Object

Create license without user (added in RegServ API v1.0.003)

See Also:



62
63
64
65
66
# File 'lib/teamdrive_api/register.rb', line 62

def create_license_without_user(opts = {})
  require_all of: [:productname, :type, :featurevalue], in_hash: opts
  res = send_request :createlicensewithoutuser, opts
  res[:licensedata][:number]
end

#delete_license(licensenumber) ⇒ Object

Delete licence

Parameters:

  • licensenumber (String)


95
96
97
98
# File 'lib/teamdrive_api/register.rb', line 95

def delete_license(licensenumber)
  res = send_request(:deletelicense, licensenumber: licensenumber)
  res[:intresult].eql?('0')
end

#downgrade_default_license(opts = {}) ⇒ Object

Downgrade default-license

Parameters:

  • opts (Hash) (defaults to: {})

    license options

Options Hash (opts):

  • :username (String)
  • :featurevalue (String)

    optional

  • :limit (String)

    optional



74
75
76
77
78
# File 'lib/teamdrive_api/register.rb', line 74

def downgrade_default_license(opts = {})
  require_all of: [:username], in_hash: opts
  res = send_request(:downgradedefaultlicense, opts)
  res[:intresult].eql?('0')
end

#get_default_depot_data(username, distributor = nil) ⇒ Array

Get Default depot data

Parameters:

  • username (String)
  • distributor (String) (defaults to: nil)

    (optional)

Returns:

  • (Array)

    the default depot data



142
143
144
145
146
147
# File 'lib/teamdrive_api/register.rb', line 142

def get_default_depot_data(username, distributor = nil)
  data = send_request :getdefaultdepotdata,
                      username: username,
                      distributor: distributor
  [data[:depotdata][:depot]].flatten
end

#get_default_license_for_user(username, distributor = nil) ⇒ Hash

Get default-license for a user

Parameters:

  • username (String)
  • distributor (String) (defaults to: nil)

    optional

Returns:

  • (Hash)

    the license data



105
106
107
108
109
110
111
# File 'lib/teamdrive_api/register.rb', line 105

def get_default_license_for_user(username, distributor = nil)
  res = send_request :getdefaultlicense,
                     username: username,
                     distributor: distributor

  res[:licensedata]
end

#get_license_data_for_user(username, distributor = nil) ⇒ Hash

Get license data for a user

Parameters:

  • username (String)
  • distributor (String) (defaults to: nil)

    (optional)

Returns:

  • (Hash)

    the license data



118
119
120
121
122
123
124
# File 'lib/teamdrive_api/register.rb', line 118

def get_license_data_for_user(username, distributor = nil)
  res = send_request :getlicensedata,
                     username: username,
                     distributor: distributor

  res[:licensedata]
end

#get_user_data(username, distributor = nil) ⇒ Hash

Get User Data

Parameters:

  • username (String)
  • distributor (String) (defaults to: nil)

    (optional, added in RegServ API v1.0.003)

Returns:

  • (Hash)

    the user data



131
132
133
134
135
# File 'lib/teamdrive_api/register.rb', line 131

def get_user_data(username, distributor = nil)
  send_request :getuserdata,
               username: username,
               distributor: distributor
end

#register_user(opts = {}) ⇒ Boolean Also known as: create_account

Note:

The range of possible Usernames depend on the RegNameComplexity setting as described in the Registration Server documentation. Similary, the length of passwords can be restricted by the ClientPasswordLength setting. However, these restriction only apply when creating a new account, they will not be checked when a user attempts to log in.

Create a new Account

Parameters:

  • opts (Hash) (defaults to: {})

    Data for the new user.

Options Hash (opts):

  • :username (String)
  • :useremail (String)
  • :password (String)
  • :language (String)

    optional

  • :reference (String)

    optional

  • :department (String)

    optional

  • :distributor (String)

    optional

Returns:

  • (Boolean)

    true if the User has been created



167
168
169
170
171
# File 'lib/teamdrive_api/register.rb', line 167

def register_user(opts = {})
  require_all of: [:username, :useremail, :password], in_hash: opts
  res = send_request(:registeruser, opts)
  res[:intresult].eql?('0')
end

#remove_user(username, opts = {}) ⇒ Boolean

Remove user (added in RegServ API v1.0.003)

Parameters:

  • username (String)

    User to be deleted

  • opts (Hash) (defaults to: {})

    Options

Options Hash (opts):

  • :deletelicense (Boolean)

    Remove the users licenses aswell. – Default: false

  • :deletedepot (Boolean)

    Remove the users depot (data) aswell. – Default: false

  • :distributor (String)

    Distributor. Only used if allowed by the API (see APIAllowSettingDistributor in the TD Register docs). – Default: nil

Returns:

  • (Boolean)

    success?



186
187
188
189
190
191
192
193
194
195
# File 'lib/teamdrive_api/register.rb', line 186

def remove_user(username, opts = {})
  opts = {
    username: username,
    deletelicense: false,
    deletedepot: false
  }.merge(opts)
  res = send_request :removeuser, opts

  res[:intresult].eql?('0')
end

#reset_password(username) ⇒ Boolean

Reset Password (added in RegServ API v1.0.003)

Resetting a user’s password will set it to a random value.

Parameters:

  • username (String)

    of the user to reset the password.

Returns:

  • (Boolean)

    success?



221
222
223
224
# File 'lib/teamdrive_api/register.rb', line 221

def reset_password(username)
  opts = { username: username }
  send_request :resetpassword, opts
end

#search_user(query = {}) ⇒ Hash

Search user

Parameters:

  • query (Hash) (defaults to: {})

    the search query.

Options Hash (query):

  • :username (String)
  • :email (String)
  • :startid (String) — default: 0
  • :showdevice (Boolean) — default: false
  • :onlyownusers (Boolean) — default: false

Returns:

  • (Hash)

    list of users



206
207
208
209
210
211
212
213
# File 'lib/teamdrive_api/register.rb', line 206

def search_user(query = {})
  require_one of: [:username, :email], in_hash: query
  query = {
    showdevice: false,
    onlyownusers: false
  }.merge(query)
  send_request :searchuser, query
end

#upgrade_default_license(opts = {}) ⇒ Object

Upgrade default-license

Parameters:

  • opts (Hash) (defaults to: {})

    license options

Options Hash (opts):

  • :username (String)
  • :featurevalue (String)

    optional

  • :limit (String)

    optional



86
87
88
89
90
# File 'lib/teamdrive_api/register.rb', line 86

def upgrade_default_license(opts = {})
  require_all of: [:username], in_hash: opts
  res = send_request(:upgradedefaultlicense, opts)
  res[:intresult].eql?('0')
end