Class: Files::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/files.com/models/session.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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 = {}, options = {})
  @attributes = attributes || {}
  @options = options || {}
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



5
6
7
# File 'lib/files.com/models/session.rb', line 5

def attributes
  @attributes
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/files.com/models/session.rb', line 5

def options
  @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 = {}, options = {})
  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, options = Api.send_request("/sessions", :post, params, options)
  Session.new(response.data, options)
end

.delete(params = {}, options = {}) ⇒ Object



292
293
294
295
# File 'lib/files.com/models/session.rb', line 292

def self.delete(params = {}, options = {})
  response, _options = Api.send_request("/sessions", :delete, params, options)
  response.data
end

.destroy(params = {}, options = {}) ⇒ Object



297
298
299
# File 'lib/files.com/models/session.rb', line 297

def self.destroy(params = {}, options = {})
  delete(params, options)
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 = {}, options = {})
  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, _options = Api.send_request("/sessions/forgot", :post, params, options)
  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 = {}, options = {})
  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, _options = Api.send_request("/sessions/forgot/reset", :post, params, options)
  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 = {}, options = {})
  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, _options = Api.send_request("/sessions/forgot/validate", :post, params, options)
  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 = {}, options = {})
  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, options = Api.send_request("/sessions/oauth", :post, params, options)
  OauthRedirect.new(response.data, options)
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 = {}, options = {})
  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, options = Api.send_request("/sessions/pairing_key/#{params[:key]}", :post, params, options)
  PairedApiKey.new(response.data, options)
end

Instance Method Details

#allowed_2fa_method_smsObject

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_totpObject

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_u2fObject

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_yubiObject

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 = {}, options = {})
  Session.destroy(params, options.merge(session: self, session_id: nil))
end

#idObject

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

#languageObject

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_tokenObject

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 
  @attributes[:login_token]
end

#login_token=(value) ⇒ Object



38
39
40
# File 'lib/files.com/models/session.rb', line 38

def (value)
  @attributes[:login_token] = value
end

#login_token_domainObject

string - Domain to use with ‘login_token`.



43
44
45
# File 'lib/files.com/models/session.rb', line 43

def 
  @attributes[:login_token_domain]
end

#login_token_domain=(value) ⇒ Object



47
48
49
# File 'lib/files.com/models/session.rb', line 47

def (value)
  @attributes[:login_token_domain] = value
end

#max_dir_listing_sizeObject

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_regionsObject

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

#otpObject

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

#passwordObject

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_onlyObject

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_pathObject

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

#saveObject



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_idObject

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_requiredObject

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_disabledObject

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_neededObject

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_atObject

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

#usernameObject

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_ftpObject

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