Class: NVX::SDS::Session
- Inherits:
-
Object
- Object
- NVX::SDS::Session
- Defined in:
- lib/nvx/sds/session.rb
Overview
The session is the primary object for interaction with the Gem. You will use the session to get the root folder and subsiquent IMFS objects and Accounting objects.
Instance Method Summary collapse
-
#account_login ⇒ Object
Gets the account login object.
-
#account_login=(account_login) ⇒ Object
Sets the account login object.
-
#AudioTranscode(number_of_frames, frame_rate, number_of_channels) ⇒ Object
Converts an audio to another format.
-
#ChangePassword(old_password, new_password) ⇒ Object
Changes the password of the current session account.
-
#DeleteFiles(file_paths_to_delete) ⇒ Object
Deletes all the files from an array of strings passed.
-
#DeleteFolders(folder_paths_to_delete) ⇒ Object
Deletes all the folders from an array of strings passed.
-
#GetAccountInfo ⇒ Object
Gets the account information as an AccountInfo object from the current session user.
-
#GetAccountLimits ⇒ Object
Gets the account limits as an array of AccountLimit objects.
-
#GetAccountUsage ⇒ Object
Gets the account usage as an array of AccountFeatureUsage objects.
-
#GetDownloadLinks(file_paths, expiration_seconds, restricted_ip = nil) ⇒ Object
Gets a public download link that will expire after expiration_seconds.
-
#GetFolder(path, page_number = 1, page_size = 500, folder_sort_code = nil, should_sort_descending = true) ⇒ Object
Gets a specific folder based on the supplied path.
-
#GetMasterAccount ⇒ Object
Returns the master account object.
-
#GetRootFolder(page_number = 1, page_size = 500, folder_sort_code = nil, should_sort_descending = true) ⇒ Object
Gets the root folder.
-
#initialize(appKey, username, appName, password = nil, session_token = nil) ⇒ Session
constructor
Creates a new session object.
-
#ListHostedItems(page_number = 1, page_size = 500) ⇒ Object
Returns an array of hosted files and folders that have been hosted.
-
#Logout ⇒ Object
Logs the current user out ending the session.
-
#SearchFileSystem(search_term, file_type = nil, min_created_date = Time.now - (24 * 60 * 60 * (365 * 10)), max_created_date = Time.now + (24 * 60 * 60), max_results = 500, min_file_size = 0, max_file_size = 0, username = nil) ⇒ Object
Searches given the parameters through the entire file system.
-
#SearchMetadata(search_term, search_key, max_results = 500, username = nil) ⇒ Object
Searches Metadata for specific values.
-
#SearchTags(search_term, max_results = 500, username = nil) ⇒ Object
Searches tags for specific values.
-
#SetAccountInfo(first_name, last_name, middle_initial, phone_number, email_address, email_format, address_line1, address_line2, city, state, country, postal_code) ⇒ Object
Sets the account information for the current session user.
-
#Sideload(url, destination_file_path, callback_url = nil) ⇒ Object
Saves a url to the file path specified and optionally calls back to a url.
-
#VideoTranscode(src_file_path, dest_file_path, callback_url, number_of_frames, frame_rate, aspect_ratio, width, height) ⇒ Object
Converts a video to another format.
Constructor Details
#initialize(appKey, username, appName, password = nil, session_token = nil) ⇒ Session
Creates a new session object. The password is optional only when called to impersonate a child account. when creating a new session use the context: session = Session.new(“APPKEY”, “USERNAME”, “APPNAME”, “PASSWORD”)
21 22 23 24 |
# File 'lib/nvx/sds/session.rb', line 21 def initialize(appKey, username, appName, password = nil, session_token = nil) @account_login = AccountLogin.new(appKey, username, appName, password, session_token) @account_login.Login if session_token.nil? end |
Instance Method Details
#account_login ⇒ Object
Gets the account login object.
27 28 29 |
# File 'lib/nvx/sds/session.rb', line 27 def account_login @account_login end |
#account_login=(account_login) ⇒ Object
Sets the account login object.
32 33 34 |
# File 'lib/nvx/sds/session.rb', line 32 def account_login=(account_login) @account_login=account_login end |
#AudioTranscode(number_of_frames, frame_rate, number_of_channels) ⇒ Object
Converts an audio to another format
184 185 186 187 188 189 190 191 192 193 |
# File 'lib/nvx/sds/session.rb', line 184 def AudioTranscode(number_of_frames, frame_rate, number_of_channels) params = [APIParam.new("srcFilePath", src_file_path ), APIParam.new("destFilePath", dest_file_path), APIParam.new("callbackURL", callback_url), APIParam.new("numberOfFrames", number_of_frames), APIParam.new("frameRate", frame_rate), APIParam.new("numberOfChannels", number_of_channels)] Transport.execute_command_post(APICommand.AudioTranscode, params, @account_login) end |
#ChangePassword(old_password, new_password) ⇒ Object
Changes the password of the current session account.
43 44 45 46 47 48 49 50 |
# File 'lib/nvx/sds/session.rb', line 43 def ChangePassword(old_password, new_password) params = [APIParam.new("appKey", @account_login.app_key ), APIParam.new("username", @account_login.username), APIParam.new("oldPassword", old_password), APIParam.new("newPassword", new_password)] Transport.execute_command_post(APICommand.ChangePassword, params, @account_login) end |
#DeleteFiles(file_paths_to_delete) ⇒ Object
Deletes all the files from an array of strings passed.
243 244 245 246 247 248 249 |
# File 'lib/nvx/sds/session.rb', line 243 def DeleteFiles(file_paths_to_delete) params = Array.new file_paths_to_delete.each do |path| params << APIParam.new("filePath", path) end Transport.execute_command_post(APICommand.DeleteFiles, params, @account_login) end |
#DeleteFolders(folder_paths_to_delete) ⇒ Object
Deletes all the folders from an array of strings passed. **THIS WILL REMOVE ALL SUB FOLDERS AND FILES AS WELL.
252 253 254 255 256 257 258 |
# File 'lib/nvx/sds/session.rb', line 252 def DeleteFolders(folder_paths_to_delete) params = Array.new folder_paths_to_delete.each do |path| params << APIParam.new("folderPath", path) end Transport.execute_command_post(APICommand.DeleteFolders, params, @account_login) end |
#GetAccountInfo ⇒ Object
Gets the account information as an AccountInfo object from the current session user.
159 160 161 |
# File 'lib/nvx/sds/session.rb', line 159 def GetAccountInfo Utilities.GetAccountInfo(@account_login, @account_login.username) end |
#GetAccountLimits ⇒ Object
Gets the account limits as an array of AccountLimit objects.
164 165 166 |
# File 'lib/nvx/sds/session.rb', line 164 def GetAccountLimits Utilities.GetAccountLimits(@account_login, @account_login.username) end |
#GetAccountUsage ⇒ Object
Gets the account usage as an array of AccountFeatureUsage objects.
169 170 171 |
# File 'lib/nvx/sds/session.rb', line 169 def GetAccountUsage Utilities.GetAccountUsage(@account_login, @account_login.username) end |
#GetDownloadLinks(file_paths, expiration_seconds, restricted_ip = nil) ⇒ Object
Gets a public download link that will expire after expiration_seconds
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
# File 'lib/nvx/sds/session.rb', line 212 def GetDownloadLinks(file_paths, expiration_seconds, restricted_ip = nil) params = [APIParam.new("expiration", expiration_seconds.to_s)] file_paths.each do |path| params << APIParam.new("filePath", path) end params << APIParam.new("restricted_ip", restricted_ip) if !restricted_ip.nil? doc = Transport.execute_command_post(APICommand.GetDownloadLinks, params, @account_login) download_links = Array.new #if there is any metadata loop through if doc.root.elements["//Response/Download/DownloadURL"] doc.root.elements.each("//Response/Download/DownloadURL") do |link| download_links << link.get_text.value end end return download_links end |
#GetFolder(path, page_number = 1, page_size = 500, folder_sort_code = nil, should_sort_descending = true) ⇒ Object
Gets a specific folder based on the supplied path.
59 60 61 62 63 64 65 |
# File 'lib/nvx/sds/session.rb', line 59 def GetFolder(path, page_number = 1, page_size = 500, folder_sort_code = nil, should_sort_descending = true) if path.index("//").nil? path = @account_login.root_path + path end folder = Folder.ListFolder(@account_login, path, page_number, page_size, folder_sort_code, should_sort_descending) return folder end |
#GetMasterAccount ⇒ Object
Returns the master account object.
266 267 268 |
# File 'lib/nvx/sds/session.rb', line 266 def GetMasterAccount MasterAccount.new(self, @account_login) end |
#GetRootFolder(page_number = 1, page_size = 500, folder_sort_code = nil, should_sort_descending = true) ⇒ Object
Gets the root folder. You can use this to access all of the files and folders.
53 54 55 56 |
# File 'lib/nvx/sds/session.rb', line 53 def GetRootFolder(page_number = 1, page_size = 500, folder_sort_code = nil, should_sort_descending = true) folder = Folder.ListFolder(@account_login, @account_login.root_path, page_number, page_size, folder_sort_code, should_sort_descending) return folder end |
#ListHostedItems(page_number = 1, page_size = 500) ⇒ Object
Returns an array of hosted files and folders that have been hosted.
261 262 263 |
# File 'lib/nvx/sds/session.rb', line 261 def ListHostedItems(page_number = 1, page_size = 500) HostedItem.ListHostedItems(@account_login, page_number, page_size) end |
#Logout ⇒ Object
Logs the current user out ending the session.
37 38 39 40 |
# File 'lib/nvx/sds/session.rb', line 37 def Logout result = Transport.execute_command_post(APICommand.Logout, nil, @account_login) @account_login = nil end |
#SearchFileSystem(search_term, file_type = nil, min_created_date = Time.now - (24 * 60 * 60 * (365 * 10)), max_created_date = Time.now + (24 * 60 * 60), max_results = 500, min_file_size = 0, max_file_size = 0, username = nil) ⇒ Object
Searches given the parameters through the entire file system. search_term - The search string to look for files and folders. The ‘*’ character may be used at the beginning or end of the string to support wild card searches. Valid File Types:
*Unassigned *Document *Executable *Audio *Video *Image
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/nvx/sds/session.rb', line 78 def SearchFileSystem(search_term, file_type = nil, min_created_date = Time.now - (24 * 60 * 60 * (365 * 10)), # Ten years ago max_created_date = Time.now + (24 * 60 * 60), # Tomorrow max_results = 500, min_file_size = 0, max_file_size = 0, username=nil) converted_min = min_created_date.month.to_s + "/" + min_created_date.day.to_s + "/" + min_created_date.year.to_s converted_max = max_created_date.month.to_s + "/" + max_created_date.day.to_s + "/" + max_created_date.year.to_s username = @account_login.username if username == nil params = [APIParam.new("searchTerm", search_term), APIParam.new("username", username), APIParam.new("minCreatedDate", converted_min), APIParam.new("maxCreatedDate", converted_max), APIParam.new("maxResults", max_results), APIParam.new("minFileSize", min_file_size), APIParam.new("maxFileSize", max_file_size)] params << APIParam.new("fileType", file_type) if !file_type.nil? doc = Transport.execute_command_post(APICommand.SearchFileSystem, params, @account_login) search_results = Array.new if doc.root.elements["//Response/SearchResults/Item"] doc.root.elements.each("//Response/SearchResults/Item") do |search_item| search_results << SearchItem.new(search_item.to_s) end end return search_results end |
#SearchMetadata(search_term, search_key, max_results = 500, username = nil) ⇒ Object
Searches Metadata for specific values. search_term - The metadata value you are looking for. The ‘*’ character may be used at the beginning or end of the string to support wild card searches. search_key - The key that will be searched, examples of this would be height, width, duration or any custom metadata keys.
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/nvx/sds/session.rb', line 113 def SearchMetadata(search_term, search_key, max_results = 500, username=nil) username = @account_login.username if username == nil params = [APIParam.new("searchTerm", search_term), APIParam.new("searchKey", search_key), APIParam.new("username", username), APIParam.new("maxResults", max_results)] doc = Transport.execute_command_post(APICommand.SearchMetadata, params, @account_login) search_results = Array.new if doc.root.elements["//Response/SearchResults/Item"] doc.root.elements.each("//Response/SearchResults/Item") do |search_item| search_results << SearchItem.new(search_item.to_s) end end return search_results end |
#SearchTags(search_term, max_results = 500, username = nil) ⇒ Object
Searches tags for specific values. search_term - The metadata value you are looking for. The ‘*’ character may be used at the beginning or end of the string to support wild card searches.
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/nvx/sds/session.rb', line 137 def SearchTags(search_term, max_results = 500, username=nil) username = @account_login.username if username == nil params = [APIParam.new("searchTerm", search_term), APIParam.new("username", username), APIParam.new("maxResults", max_results)] doc = Transport.execute_command_post(APICommand.SearchTags, params, @account_login) search_results = Array.new if doc.root.elements["//Response/SearchResults/Item"] doc.root.elements.each("//Response/SearchResults/Item") do |search_item| search_results << SearchItem.new(search_item.to_s) end end return search_results end |
#SetAccountInfo(first_name, last_name, middle_initial, phone_number, email_address, email_format, address_line1, address_line2, city, state, country, postal_code) ⇒ Object
Sets the account information for the current session user.
174 175 176 177 178 179 180 181 |
# File 'lib/nvx/sds/session.rb', line 174 def SetAccountInfo(first_name, last_name, middle_initial, phone_number, email_address, email_format, address_line1, address_line2, city, state, country, postal_code) Utilities.SetAccountInfo(@account_login, @account_login.username, first_name, last_name, middle_initial, phone_number, email_address, email_format, address_line1, address_line2, city, state, country, postal_code) end |
#Sideload(url, destination_file_path, callback_url = nil) ⇒ Object
Saves a url to the file path specified and optionally calls back to a url.
233 234 235 236 237 238 239 |
# File 'lib/nvx/sds/session.rb', line 233 def Sideload(url, destination_file_path, callback_url = nil) params = [APIParam.new("targetUrl", url), APIParam.new("destFilePath", destination_file_path)] params << APIParam.new("callbackUrl", callback_url) if !callback_url.nil? Transport.execute_command_post(APICommand.Sideload, params, @account_login) end |
#VideoTranscode(src_file_path, dest_file_path, callback_url, number_of_frames, frame_rate, aspect_ratio, width, height) ⇒ Object
Converts a video to another format
196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/nvx/sds/session.rb', line 196 def VideoTranscode(src_file_path, dest_file_path, callback_url, number_of_frames, frame_rate, aspect_ratio, width, height) params = [APIParam.new("srcFilePath", src_file_path), APIParam.new("destFilePath", dest_file_path), APIParam.new("callbackURL", callback_url), APIParam.new("frameRate", frame_rate), APIParam.new("aspectRatio", aspect_ratio), APIParam.new("numberOfFrames", number_of_frames), APIParam.new("width", width), APIParam.new("height", height)] Transport.execute_command_post(APICommand.VideoTranscode, params, @account_login) end |