Class: Files::Session
- Inherits:
-
Object
- Object
- Files::Session
- Defined in:
- lib/files.com/models/session.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
-
.create(params = {}, options = {}) ⇒ Object
Parameters: username - string - Username to sign in as password - string - Password for sign in otp - string - If this user has a 2FA device, provide its OTP or code here.
- .delete(params = {}, options = {}) ⇒ Object
- .destroy(params = {}, options = {}) ⇒ Object
-
.forgot(params = {}, options = {}) ⇒ Object
Parameters: email - string username - string.
-
.forgot_reset(params = {}, options = {}) ⇒ Object
Parameters: code (required) - string password (required) - string confirm_password - string interface - string locale - string otp - string.
-
.forgot_validate(params = {}, options = {}) ⇒ Object
Parameters: code (required) - string.
-
.oauth(params = {}, options = {}) ⇒ Object
Parameters: provider (required) - string state - string.
-
.pairing_key(key, params = {}, options = {}) ⇒ Object
Parameters: key (required) - string - The pairing key to reserve for login.
Instance Method Summary collapse
-
#allowed_2fa_method_sms ⇒ Object
boolean - Sent only if 2FA setup is needed.
- #allowed_2fa_method_sms=(value) ⇒ Object
-
#allowed_2fa_method_totp ⇒ Object
boolean - Sent only if 2FA setup is needed.
- #allowed_2fa_method_totp=(value) ⇒ Object
-
#allowed_2fa_method_u2f ⇒ Object
boolean - Sent only if 2FA setup is needed.
- #allowed_2fa_method_u2f=(value) ⇒ Object
-
#allowed_2fa_method_yubi ⇒ Object
boolean - Sent only if 2FA setup is needed.
- #allowed_2fa_method_yubi=(value) ⇒ Object
- #destroy(params = {}, options = {}) ⇒ Object
-
#id ⇒ Object
int64 - Session ID.
- #id=(value) ⇒ Object
-
#initialize(attributes = {}, options = {}) ⇒ Session
constructor
A new instance of Session.
-
#language ⇒ Object
string - Session language.
- #language=(value) ⇒ Object
-
#login_token ⇒ Object
string - Login token.
- #login_token=(value) ⇒ Object
-
#login_token_domain ⇒ Object
string - Domain to use with ‘login_token`.
- #login_token_domain=(value) ⇒ Object
-
#max_dir_listing_size ⇒ Object
int64 - Maximum number of files to retrieve per folder for a directory listing.
- #max_dir_listing_size=(value) ⇒ Object
-
#multiple_regions ⇒ Object
boolean - Can access multiple regions?.
- #multiple_regions=(value) ⇒ Object
-
#otp ⇒ Object
string - If this user has a 2FA device, provide its OTP or code here.
- #otp=(value) ⇒ Object
-
#password ⇒ Object
string - Password for sign in.
- #password=(value) ⇒ Object
-
#read_only ⇒ Object
boolean - Is this session read only?.
- #read_only=(value) ⇒ Object
-
#root_path ⇒ Object
string - Initial root path to start the user’s session in.
- #root_path=(value) ⇒ Object
- #save ⇒ Object
-
#site_id ⇒ Object
int64 - Site ID.
- #site_id=(value) ⇒ Object
-
#ssl_required ⇒ Object
boolean - Is SSL required for this user? (If so, ensure all your communications with this user use SSL.).
- #ssl_required=(value) ⇒ Object
-
#tls_disabled ⇒ Object
boolean - Is strong TLS disabled for this user? (If this is set to true, the site administrator has signaled that it is ok to use less secure TLS versions for this user.).
- #tls_disabled=(value) ⇒ Object
-
#two_factor_setup_needed ⇒ Object
boolean - If true, this user needs to add a Two Factor Authentication method before performing any further actions.
- #two_factor_setup_needed=(value) ⇒ Object
-
#use_provided_modified_at ⇒ Object
boolean - Allow the user to provide file/folder modified at dates? If false, the server will always use the current date/time.
- #use_provided_modified_at=(value) ⇒ Object
-
#username ⇒ Object
string - Username to sign in as.
- #username=(value) ⇒ Object
-
#windows_mode_ftp ⇒ Object
boolean - Does this user want to use Windows line-ending emulation? (CR vs CRLF).
- #windows_mode_ftp=(value) ⇒ Object
Constructor Details
#initialize(attributes = {}, options = {}) ⇒ Session
Returns a new instance of Session.
10 11 12 13 |
# File 'lib/files.com/models/session.rb', line 10 def initialize(attributes = {}, = {}) @attributes = attributes || {} @options = || {} end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
5 6 7 |
# File 'lib/files.com/models/session.rb', line 5 def attributes @attributes end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/files.com/models/session.rb', line 5 def @options end |
Class Method Details
.create(params = {}, options = {}) ⇒ Object
Parameters:
username - string - Username to sign in as
password - string - Password for sign in
otp - string - If this user has a 2FA device, provide its OTP or code here.
217 218 219 220 221 222 223 224 |
# File 'lib/files.com/models/session.rb', line 217 def self.create(params = {}, = {}) raise InvalidParameterError.new("Bad parameter: username must be an String") if params.dig(:username) and !params.dig(:username).is_a?(String) raise InvalidParameterError.new("Bad parameter: password must be an String") if params.dig(:password) and !params.dig(:password).is_a?(String) raise InvalidParameterError.new("Bad parameter: otp must be an String") if params.dig(:otp) and !params.dig(:otp).is_a?(String) response, = Api.send_request("/sessions", :post, params, ) Session.new(response.data, ) end |
.delete(params = {}, options = {}) ⇒ Object
292 293 294 295 |
# File 'lib/files.com/models/session.rb', line 292 def self.delete(params = {}, = {}) response, = Api.send_request("/sessions", :delete, params, ) response.data end |
.destroy(params = {}, options = {}) ⇒ Object
297 298 299 |
# File 'lib/files.com/models/session.rb', line 297 def self.destroy(params = {}, = {}) delete(params, ) end |
.forgot(params = {}, options = {}) ⇒ Object
Parameters:
email - string
username - string
260 261 262 263 264 265 266 |
# File 'lib/files.com/models/session.rb', line 260 def self.forgot(params = {}, = {}) raise InvalidParameterError.new("Bad parameter: email must be an String") if params.dig(:email) and !params.dig(:email).is_a?(String) raise InvalidParameterError.new("Bad parameter: username must be an String") if params.dig(:username) and !params.dig(:username).is_a?(String) response, = Api.send_request("/sessions/forgot", :post, params, ) response.data end |
.forgot_reset(params = {}, options = {}) ⇒ Object
Parameters:
code (required) - string
password (required) - string
confirm_password - string
interface - string
locale - string
otp - string
233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/files.com/models/session.rb', line 233 def self.forgot_reset(params = {}, = {}) raise InvalidParameterError.new("Bad parameter: code must be an String") if params.dig(:code) and !params.dig(:code).is_a?(String) raise InvalidParameterError.new("Bad parameter: password must be an String") if params.dig(:password) and !params.dig(:password).is_a?(String) raise InvalidParameterError.new("Bad parameter: confirm_password must be an String") if params.dig(:confirm_password) and !params.dig(:confirm_password).is_a?(String) raise InvalidParameterError.new("Bad parameter: interface must be an String") if params.dig(:interface) and !params.dig(:interface).is_a?(String) raise InvalidParameterError.new("Bad parameter: locale must be an String") if params.dig(:locale) and !params.dig(:locale).is_a?(String) raise InvalidParameterError.new("Bad parameter: otp must be an String") if params.dig(:otp) and !params.dig(:otp).is_a?(String) raise MissingParameterError.new("Parameter missing: code") unless params.dig(:code) raise MissingParameterError.new("Parameter missing: password") unless params.dig(:password) response, = Api.send_request("/sessions/forgot/reset", :post, params, ) response.data end |
.forgot_validate(params = {}, options = {}) ⇒ Object
Parameters:
code (required) - string
249 250 251 252 253 254 255 |
# File 'lib/files.com/models/session.rb', line 249 def self.forgot_validate(params = {}, = {}) raise InvalidParameterError.new("Bad parameter: code must be an String") if params.dig(:code) and !params.dig(:code).is_a?(String) raise MissingParameterError.new("Parameter missing: code") unless params.dig(:code) response, = Api.send_request("/sessions/forgot/validate", :post, params, ) response.data end |
.oauth(params = {}, options = {}) ⇒ Object
Parameters:
provider (required) - string
state - string
283 284 285 286 287 288 289 290 |
# File 'lib/files.com/models/session.rb', line 283 def self.oauth(params = {}, = {}) raise InvalidParameterError.new("Bad parameter: provider must be an String") if params.dig(:provider) and !params.dig(:provider).is_a?(String) raise InvalidParameterError.new("Bad parameter: state must be an String") if params.dig(:state) and !params.dig(:state).is_a?(String) raise MissingParameterError.new("Parameter missing: provider") unless params.dig(:provider) response, = Api.send_request("/sessions/oauth", :post, params, ) OauthRedirect.new(response.data, ) end |
.pairing_key(key, params = {}, options = {}) ⇒ Object
Parameters:
key (required) - string - The pairing key to reserve for login. Cannot be reused
270 271 272 273 274 275 276 277 278 |
# File 'lib/files.com/models/session.rb', line 270 def self.pairing_key(key, params = {}, = {}) params ||= {} params[:key] = key raise InvalidParameterError.new("Bad parameter: key must be an String") if params.dig(:key) and !params.dig(:key).is_a?(String) raise MissingParameterError.new("Parameter missing: key") unless params.dig(:key) response, = Api.send_request("/sessions/pairing_key/#{params[:key]}", :post, params, ) PairedApiKey.new(response.data, ) end |
Instance Method Details
#allowed_2fa_method_sms ⇒ Object
boolean - Sent only if 2FA setup is needed. Is SMS two factor authentication allowed?
124 125 126 |
# File 'lib/files.com/models/session.rb', line 124 def allowed_2fa_method_sms @attributes[:allowed_2fa_method_sms] end |
#allowed_2fa_method_sms=(value) ⇒ Object
128 129 130 |
# File 'lib/files.com/models/session.rb', line 128 def allowed_2fa_method_sms=(value) @attributes[:allowed_2fa_method_sms] = value end |
#allowed_2fa_method_totp ⇒ Object
boolean - Sent only if 2FA setup is needed. Is TOTP two factor authentication allowed?
133 134 135 |
# File 'lib/files.com/models/session.rb', line 133 def allowed_2fa_method_totp @attributes[:allowed_2fa_method_totp] end |
#allowed_2fa_method_totp=(value) ⇒ Object
137 138 139 |
# File 'lib/files.com/models/session.rb', line 137 def allowed_2fa_method_totp=(value) @attributes[:allowed_2fa_method_totp] = value end |
#allowed_2fa_method_u2f ⇒ Object
boolean - Sent only if 2FA setup is needed. Is U2F two factor authentication allowed?
142 143 144 |
# File 'lib/files.com/models/session.rb', line 142 def allowed_2fa_method_u2f @attributes[:allowed_2fa_method_u2f] end |
#allowed_2fa_method_u2f=(value) ⇒ Object
146 147 148 |
# File 'lib/files.com/models/session.rb', line 146 def allowed_2fa_method_u2f=(value) @attributes[:allowed_2fa_method_u2f] = value end |
#allowed_2fa_method_yubi ⇒ Object
boolean - Sent only if 2FA setup is needed. Is Yubikey two factor authentication allowed?
151 152 153 |
# File 'lib/files.com/models/session.rb', line 151 def allowed_2fa_method_yubi @attributes[:allowed_2fa_method_yubi] end |
#allowed_2fa_method_yubi=(value) ⇒ Object
155 156 157 |
# File 'lib/files.com/models/session.rb', line 155 def allowed_2fa_method_yubi=(value) @attributes[:allowed_2fa_method_yubi] = value end |
#destroy(params = {}, options = {}) ⇒ Object
6 7 8 |
# File 'lib/files.com/models/session.rb', line 6 def destroy(params = {}, = {}) Session.destroy(params, .merge(session: self, session_id: nil)) end |
#id ⇒ Object
int64 - Session ID
16 17 18 |
# File 'lib/files.com/models/session.rb', line 16 def id @attributes[:id] end |
#id=(value) ⇒ Object
20 21 22 |
# File 'lib/files.com/models/session.rb', line 20 def id=(value) @attributes[:id] = value end |
#language ⇒ Object
string - Session language
25 26 27 |
# File 'lib/files.com/models/session.rb', line 25 def language @attributes[:language] end |
#language=(value) ⇒ Object
29 30 31 |
# File 'lib/files.com/models/session.rb', line 29 def language=(value) @attributes[:language] = value end |
#login_token ⇒ Object
string - Login token. If set, this token will allow your user to log in via browser at the domain in ‘login_token_domain`.
34 35 36 |
# File 'lib/files.com/models/session.rb', line 34 def login_token @attributes[:login_token] end |
#login_token=(value) ⇒ Object
38 39 40 |
# File 'lib/files.com/models/session.rb', line 38 def login_token=(value) @attributes[:login_token] = value end |
#login_token_domain ⇒ Object
string - Domain to use with ‘login_token`.
43 44 45 |
# File 'lib/files.com/models/session.rb', line 43 def login_token_domain @attributes[:login_token_domain] end |
#login_token_domain=(value) ⇒ Object
47 48 49 |
# File 'lib/files.com/models/session.rb', line 47 def login_token_domain=(value) @attributes[:login_token_domain] = value end |
#max_dir_listing_size ⇒ Object
int64 - Maximum number of files to retrieve per folder for a directory listing. This is based on the user’s plan.
52 53 54 |
# File 'lib/files.com/models/session.rb', line 52 def max_dir_listing_size @attributes[:max_dir_listing_size] end |
#max_dir_listing_size=(value) ⇒ Object
56 57 58 |
# File 'lib/files.com/models/session.rb', line 56 def max_dir_listing_size=(value) @attributes[:max_dir_listing_size] = value end |
#multiple_regions ⇒ Object
boolean - Can access multiple regions?
61 62 63 |
# File 'lib/files.com/models/session.rb', line 61 def multiple_regions @attributes[:multiple_regions] end |
#multiple_regions=(value) ⇒ Object
65 66 67 |
# File 'lib/files.com/models/session.rb', line 65 def multiple_regions=(value) @attributes[:multiple_regions] = value end |
#otp ⇒ Object
string - If this user has a 2FA device, provide its OTP or code here.
196 197 198 |
# File 'lib/files.com/models/session.rb', line 196 def otp @attributes[:otp] end |
#otp=(value) ⇒ Object
200 201 202 |
# File 'lib/files.com/models/session.rb', line 200 def otp=(value) @attributes[:otp] = value end |
#password ⇒ Object
string - Password for sign in
187 188 189 |
# File 'lib/files.com/models/session.rb', line 187 def password @attributes[:password] end |
#password=(value) ⇒ Object
191 192 193 |
# File 'lib/files.com/models/session.rb', line 191 def password=(value) @attributes[:password] = value end |
#read_only ⇒ Object
boolean - Is this session read only?
70 71 72 |
# File 'lib/files.com/models/session.rb', line 70 def read_only @attributes[:read_only] end |
#read_only=(value) ⇒ Object
74 75 76 |
# File 'lib/files.com/models/session.rb', line 74 def read_only=(value) @attributes[:read_only] = value end |
#root_path ⇒ Object
string - Initial root path to start the user’s session in.
79 80 81 |
# File 'lib/files.com/models/session.rb', line 79 def root_path @attributes[:root_path] end |
#root_path=(value) ⇒ Object
83 84 85 |
# File 'lib/files.com/models/session.rb', line 83 def root_path=(value) @attributes[:root_path] = value end |
#save ⇒ Object
204 205 206 207 208 209 210 211 |
# File 'lib/files.com/models/session.rb', line 204 def save if @attributes[:id] raise NotImplementedError.new("The Session object doesn't support updates.") else new_obj = Session.create(@attributes, @options) @attributes = new_obj.attributes end end |
#site_id ⇒ Object
int64 - Site ID
88 89 90 |
# File 'lib/files.com/models/session.rb', line 88 def site_id @attributes[:site_id] end |
#site_id=(value) ⇒ Object
92 93 94 |
# File 'lib/files.com/models/session.rb', line 92 def site_id=(value) @attributes[:site_id] = value end |
#ssl_required ⇒ Object
boolean - Is SSL required for this user? (If so, ensure all your communications with this user use SSL.)
97 98 99 |
# File 'lib/files.com/models/session.rb', line 97 def ssl_required @attributes[:ssl_required] end |
#ssl_required=(value) ⇒ Object
101 102 103 |
# File 'lib/files.com/models/session.rb', line 101 def ssl_required=(value) @attributes[:ssl_required] = value end |
#tls_disabled ⇒ Object
boolean - Is strong TLS disabled for this user? (If this is set to true, the site administrator has signaled that it is ok to use less secure TLS versions for this user.)
106 107 108 |
# File 'lib/files.com/models/session.rb', line 106 def tls_disabled @attributes[:tls_disabled] end |
#tls_disabled=(value) ⇒ Object
110 111 112 |
# File 'lib/files.com/models/session.rb', line 110 def tls_disabled=(value) @attributes[:tls_disabled] = value end |
#two_factor_setup_needed ⇒ Object
boolean - If true, this user needs to add a Two Factor Authentication method before performing any further actions.
115 116 117 |
# File 'lib/files.com/models/session.rb', line 115 def two_factor_setup_needed @attributes[:two_factor_setup_needed] end |
#two_factor_setup_needed=(value) ⇒ Object
119 120 121 |
# File 'lib/files.com/models/session.rb', line 119 def two_factor_setup_needed=(value) @attributes[:two_factor_setup_needed] = value end |
#use_provided_modified_at ⇒ Object
boolean - Allow the user to provide file/folder modified at dates? If false, the server will always use the current date/time.
160 161 162 |
# File 'lib/files.com/models/session.rb', line 160 def use_provided_modified_at @attributes[:use_provided_modified_at] end |
#use_provided_modified_at=(value) ⇒ Object
164 165 166 |
# File 'lib/files.com/models/session.rb', line 164 def use_provided_modified_at=(value) @attributes[:use_provided_modified_at] = value end |
#username ⇒ Object
string - Username to sign in as
178 179 180 |
# File 'lib/files.com/models/session.rb', line 178 def username @attributes[:username] end |
#username=(value) ⇒ Object
182 183 184 |
# File 'lib/files.com/models/session.rb', line 182 def username=(value) @attributes[:username] = value end |
#windows_mode_ftp ⇒ Object
boolean - Does this user want to use Windows line-ending emulation? (CR vs CRLF)
169 170 171 |
# File 'lib/files.com/models/session.rb', line 169 def windows_mode_ftp @attributes[:windows_mode_ftp] end |
#windows_mode_ftp=(value) ⇒ Object
173 174 175 |
# File 'lib/files.com/models/session.rb', line 173 def windows_mode_ftp=(value) @attributes[:windows_mode_ftp] = value end |