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.



11
12
13
14
# File 'lib/files.com/models/session.rb', line 11

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.
partial_session_id - string - Identifier for a partially-completed login


104
105
106
107
108
109
110
111
112
# File 'lib/files.com/models/session.rb', line 104

def self.create(params = {}, options = {})
  raise InvalidParameterError.new("Bad parameter: username must be an String") if params[:username] and !params[:username].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: password must be an String") if params[:password] and !params[:password].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: otp must be an String") if params[:otp] and !params[:otp].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: partial_session_id must be an String") if params[:partial_session_id] and !params[:partial_session_id].is_a?(String)

  response, options = Api.send_request("/sessions", :post, params, options)
  Session.new(response.data, options)
end

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



114
115
116
117
# File 'lib/files.com/models/session.rb', line 114

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

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



119
120
121
122
# File 'lib/files.com/models/session.rb', line 119

def self.destroy(params = {}, options = {})
  delete(params, options)
  nil
end

Instance Method Details

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



7
8
9
# File 'lib/files.com/models/session.rb', line 7

def destroy(params = {}, options = {})
  Session.destroy(params, options.merge(session: self, session_id: nil))
end

#idObject

string - Session ID



17
18
19
# File 'lib/files.com/models/session.rb', line 17

def id
  @attributes[:id]
end

#id=(value) ⇒ Object



21
22
23
# File 'lib/files.com/models/session.rb', line 21

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

#languageObject

string - Session language



26
27
28
# File 'lib/files.com/models/session.rb', line 26

def language
  @attributes[:language]
end

#language=(value) ⇒ Object



30
31
32
# File 'lib/files.com/models/session.rb', line 30

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

#otpObject

string - If this user has a 2FA device, provide its OTP or code here.



71
72
73
# File 'lib/files.com/models/session.rb', line 71

def otp
  @attributes[:otp]
end

#otp=(value) ⇒ Object



75
76
77
# File 'lib/files.com/models/session.rb', line 75

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

#partial_session_idObject

string - Identifier for a partially-completed login



80
81
82
# File 'lib/files.com/models/session.rb', line 80

def partial_session_id
  @attributes[:partial_session_id]
end

#partial_session_id=(value) ⇒ Object



84
85
86
# File 'lib/files.com/models/session.rb', line 84

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

#passwordObject

string - Password for sign in



62
63
64
# File 'lib/files.com/models/session.rb', line 62

def password
  @attributes[:password]
end

#password=(value) ⇒ Object



66
67
68
# File 'lib/files.com/models/session.rb', line 66

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

#read_onlyObject

boolean - Is this session read only?



35
36
37
# File 'lib/files.com/models/session.rb', line 35

def read_only
  @attributes[:read_only]
end

#read_only=(value) ⇒ Object



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

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

#saveObject



88
89
90
91
92
93
94
95
96
97
# File 'lib/files.com/models/session.rb', line 88

def save
  if @attributes[:id]
    raise NotImplementedError.new("The Session object doesn't support updates.")
  else
    new_obj = Session.create(@attributes, @options)
  end

  @attributes = new_obj.attributes
  true
end

#sftp_insecure_ciphersObject

boolean - Are insecure SFTP ciphers allowed for this user? (If this is set to true, the site administrator has signaled that it is ok to use less secure SSH ciphers for this user.)



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

def sftp_insecure_ciphers
  @attributes[:sftp_insecure_ciphers]
end

#sftp_insecure_ciphers=(value) ⇒ Object



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

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

#usernameObject

string - Username to sign in as



53
54
55
# File 'lib/files.com/models/session.rb', line 53

def username
  @attributes[:username]
end

#username=(value) ⇒ Object



57
58
59
# File 'lib/files.com/models/session.rb', line 57

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