Class: Files::TwoFactorAuthenticationMethod
- Inherits:
-
Object
- Object
- Files::TwoFactorAuthenticationMethod
- Defined in:
- lib/files.com/models/two_factor_authentication_method.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: method_type (required) - string - Type of 2fa name - string - 2fa method name phone_number - string - 2fa phone number (if SMS).
- .delete(id, params = {}, options = {}) ⇒ Object
- .destroy(id, params = {}, options = {}) ⇒ Object
-
.get(params = {}, options = {}) ⇒ Object
Parameters: page - integer - Current page number.
-
.send_code(params = {}, options = {}) ⇒ Object
Parameters: u2f_only - boolean - Set to ‘true` to only generate an OTP for U2F (FIDO) keys and skip things like SMS.
-
.update(id, params = {}, options = {}) ⇒ Object
Parameters: otp - string - Current value of OTP, Yubikey string, or U2F response value.
Instance Method Summary collapse
- #delete(params = {}) ⇒ Object
- #destroy(params = {}) ⇒ Object
-
#id ⇒ Object
int64 - 2fa ID.
- #id=(value) ⇒ Object
-
#initialize(attributes = {}, options = {}) ⇒ TwoFactorAuthenticationMethod
constructor
A new instance of TwoFactorAuthenticationMethod.
-
#method_type ⇒ Object
string - Type of 2fa.
- #method_type=(value) ⇒ Object
-
#name ⇒ Object
string - 2fa method name.
- #name=(value) ⇒ Object
-
#otp ⇒ Object
string - Current value of OTP, Yubikey string, or U2F response value.
- #otp=(value) ⇒ Object
-
#phone_number ⇒ Object
string - 2fa phone number (if SMS).
- #phone_number=(value) ⇒ Object
-
#phone_number_country ⇒ Object
string - 2fa phone number country (if SMS).
- #phone_number_country=(value) ⇒ Object
-
#phone_number_national_format ⇒ Object
string - 2fa phone number national format (if SMS).
- #phone_number_national_format=(value) ⇒ Object
- #save ⇒ Object
-
#setup_complete ⇒ Object
boolean - 2fa setup complete?.
- #setup_complete=(value) ⇒ Object
-
#setup_expired ⇒ Object
boolean - 2fa setup expired?.
- #setup_expired=(value) ⇒ Object
-
#setup_expires_at ⇒ Object
date-time - 2fa setup expires at this date/time (typically 10 minutes after a new method is created).
- #setup_expires_at=(value) ⇒ Object
-
#totp_provisioning_uri ⇒ Object
string - TOTP provisioning URI (if TOTP).
- #totp_provisioning_uri=(value) ⇒ Object
-
#u2f_app_id ⇒ Object
string - U2F app ID (if U2F).
- #u2f_app_id=(value) ⇒ Object
-
#u2f_registration_requests ⇒ Object
array - U2F registration requests (if U2F).
- #u2f_registration_requests=(value) ⇒ Object
-
#update(params = {}) ⇒ Object
Parameters: otp - string - Current value of OTP, Yubikey string, or U2F response value.
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 = {}, = {}) @attributes = attributes || {} @options = || {} end |
Instance Attribute Details
#attributes ⇒ Object (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 |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 5 def @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)
184 185 186 187 188 189 190 191 192 |
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 184 def self.create(params = {}, = {}) raise InvalidParameterError.new("Bad parameter: method_type must be an String") if params.dig(:method_type) and !params.dig(:method_type).is_a?(String) raise InvalidParameterError.new("Bad parameter: name must be an String") if params.dig(:name) and !params.dig(:name).is_a?(String) raise InvalidParameterError.new("Bad parameter: phone_number must be an String") if params.dig(:phone_number) and !params.dig(:phone_number).is_a?(String) raise MissingParameterError.new("Parameter missing: method_type") unless params.dig(:method_type) response, = Api.send_request("/2fa", :post, params, ) TwoFactorAuthenticationMethod.new(response.data, ) end |
.delete(id, params = {}, options = {}) ⇒ Object
216 217 218 219 220 221 222 223 224 |
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 216 def self.delete(id, params = {}, = {}) params ||= {} params[:id] = id raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer) raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id) response, = Api.send_request("/2fa/#{params[:id]}", :delete, params, ) response.data end |
.destroy(id, params = {}, options = {}) ⇒ Object
226 227 228 |
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 226 def self.destroy(id, params = {}, = {}) delete(id, params, ) end |
.get(params = {}, options = {}) ⇒ Object
Parameters:
page - integer - Current page number.
per_page - integer - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
action - string - Deprecated: If set to `count` returns a count of matching records rather than the records themselves.
171 172 173 174 175 176 177 178 |
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 171 def self.get(params = {}, = {}) raise InvalidParameterError.new("Bad parameter: page must be an Integer") if params.dig(:page) and !params.dig(:page).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: per_page must be an Integer") if params.dig(:per_page) and !params.dig(:per_page).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String) response, = Api.send_request("/2fa", :get, params, ) response.data.map { |object| TwoFactorAuthenticationMethod.new(object, ) } end |
.send_code(params = {}, options = {}) ⇒ Object
Parameters:
u2f_only - boolean - Set to `true` to only generate an OTP for U2F (FIDO) keys and skip things like SMS.
196 197 198 199 |
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 196 def self.send_code(params = {}, = {}) response, = Api.send_request("/2fa/send_code", :post, params, ) U2fSignRequest.new(response.data, ) end |
.update(id, params = {}, options = {}) ⇒ Object
Parameters:
otp - string - Current value of OTP, Yubikey string, or U2F response value. U2F response value requires a json stringified object containing fields `clientData`, `keyHandle`, and `signatureData`.
name - string - 2fa method name
204 205 206 207 208 209 210 211 212 213 214 |
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 204 def self.update(id, params = {}, = {}) params ||= {} params[:id] = id raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: otp must be an String") if params.dig(:otp) and !params.dig(:otp).is_a?(String) raise InvalidParameterError.new("Bad parameter: name must be an String") if params.dig(:name) and !params.dig(:name).is_a?(String) raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id) response, = Api.send_request("/2fa/#{params[:id]}", :patch, params, ) TwoFactorAuthenticationMethod.new(response.data, ) end |
Instance Method Details
#delete(params = {}) ⇒ Object
144 145 146 147 148 149 150 151 152 |
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 144 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.dig(:id) and !params.dig(:id).is_a?(Integer) raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id) Api.send_request("/2fa/#{@attributes[:id]}", :delete, params, @options) end |
#destroy(params = {}) ⇒ Object
154 155 156 |
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 154 def destroy(params = {}) delete(params) end |
#id ⇒ Object
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_type ⇒ Object
string - Type of 2fa
22 23 24 |
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 22 def method_type @attributes[:method_type] end |
#method_type=(value) ⇒ Object
26 27 28 |
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 26 def method_type=(value) @attributes[:method_type] = value end |
#name ⇒ Object
string - 2fa method name
31 32 33 |
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 31 def name @attributes[:name] end |
#name=(value) ⇒ Object
35 36 37 |
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 35 def name=(value) @attributes[:name] = value end |
#otp ⇒ Object
string - Current value of OTP, Yubikey string, or U2F response value. U2F response value requires a json stringified object containing fields ‘clientData`, `keyHandle`, and `signatureData`.
121 122 123 |
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 121 def otp @attributes[:otp] end |
#otp=(value) ⇒ Object
125 126 127 |
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 125 def otp=(value) @attributes[:otp] = value end |
#phone_number ⇒ Object
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_country ⇒ Object
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_format ⇒ Object
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 |
#save ⇒ Object
158 159 160 161 162 163 164 165 |
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 158 def save if @attributes[:id] update(@attributes) else new_obj = TwoFactorAuthenticationMethod.create(@attributes, @options) @attributes = new_obj.attributes end end |
#setup_complete ⇒ Object
boolean - 2fa setup complete?
76 77 78 |
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 76 def setup_complete @attributes[:setup_complete] end |
#setup_complete=(value) ⇒ Object
80 81 82 |
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 80 def setup_complete=(value) @attributes[:setup_complete] = value end |
#setup_expired ⇒ Object
boolean - 2fa setup expired?
67 68 69 |
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 67 def setup_expired @attributes[:setup_expired] end |
#setup_expired=(value) ⇒ Object
71 72 73 |
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 71 def setup_expired=(value) @attributes[:setup_expired] = value end |
#setup_expires_at ⇒ Object
date-time - 2fa setup expires at this date/time (typically 10 minutes after a new method is created)
85 86 87 |
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 85 def setup_expires_at @attributes[:setup_expires_at] end |
#setup_expires_at=(value) ⇒ Object
89 90 91 |
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 89 def setup_expires_at=(value) @attributes[:setup_expires_at] = value end |
#totp_provisioning_uri ⇒ Object
string - TOTP provisioning URI (if TOTP)
94 95 96 |
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 94 def totp_provisioning_uri @attributes[:totp_provisioning_uri] end |
#totp_provisioning_uri=(value) ⇒ Object
98 99 100 |
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 98 def totp_provisioning_uri=(value) @attributes[:totp_provisioning_uri] = value end |
#u2f_app_id ⇒ Object
string - U2F app ID (if U2F)
103 104 105 |
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 103 def u2f_app_id @attributes[:u2f_app_id] end |
#u2f_app_id=(value) ⇒ Object
107 108 109 |
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 107 def u2f_app_id=(value) @attributes[:u2f_app_id] = value end |
#u2f_registration_requests ⇒ Object
array - U2F registration requests (if U2F)
112 113 114 |
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 112 def u2f_registration_requests @attributes[:u2f_registration_requests] end |
#u2f_registration_requests=(value) ⇒ Object
116 117 118 |
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 116 def u2f_registration_requests=(value) @attributes[:u2f_registration_requests] = value end |
#update(params = {}) ⇒ Object
Parameters:
otp - string - Current value of OTP, Yubikey string, or U2F response value. U2F response value requires a json stringified object containing fields `clientData`, `keyHandle`, and `signatureData`.
name - string - 2fa method name
132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/files.com/models/two_factor_authentication_method.rb', line 132 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.dig(:id) and !params.dig(:id).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: otp must be an String") if params.dig(:otp) and !params.dig(:otp).is_a?(String) raise InvalidParameterError.new("Bad parameter: name must be an String") if params.dig(:name) and !params.dig(:name).is_a?(String) raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id) Api.send_request("/2fa/#{@attributes[:id]}", :patch, params, @options) end |