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::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::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::Types::ChangePswUserResponse
Use this endpoint to change the password for a user within an organization.
-
#delete_user(request_options: {}, **params) ⇒ Payabli::Types::DeleteUserResponse
Use this endpoint to delete a specific user within an organization.
-
#edit_mfa_user(request_options: {}, **params) ⇒ Payabli::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::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::Types::AddUserResponse
Use this endpoint to add a new user to an organization.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/payabli/user/client.rb', line 27 def add_user(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "User", headers: headers, 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::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.
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
# File 'lib/payabli/user/client.rb', line 238 def auth_refresh_user(request_options: {}, **_params) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "User/authrefresh", headers: headers, 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::Types::AuthResetUserResponse
Use this endpoint to initiate a password reset for a user within an organization.
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
# File 'lib/payabli/user/client.rb', line 275 def auth_reset_user(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "User/authreset", headers: headers, 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::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.
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
# File 'lib/payabli/user/client.rb', line 195 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 = %w[provider] body = request_data.except(*non_body_param_names) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "User/auth/#{URI.encode_uri_component(params[:provider].to_s)}", headers: headers, 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::Types::ChangePswUserResponse
Use this endpoint to change the password for a user within an organization.
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 |
# File 'lib/payabli/user/client.rb', line 314 def change_psw_user(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "PUT", path: "User/authpsw", headers: headers, 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::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::Types::DeleteUserResponse
Use this endpoint to delete a specific user within an organization.
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/payabli/user/client.rb', line 156 def delete_user(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "DELETE", path: "User/#{URI.encode_uri_component(params[:user_id].to_s)}", headers: headers, 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::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::Types::EditMfaUserResponse
Use this endpoint to enable or disable multi-factor authentication (MFA) for a user within an organization.
430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 |
# File 'lib/payabli/user/client.rb', line 430 def edit_mfa_user(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "PUT", path: "User/mfa/#{URI.encode_uri_component(params[:user_id].to_s)}", headers: headers, 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::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.
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/payabli/user/client.rb', line 116 def edit_user(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "PUT", path: "User/#{URI.encode_uri_component(params[:user_id].to_s)}", headers: headers, 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.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/payabli/user/client.rb', line 72 def get_user(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) query_params = {} query_params["entry"] = params[:entry] if params.key?(:entry) query_params["level"] = params[:level] if params.key?(:level) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "User/#{URI.encode_uri_component(params[:user_id].to_s)}", headers: headers, 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::Types::LogoutUserResponse
Use this endpoint to log a user out from the system.
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 |
# File 'lib/payabli/user/client.rb', line 353 def logout_user(request_options: {}, **_params) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "User/authlogout", headers: headers, 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::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).
476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 |
# File 'lib/payabli/user/client.rb', line 476 def resend_mfa_code(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) 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)}", headers: headers, 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.
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 |
# File 'lib/payabli/user/client.rb', line 390 def validate_mfa_user(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "User/mfa", headers: headers, 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 |