Skip to content

Latest commit

 

History

History
219 lines (151 loc) · 8.91 KB

README.md

File metadata and controls

219 lines (151 loc) · 8.91 KB

PhoneNumbers

(phoneNumbers())

Overview

Available Operations

  • create - Create a phone number
  • get - Retrieve a phone number
  • delete - Delete a phone number
  • update - Update a phone number

create

Create a new phone number

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.CreatePhoneNumberRequestBody;
import com.clerk.backend_api.models.operations.CreatePhoneNumberResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ClerkErrors, Exception {

        Clerk sdk = Clerk.builder()
                .bearerAuth("<YOUR_BEARER_TOKEN_HERE>")
            .build();

        CreatePhoneNumberRequestBody req = CreatePhoneNumberRequestBody.builder()
                .build();

        CreatePhoneNumberResponse res = sdk.phoneNumbers().create()
                .request(req)
                .call();

        if (res.phoneNumber().isPresent()) {
            // handle response
        }
    }
}

Parameters

Parameter Type Required Description
request CreatePhoneNumberRequestBody ✔️ The request object to use for the request.

Response

CreatePhoneNumberResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 400, 401, 403, 404, 422 application/json
models/errors/SDKError 4XX, 5XX */*

get

Returns the details of a phone number

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.GetPhoneNumberResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ClerkErrors, Exception {

        Clerk sdk = Clerk.builder()
                .bearerAuth("<YOUR_BEARER_TOKEN_HERE>")
            .build();

        GetPhoneNumberResponse res = sdk.phoneNumbers().get()
                .phoneNumberId("<id>")
                .call();

        if (res.phoneNumber().isPresent()) {
            // handle response
        }
    }
}

Parameters

Parameter Type Required Description
phoneNumberId String ✔️ The ID of the phone number to retrieve

Response

GetPhoneNumberResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 400, 401, 403, 404 application/json
models/errors/SDKError 4XX, 5XX */*

delete

Delete the phone number with the given ID

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.DeletePhoneNumberResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ClerkErrors, Exception {

        Clerk sdk = Clerk.builder()
                .bearerAuth("<YOUR_BEARER_TOKEN_HERE>")
            .build();

        DeletePhoneNumberResponse res = sdk.phoneNumbers().delete()
                .phoneNumberId("<id>")
                .call();

        if (res.deletedObject().isPresent()) {
            // handle response
        }
    }
}

Parameters

Parameter Type Required Description
phoneNumberId String ✔️ The ID of the phone number to delete

Response

DeletePhoneNumberResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 400, 401, 403, 404 application/json
models/errors/SDKError 4XX, 5XX */*

update

Updates a phone number

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.UpdatePhoneNumberRequestBody;
import com.clerk.backend_api.models.operations.UpdatePhoneNumberResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ClerkErrors, Exception {

        Clerk sdk = Clerk.builder()
                .bearerAuth("<YOUR_BEARER_TOKEN_HERE>")
            .build();

        UpdatePhoneNumberResponse res = sdk.phoneNumbers().update()
                .phoneNumberId("<id>")
                .requestBody(UpdatePhoneNumberRequestBody.builder()
                    .build())
                .call();

        if (res.phoneNumber().isPresent()) {
            // handle response
        }
    }
}

Parameters

Parameter Type Required Description
phoneNumberId String ✔️ The ID of the phone number to update
requestBody Optional<UpdatePhoneNumberRequestBody> N/A

Response

UpdatePhoneNumberResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 400, 401, 403, 404 application/json
models/errors/SDKError 4XX, 5XX */*