lib/fusionauth/fusionauth_client.rb in fusionauth_client-1.36.0 vs lib/fusionauth/fusionauth_client.rb in fusionauth_client-1.37.0

- old
+ new

@@ -1,10 +1,10 @@ require 'ostruct' require 'fusionauth/rest_client' # -# Copyright (c) 2018-2019, FusionAuth, All Rights Reserved +# Copyright (c) 2018-2022, FusionAuth, All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # @@ -128,13 +128,13 @@ end # # Check to see if the user must obtain a Trust Token Id in order to complete a change password request. # When a user has enabled Two-Factor authentication, before you are allowed to use the Change Password API to change - # your password, you must obtain a Truest Token by completing a Two-Factor Step-Up authentication. + # your password, you must obtain a Trust Token by completing a Two-Factor Step-Up authentication. # - # An HTTP status code of 412 indicates that a Trust Token is required to make a POST request to this API. + # An HTTP status code of 400 with a general error code of [TrustTokenRequired] indicates that a Trust Token is required to make a POST request to this API. # # @param change_password_id [string] The change password Id used to find the user. This value is generated by FusionAuth once the change password workflow has been initiated. # @return [FusionAuth::ClientResponse] The ClientResponse object. def check_change_password_using_id(change_password_id) startAnonymous.uri('/api/user/change-password') @@ -144,13 +144,13 @@ end # # Check to see if the user must obtain a Trust Token Id in order to complete a change password request. # When a user has enabled Two-Factor authentication, before you are allowed to use the Change Password API to change - # your password, you must obtain a Truest Token by completing a Two-Factor Step-Up authentication. + # your password, you must obtain a Trust Token by completing a Two-Factor Step-Up authentication. # - # An HTTP status code of 412 indicates that a Trust Token is required to make a POST request to this API. + # An HTTP status code of 400 with a general error code of [TrustTokenRequired] indicates that a Trust Token is required to make a POST request to this API. # # @param encoded_jwt [string] The encoded JWT (access token). # @return [FusionAuth::ClientResponse] The ClientResponse object. def check_change_password_using_jwt(encoded_jwt) startAnonymous.uri('/api/user/change-password') @@ -160,13 +160,13 @@ end # # Check to see if the user must obtain a Trust Request Id in order to complete a change password request. # When a user has enabled Two-Factor authentication, before you are allowed to use the Change Password API to change - # your password, you must obtain a Truest Request Id by completing a Two-Factor Step-Up authentication. + # your password, you must obtain a Trust Request Id by completing a Two-Factor Step-Up authentication. # - # An HTTP status code of 412 indicates that a Trust Token is required to make a POST request to this API. + # An HTTP status code of 400 with a general error code of [TrustTokenRequired] indicates that a Trust Token is required to make a POST request to this API. # # @param login_id [string] The loginId of the User that you intend to change the password for. # @return [FusionAuth::ClientResponse] The ClientResponse object. def check_change_password_using_login_id(login_id) start.uri('/api/user/change-password') @@ -1510,10 +1510,25 @@ .put() .go() end # + # Sends a ping to FusionAuth indicating that the user was automatically logged into an application. When using + # FusionAuth's SSO or your own, you should call this if the user is already logged in centrally, but accesses an + # application where they no longer have a session. This helps correctly track login counts, times and helps with + # reporting. + # + # @param request [OpenStruct, Hash] The login request that contains the user credentials used to log them in. + # @return [FusionAuth::ClientResponse] The ClientResponse object. + def login_ping_with_request(request) + start.uri('/api/login') + .body_handler(FusionAuth::JSONBodyHandler.new(request)) + .put() + .go() + end + + # # The Logout API is intended to be used to remove the refresh token and access token cookies if they exist on the # client and revoke the refresh token stored. This API does nothing if the request does not contain an access # token or refresh token cookies. # # @param global [Boolean] When this value is set to true all of the refresh tokens issued to the owner of the @@ -2778,17 +2793,17 @@ .get() .go() end # - # Retrieves a single refresh token by unique Id. This is not the same thing as the string value of the refresh token, if you have that, you already have what you need.. + # Retrieves a single refresh token by unique Id. This is not the same thing as the string value of the refresh token. If you have that, you already have what you need. # - # @param user_id [string] The Id of the user. + # @param token_id [string] The Id of the token. # @return [FusionAuth::ClientResponse] The ClientResponse object. - def retrieve_refresh_token_by_id(user_id) + def retrieve_refresh_token_by_id(token_id) start.uri('/api/jwt/refresh') - .url_segment(user_id) + .url_segment(token_id) .get() .go() end # @@ -2921,10 +2936,29 @@ .get() .go() end # + # Retrieve a user's two-factor status. + # + # This can be used to see if a user will need to complete a two-factor challenge to complete a login, + # and optionally identify the state of the two-factor trust across various applications. + # + # @param user_id [string] The user Id to retrieve the Two-Factor status. + # @param application_id [string] The optional applicationId to verify. + # @param two_factor_trust_id [string] The optional two-factor trust Id to verify. + # @return [FusionAuth::ClientResponse] The ClientResponse object. + def retrieve_two_factor_status(user_id, application_id, two_factor_trust_id) + start.uri('/api/two-factor/status') + .url_parameter('userId', user_id) + .url_parameter('applicationId', application_id) + .url_segment(two_factor_trust_id) + .get() + .go() + end + + # # Retrieves the user for the given Id. # # @param user_id [string] The Id of the user. # @return [FusionAuth::ClientResponse] The ClientResponse object. def retrieve_user(user_id) @@ -4144,9 +4178,23 @@ # # @param request [OpenStruct, Hash] The request that contains the verificationId and optional one-time use code paired with the verificationId. # @return [FusionAuth::ClientResponse] The ClientResponse object. def verify_email_address(request) startAnonymous.uri('/api/user/verify-email') + .body_handler(FusionAuth::JSONBodyHandler.new(request)) + .post() + .go() + end + + # + # Administratively verify a user's email address. Use this method to bypass email verification for the user. + # + # The request body will contain the userId to be verified. An API key is required when sending the userId in the request body. + # + # @param request [OpenStruct, Hash] The request that contains the userId to verify. + # @return [FusionAuth::ClientResponse] The ClientResponse object. + def verify_email_address_by_user_id(request) + start.uri('/api/user/verify-email') .body_handler(FusionAuth::JSONBodyHandler.new(request)) .post() .go() end