Class: NVX::SDS::MasterAccount
- Inherits:
-
Object
- Object
- NVX::SDS::MasterAccount
- Defined in:
- lib/nvx/sds/masteraccount.rb
Overview
Overview
The Master account lets you create children, modify children, Get and Set limits, adjust account notes and impersonate child accounts. Impersonation is available as a simple way to log into a child account if you do not know the child accounts password but you are the master account. This simplifies the administration of child accounts.
Instance Method Summary collapse
-
#CreateChildAccount(username, password, first_name = nil, last_name = nil, middle_initial = nil, phone_number = nil, email_address = nil, email_format = nil, address_line1 = nil, address_line2 = nil, city = nil, state = nil, country = nil, postal_code = nil) ⇒ Object
Creates a new child account.
-
#DeleteChildAccount(username) ⇒ Object
Removes a child account.
-
#GetAccountLimits(username) ⇒ Object
Gets the account limits as an array of AccountLimit objects of the child account passed.
-
#GetAccountNotes(username) ⇒ Object
Gets the account notes in xml.
-
#ImpersonateChildAccount(username) ⇒ Object
This lets the master account get a session for a child account that they have previously created without knowing the password for that child account.
-
#initialize(session, account_login) ⇒ MasterAccount
constructor
Sets the current session and account login objects.
- #ListChildAccounts(page_number = 1, page_size = 500) ⇒ Object
-
#SetAccountLimits(username, limits) ⇒ Object
Sets the account limits from the array of AccountLimit objects passed on the username.
-
#SetAccountNotes(username, xml_notes) ⇒ Object
Set the account notes.
-
#SetChildAccountPassword(master_password, child_username, new_password) ⇒ Object
Changes the child password.
Constructor Details
#initialize(session, account_login) ⇒ MasterAccount
Sets the current session and account login objects.
18 19 20 21 |
# File 'lib/nvx/sds/masteraccount.rb', line 18 def initialize(session, account_login) @account_login = account_login @session = session end |
Instance Method Details
#CreateChildAccount(username, password, first_name = nil, last_name = nil, middle_initial = nil, phone_number = nil, email_address = nil, email_format = nil, address_line1 = nil, address_line2 = nil, city = nil, state = nil, country = nil, postal_code = nil) ⇒ Object
Creates a new child account. The username and password are required fields. By default there are no limits on a child account.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/nvx/sds/masteraccount.rb', line 25 def CreateChildAccount(username, password, first_name = nil, last_name = nil, middle_initial = nil, phone_number = nil, email_address = nil, email_format = nil, address_line1 = nil, address_line2 = nil, city = nil, state = nil, country = nil, postal_code = nil) params = [APIParam.new("username", username), APIParam.new("password", password)] params << APIParam.new("firstName", first_name) if !first_name.nil? params << APIParam.new("lastName", last_name) if !last_name.nil? params << APIParam.new("middleInitial", middle_initial) if !middle_initial.nil? params << APIParam.new("phoneNumber", phone_number) if !phone_number.nil? params << APIParam.new("emailAddress", email_address) if !email_address.nil? params << APIParam.new("emailFormat", email_format) if !email_format.nil? params << APIParam.new("addressLine1", address_line1) if !address_line1.nil? params << APIParam.new("addressLine2", address_line2) if !address_line2.nil? params << APIParam.new("city", city) if !city.nil? params << APIParam.new("state", state) if !state.nil? params << APIParam.new("countryID", country) if !country.nil? params << APIParam.new("postalCode", postal_code) if !postal_code.nil? Transport.execute_command_post(APICommand.CreateChildAccount, params, @account_login) end |
#DeleteChildAccount(username) ⇒ Object
Removes a child account. **This will also remove ALL files/notes/account info the child previously had in their account.
48 49 50 |
# File 'lib/nvx/sds/masteraccount.rb', line 48 def DeleteChildAccount(username) Transport.execute_command_post(APICommand.DeleteChildAccount, [APIParam.new("username", username)], @account_login) end |
#GetAccountLimits(username) ⇒ Object
Gets the account limits as an array of AccountLimit objects of the child account passed.
88 89 90 |
# File 'lib/nvx/sds/masteraccount.rb', line 88 def GetAccountLimits(username) Utilities.GetAccountLimits(@account_login, username) end |
#GetAccountNotes(username) ⇒ Object
Gets the account notes in xml.
81 82 83 84 85 |
# File 'lib/nvx/sds/masteraccount.rb', line 81 def GetAccountNotes(username) doc = Transport.execute_command_post(APICommand.GetAccountNotes, [APIParam.new("username", username)], @account_login) return (text = doc.root.elements["//Response/GetAccountNotes"].get_text and text.value) end |
#ImpersonateChildAccount(username) ⇒ Object
This lets the master account get a session for a child account that they have previously created without knowing the password for that child account.
114 115 116 117 |
# File 'lib/nvx/sds/masteraccount.rb', line 114 def ImpersonateChildAccount(username) @session = Session.new(@account_login.app_key, username, @account_login.app_name, nil, @account_login.session_token) return @session end |
#ListChildAccounts(page_number = 1, page_size = 500) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/nvx/sds/masteraccount.rb', line 64 def ListChildAccounts(page_number = 1, page_size = 500) params = [APIParam.new("pageNumber", page_number), APIParam.new("pageSize", page_size)] doc = Transport.execute_command_post(APICommand.ListChildAccounts, params, @account_login) child_accounts = Array.new #if there is any metadata loop through if doc.root.elements["//Response/Account"] doc.root.elements.each("//Response/Account") do |account_name| child_accounts << account_name.get_text.value end end return child_accounts end |
#SetAccountLimits(username, limits) ⇒ Object
Sets the account limits from the array of AccountLimit objects passed on the username. Valid limit types:
-
StorageAmount - The total bytes stored.
-
DownloadBandwidthAmount - The total number of bytes that can be downloaded per pay period.
-
FileSizeDownloadLimit - The maximum size in bytes of a file that can be downlaoded.
-
UploadBandwidthAmount - The total number of bytes that can be uploaded per pay period.
101 102 103 |
# File 'lib/nvx/sds/masteraccount.rb', line 101 def SetAccountLimits(username, limits) Utilities.SetAccountLimits(@account_login, username, limits) end |
#SetAccountNotes(username, xml_notes) ⇒ Object
Set the account notes. This method expects properly formated xml. Be sure to escape any invalid characters.
106 107 108 109 110 |
# File 'lib/nvx/sds/masteraccount.rb', line 106 def SetAccountNotes(username, xml_notes) params = [APIParam.new("username", username), APIParam.new("xmlNotes", xml_notes)] Transport.execute_command_post(APICommand.SetAccountNotes, params, @account_login) end |
#SetChildAccountPassword(master_password, child_username, new_password) ⇒ Object
Changes the child password. The master account needs to reauthenticate with the system to change a childs password.
54 55 56 57 58 59 60 61 62 |
# File 'lib/nvx/sds/masteraccount.rb', line 54 def SetChildAccountPassword(master_password, child_username, new_password) # The master account needs to reauthenticate with the system to change a childs password. params = [APIParam.new("username", @account_login.username), APIParam.new("password", master_password), APIParam.new("appKey", @account_login.app_key), APIParam.new("childAccountUsername", child_username), APIParam.new("childAccountPassword", new_password)] Transport.execute_command_post(APICommand.SetChildAccountPassword, params, @account_login) end |