Class: Payabli::User::Client
- Inherits:
-
Object
- Object
- Payabli::User::Client
- Defined in:
- lib/payabli/user/client.rb
Instance Method Summary collapse
-
#add_user(request_options: {}, **params) ⇒ Payabli::User::Types::AddUserResponse
Use this endpoint to add a new user to an organization.
-
#auth_refresh_user(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponseUserMfa
Use this endpoint to refresh the authentication token for a user within an organization.
-
#auth_reset_user(request_options: {}, **params) ⇒ Payabli::User::Types::AuthResetUserResponse
Use this endpoint to initiate a password reset for a user within an organization.
-
#auth_user(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponseMfaBasic
This endpoint requires an application API token.
-
#change_psw_user(request_options: {}, **params) ⇒ Payabli::User::Types::ChangePswUserResponse
Use this endpoint to change the password for a user within an organization.
-
#delete_user(request_options: {}, **params) ⇒ Payabli::User::Types::DeleteUserResponse
Use this endpoint to delete a specific user within an organization.
-
#edit_mfa_user(request_options: {}, **params) ⇒ Payabli::User::Types::EditMfaUserResponse
Use this endpoint to enable or disable multi-factor authentication (MFA) for a user within an organization.
-
#edit_user(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponse
Use this endpoint to modify the details of a specific user within an organization.
-
#get_user(request_options: {}, **params) ⇒ Payabli::Types::UserQueryRecord
Use this endpoint to retrieve information about a specific user within an organization.
- #initialize(client:) ⇒ void constructor
-
#logout_user(request_options: {}, **params) ⇒ Payabli::User::Types::LogoutUserResponse
Use this endpoint to log a user out from the system.
-
#resend_mfa_code(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponseMfaBasic
Resends the MFA code to the user via the selected MFA mode (email or SMS).
-
#validate_mfa_user(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponseUserMfa
Use this endpoint to validate the multi-factor authentication (MFA) code for a user within an organization.
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/payabli/user/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#add_user(request_options: {}, **params) ⇒ Payabli::User::Types::AddUserResponse
Use this endpoint to add a new user to an organization.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/payabli/user/client.rb', line 24 def add_user(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "User", body: Payabli::Types::UserData.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::User::Types::AddUserResponse.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#auth_refresh_user(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponseUserMfa
Use this endpoint to refresh the authentication token for a user within an organization.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/payabli/user/client.rb', line 58 def auth_refresh_user(request_options: {}, **params) Payabli::Internal::Types::Utils.normalize_keys(params) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "User/authrefresh", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::Types::PayabliApiResponseUserMfa.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#auth_reset_user(request_options: {}, **params) ⇒ Payabli::User::Types::AuthResetUserResponse
Use this endpoint to initiate a password reset for a user within an organization.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/payabli/user/client.rb', line 91 def auth_reset_user(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "User/authreset", body: Payabli::User::Types::UserAuthResetRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::User::Types::AuthResetUserResponse.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#auth_user(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponseMfaBasic
This endpoint requires an application API token.
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/payabli/user/client.rb', line 126 def auth_user(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) request_data = Payabli::User::Types::UserAuthRequest.new(params).to_h non_body_param_names = ["provider"] body = request_data.except(*non_body_param_names) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "User/auth/#{URI.encode_uri_component(params[:provider].to_s)}", body: body, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::Types::PayabliApiResponseMfaBasic.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#change_psw_user(request_options: {}, **params) ⇒ Payabli::User::Types::ChangePswUserResponse
Use this endpoint to change the password for a user within an organization.
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/payabli/user/client.rb', line 164 def change_psw_user(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "PUT", path: "User/authpsw", body: Payabli::User::Types::UserAuthPswResetRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::User::Types::ChangePswUserResponse.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#delete_user(request_options: {}, **params) ⇒ Payabli::User::Types::DeleteUserResponse
Use this endpoint to delete a specific user within an organization.
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
# File 'lib/payabli/user/client.rb', line 199 def delete_user(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "DELETE", path: "User/#{URI.encode_uri_component(params[:user_id].to_s)}", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::User::Types::DeleteUserResponse.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#edit_mfa_user(request_options: {}, **params) ⇒ Payabli::User::Types::EditMfaUserResponse
Use this endpoint to enable or disable multi-factor authentication (MFA) for a user within an organization.
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
# File 'lib/payabli/user/client.rb', line 233 def edit_mfa_user(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "PUT", path: "User/mfa/#{URI.encode_uri_component(params[:user_id].to_s)}", body: Payabli::Types::MfaData.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::User::Types::EditMfaUserResponse.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#edit_user(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponse
Use this endpoint to modify the details of a specific user within an organization.
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
# File 'lib/payabli/user/client.rb', line 268 def edit_user(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "PUT", path: "User/#{URI.encode_uri_component(params[:user_id].to_s)}", body: Payabli::Types::UserData.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::Types::PayabliApiResponse.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get_user(request_options: {}, **params) ⇒ Payabli::Types::UserQueryRecord
Use this endpoint to retrieve information about a specific user within an organization.
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 |
# File 'lib/payabli/user/client.rb', line 305 def get_user(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) query_param_names = %i[entry level] query_params = {} query_params["entry"] = params[:entry] if params.key?(:entry) query_params["level"] = params[:level] if params.key?(:level) params = params.except(*query_param_names) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "User/#{URI.encode_uri_component(params[:user_id].to_s)}", query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::Types::UserQueryRecord.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#logout_user(request_options: {}, **params) ⇒ Payabli::User::Types::LogoutUserResponse
Use this endpoint to log a user out from the system.
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 |
# File 'lib/payabli/user/client.rb', line 345 def logout_user(request_options: {}, **params) Payabli::Internal::Types::Utils.normalize_keys(params) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "User/authlogout", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::User::Types::LogoutUserResponse.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#resend_mfa_code(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponseMfaBasic
Resends the MFA code to the user via the selected MFA mode (email or SMS).
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 |
# File 'lib/payabli/user/client.rb', line 381 def resend_mfa_code(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "User/resendmfa/#{URI.encode_uri_component(params[:usrname].to_s)}/#{URI.encode_uri_component(params[:entry].to_s)}/#{URI.encode_uri_component(params[:entry_type].to_s)}", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::Types::PayabliApiResponseMfaBasic.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#validate_mfa_user(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponseUserMfa
Use this endpoint to validate the multi-factor authentication (MFA) code for a user within an organization.
414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 |
# File 'lib/payabli/user/client.rb', line 414 def validate_mfa_user(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "User/mfa", body: Payabli::User::Types::MfaValidationData.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::Types::PayabliApiResponseUserMfa.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |