Class: Files::TwoFactorAuthenticationMethod

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}, options = {}) ⇒ TwoFactorAuthenticationMethod

Returns a new instance of TwoFactorAuthenticationMethod.



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

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/two_factor_authentication_method.rb', line 5

def attributes
  @attributes
end

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

Class Method Details

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

Parameters:

method_type (required) - string - Type of 2fa
name - string - 2fa method name
phone_number - string - 2fa phone number (if SMS)
bypass_for_ftp_sftp_dav - boolean - Set true to skip checking this 2FA method when using FTP, SFTP, and DAV


197
198
199
200
201
202
203
204
205
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 197

def self.create(params = {}, options = {})
  raise InvalidParameterError.new("Bad parameter: method_type must be an String") if params[:method_type] and !params[:method_type].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: name must be an String") if params[:name] and !params[:name].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: phone_number must be an String") if params[:phone_number] and !params[:phone_number].is_a?(String)
  raise MissingParameterError.new("Parameter missing: method_type") unless params[:method_type]

  response, options = Api.send_request("/2fa", :post, params, options)
  TwoFactorAuthenticationMethod.new(response.data, options)
end

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



214
215
216
217
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 214

def self.create_export(params = {}, options = {})
  response, options = Api.send_request("/2fa/create_export", :post, params, options)
  Export.new(response.data, options)
end

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



235
236
237
238
239
240
241
242
243
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 235

def self.delete(id, params = {}, options = {})
  params ||= {}
  params[:id] = id
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: id") unless params[:id]

  Api.send_request("/2fa/#{params[:id]}", :delete, params, options)
  nil
end

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



245
246
247
248
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 245

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

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

Parameters:

cursor - string - Used for pagination.  When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`.  Send one of those cursor value here to resume an existing list from the next available record.  Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination.
per_page - int64 - Number of records to show per page.  (Max: 10000, 1,000 or less is recommended).


183
184
185
186
187
188
189
190
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 183

def self.get(params = {}, options = {})
  raise InvalidParameterError.new("Bad parameter: cursor must be an String") if params[:cursor] and !params[:cursor].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: per_page must be an Integer") if params[:per_page] and !params[:per_page].is_a?(Integer)

  List.new(TwoFactorAuthenticationMethod, params) do
    Api.send_request("/2fa", :get, params, options)
  end
end

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

Parameters:

webauthn_only - boolean - Set to `true` to only generate an OTP for Webauthn keys and skip things like SMS.


209
210
211
212
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 209

def self.send_code(params = {}, options = {})
  response, options = Api.send_request("/2fa/send_code", :post, params, options)
  WebauthnSignRequest.new(response.data, options)
end

.update(id, params = {}, options = {}) ⇒ Object

Parameters:

otp - string - Current value of OTP, Yubikey string, or Webauthn response value.
name - string - 2fa method name
bypass_for_ftp_sftp_dav - boolean - Set true to skip checking this 2FA method when using FTP, SFTP, and DAV


223
224
225
226
227
228
229
230
231
232
233
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 223

def self.update(id, params = {}, options = {})
  params ||= {}
  params[:id] = id
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: otp must be an String") if params[:otp] and !params[:otp].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: name must be an String") if params[:name] and !params[:name].is_a?(String)
  raise MissingParameterError.new("Parameter missing: id") unless params[:id]

  response, options = Api.send_request("/2fa/#{params[:id]}", :patch, params, options)
  TwoFactorAuthenticationMethod.new(response.data, options)
end

Instance Method Details

#bypass_for_ftp_sftp_davObject

boolean - Set true to skip checking this 2FA method when using FTP, SFTP, and DAV



121
122
123
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 121

def bypass_for_ftp_sftp_dav
  @attributes[:bypass_for_ftp_sftp_dav]
end

#bypass_for_ftp_sftp_dav=(value) ⇒ Object



125
126
127
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 125

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

#delete(params = {}) ⇒ Object



154
155
156
157
158
159
160
161
162
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 154

def delete(params = {})
  params ||= {}
  params[:id] = @attributes[:id]
  raise MissingParameterError.new("Current object doesn't have a id") unless @attributes[:id]
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: id") unless params[:id]

  Api.send_request("/2fa/#{@attributes[:id]}", :delete, params, @options)
end

#destroy(params = {}) ⇒ Object



164
165
166
167
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 164

def destroy(params = {})
  delete(params)
  nil
end

#idObject

int64 - 2fa ID



13
14
15
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 13

def id
  @attributes[:id]
end

#id=(value) ⇒ Object



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

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

#method_typeObject

string - Type of 2fa



31
32
33
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 31

def method_type
  @attributes[:method_type]
end

#method_type=(value) ⇒ Object



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

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

#nameObject

string - 2fa method name



22
23
24
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 22

def name
  @attributes[:name]
end

#name=(value) ⇒ Object



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

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

#otpObject

string - Current value of OTP, Yubikey string, or Webauthn response value.



130
131
132
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 130

def otp
  @attributes[:otp]
end

#otp=(value) ⇒ Object



134
135
136
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 134

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

#phone_numberObject

string - 2fa phone number (if SMS)



40
41
42
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 40

def phone_number
  @attributes[:phone_number]
end

#phone_number=(value) ⇒ Object



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

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

#phone_number_countryObject

string - 2fa phone number country (if SMS)



49
50
51
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 49

def phone_number_country
  @attributes[:phone_number_country]
end

#phone_number_country=(value) ⇒ Object



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

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

#phone_number_national_formatObject

string - 2fa phone number national format (if SMS)



58
59
60
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 58

def phone_number_national_format
  @attributes[:phone_number_national_format]
end

#phone_number_national_format=(value) ⇒ Object



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

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

#saveObject



169
170
171
172
173
174
175
176
177
178
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 169

def save
  if @attributes[:id]
    new_obj = update(@attributes)
  else
    new_obj = TwoFactorAuthenticationMethod.create(@attributes, @options)
  end

  @attributes = new_obj.attributes
  true
end

#secret_tokensObject

array(string) - For the Static method type, this is the list of tokens which can be used



67
68
69
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 67

def secret_tokens
  @attributes[:secret_tokens]
end

#secret_tokens=(value) ⇒ Object



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

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

#setup_completeObject

boolean - 2fa setup complete?



85
86
87
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 85

def setup_complete
  @attributes[:setup_complete]
end

#setup_complete=(value) ⇒ Object



89
90
91
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 89

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

#setup_expiredObject

boolean - 2fa setup expired?



76
77
78
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 76

def setup_expired
  @attributes[:setup_expired]
end

#setup_expired=(value) ⇒ Object



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

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

#setup_expires_atObject

date-time - 2fa setup expires at this date/time (typically 10 minutes after a new method is created)



94
95
96
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 94

def setup_expires_at
  @attributes[:setup_expires_at]
end

#setup_expires_at=(value) ⇒ Object



98
99
100
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 98

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

#totp_provisioning_uriObject

string - TOTP provisioning URI (if TOTP)



103
104
105
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 103

def totp_provisioning_uri
  @attributes[:totp_provisioning_uri]
end

#totp_provisioning_uri=(value) ⇒ Object



107
108
109
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 107

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

#update(params = {}) ⇒ Object

Parameters:

otp - string - Current value of OTP, Yubikey string, or Webauthn response value.
name - string - 2fa method name
bypass_for_ftp_sftp_dav - boolean - Set true to skip checking this 2FA method when using FTP, SFTP, and DAV


142
143
144
145
146
147
148
149
150
151
152
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 142

def update(params = {})
  params ||= {}
  params[:id] = @attributes[:id]
  raise MissingParameterError.new("Current object doesn't have a id") unless @attributes[:id]
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: otp must be an String") if params[:otp] and !params[:otp].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: name must be an String") if params[:name] and !params[:name].is_a?(String)
  raise MissingParameterError.new("Parameter missing: id") unless params[:id]

  Api.send_request("/2fa/#{@attributes[:id]}", :patch, params, @options)
end

#webauthn_registration_optionsObject

object - WebAuthn / FIDO 2 registration options (if WebAuthn)



112
113
114
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 112

def webauthn_registration_options
  @attributes[:webauthn_registration_options]
end

#webauthn_registration_options=(value) ⇒ Object



116
117
118
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 116

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