Skip to main content
Version: Go

SIM Swap Reference

The SIM Swap client operates with a specific user identifier (e.g., a phone number). To interact with the SIM Swap service for a particular user, you need to create a SimSwapUserClient configured for that user.

SimSwapUserClients are creating using the SimSwapClient accessible from the GlideClient.

SimSwapClient Reference

Methods

1. For

Description: For creates and returns a SimSwapUserClient configured for the specified user identifier.

Syntax:

For(identifier types.UserIdentifier) (*SimSwapUserClient, error)

Parameters:

ParameterTypeDescription
identifierUserIdentifierAn interface representing a user (can be a phonenumber, ip address or custom user id but only one of the above)

UserIdentifier Properties:

PropertyTypeDescription
PhoneNumberstringThe phone number of the user.
IPAddressstringThe IP address of the user.
UserIDstringA custom user identifier.

Only one of the properties should be provided.

Returns:

  • *SimSwapUserClient: A pointer to a SimSwapUserClient configured for the specified user identifier.

Example:

client, err := glide.NewGlideClient(settings)
userClient, err := client.SimSwap.For(types.PhoneIdentifier{PhoneNumber: "+555123456789"})

SimSwapUserClient Reference

The SimSwapUserClient is used to interact with the SIM Swap service for a specific phone number.

Properties

1. requiresConsent

A boolean indicating if the user needs to provide consent before checking for a SIM swap. If this is true then you need to call getConsentUrl to get the consent URL and ask the user to provide consent before calling check or retrieveDate.

Methods

1. Check

Description: Check verifies if a SIM swap has occurred for the user's phone number.

Syntax:

Check(params types.SimSwapCheckParams, conf types.ApiConfig) (*SimSwapCheckResponse, error)

Parameters:

ParameterTypeDescription
checkParamsSimSwapCheckParamsA struct containing the check parameters.

SimSwapCheckParams Properties:

PropertyTypeDescription
PhoneNumberstringOptional - The phone number to check for a SIM swap.
MaxAge*intOptional - Maximum age of the SIM swap in hours.

If phoneNumber was provided in the for method as the user identifier, it can be omitted here.

Returns:

  • SimSwapCheckResponse: A struct containing the SIM swap status.

SimSwapCheckResponse Properties:

PropertyTypeJSON keyDescription
SwappedboolswappedIndicates if a SIM swap has occurred up to maxAge hours ago

Example:

import (
"github.com/GlideApis/sdk-go/pkg/glide"
"github.com/GlideApis/sdk-go/pkg/types"
)
client, err := glide.NewGlideClient(settings)
userClient, _ := client.SimSwap.For(types.PhoneIdentifier{PhoneNumber: "+555123456789"})
response, err := userClient.Check(types.SimSwapCheckParams{}, types.ApiConfig{})

2. RetrieveDate

Description: RetrieveDate retrieves the date of the last SIM swap for the user's phone number.

Syntax:

RetrieveDate(params types.SimSwapRetrieveDateParams, conf types.ApiConfig) (*SimSwapRetrieveDateResponse, error)

Parameters:

ParameterTypeDescription
paramsSimSwapRetrieveDateParamsA struct containing the retrieve date parameters.

SimSwapRetrieveDateParams Properties:

PropertyTypeDescription
PhoneNumberstringOptional - The phone number to check for a SIM swap.

Returns:

  • SimSwapRetrieveDateResponse: An object containing the date of the last SIM swap.

SimSwapRetrieveDateResponse Properties:

PropertyTypeJSON KeyDescription
LatestSimChangestringlatestSimChangeThe date of the last SIM swap in ISO 8601 format.

Example:

import (
"github.com/GlideApis/sdk-go/pkg/glide"
"github.com/GlideApis/sdk-go/pkg/types"
)
client, err := glide.NewGlideClient(settings)
userClient, _ := client.SimSwap.For(types.PhoneIdentifier{PhoneNumber: "+555123456789"})
response, err := userClient.RetrieveDate(types.SimSwapRetrieveDateParams{}, types.ApiConfig{})

// Output: { LatestSimChange: "2022-01-01T00:00:00Z" }


3. GetConsentUrl

Description: GetConsentUrl retrieves the URL for the user to provide consent before checking for a SIM swap.

Syntax:

GetConsentURL() string

Returns:

  • string: The URL for the user to provide consent.

Example:

import (
"github.com/GlideApis/sdk-go/pkg/glide"
"github.com/GlideApis/sdk-go/pkg/types"
)
simSwapUserClient, _ := client.SimSwap.For(types.PhoneIdentifier{PhoneNumber: "+555123456789"})
if simSwapUserClient.requiresConsent {
consentURL := simSwapUserClient.GetConsentURL()
}


Error Handling

Each method in SimSwapService can throw errors under certain conditions. Developers should handle these exceptions as part of their implementation. Common errors include:

  • InvalidInputError: Thrown when input parameters do not meet the required format or type.
  • OperationFailedError: Thrown when an operation cannot be completed successfully due to various issues, such as network problems or service unavailability.

Type Definitions

ApiConfig

This string can be sent to most service apis to override the default configuration like the access token used in the request.

Properties

PropertyTypeDescription
SessionSessionAn optional session object for authentication and authorization.

Session

This object represents a user session with an access token, expiration time, and associated scopes.

Properties

PropertyTypeDescription
AccessTokenstringThe access token for the session.
ExpiresAtint64The expiration time of the session.
Scopes[]stringA string with scopes associated with the session.