Class: TeamdriveApi::Register
- 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
Instance Method Summary collapse
-
#assign_license_to_client(username, number, devices = nil) ⇒ Boolean
Assign license to client (added in RegServ API 1.0.004).
-
#assign_user_to_license(username, number) ⇒ Boolean
Assign user to license (added in RegServ API v1.0.003).
-
#create_license(opts = {}) ⇒ String
Create a license and assign it to a user.
-
#create_license_without_user(opts = {}) ⇒ Object
Create license without user (added in RegServ API v1.0.003).
-
#delete_license(licensenumber) ⇒ Object
Delete licence.
-
#downgrade_default_license(opts = {}) ⇒ Object
Downgrade default-license.
-
#get_default_depot_data(username, distributor = nil) ⇒ Array
Get Default depot data.
-
#get_default_license_for_user(username, distributor = nil) ⇒ Hash
Get default-license for a user.
-
#get_license_data_for_user(username, distributor = nil) ⇒ Hash
Get license data for a user.
-
#get_user_data(username, distributor = nil) ⇒ Hash
Get User Data.
-
#register_user(opts = {}) ⇒ Boolean
(also: #create_account)
Create a new Account.
-
#remove_user(username, opts = {}) ⇒ Boolean
Remove user (added in RegServ API v1.0.003).
-
#reset_password(username) ⇒ Boolean
Reset Password (added in RegServ API v1.0.003).
-
#search_user(query = {}) ⇒ Hash
Search user.
-
#upgrade_default_license(opts = {}) ⇒ Object
Upgrade default-license.
Methods inherited from Base
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)
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)
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.
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)
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
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
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
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
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
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
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
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
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)
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.
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
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
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 |