Skip to content

Latest commit

 

History

History
284 lines (210 loc) · 13.7 KB

README.md

File metadata and controls

284 lines (210 loc) · 13.7 KB

Otp

(Otp)

Overview

Send OTP codes to your users using their phone numbers.

Available Operations

Check

Check a code

Example Usage

package main

import(
	"context"
	dinggolang "github.com/ding-live/ding-golang"
	"github.com/ding-live/ding-golang/models/components"
	"log"
)

func main() {
    ctx := context.Background()

    s := dinggolang.New(
        dinggolang.WithSecurity("YOUR_API_KEY"),
    )

    res, err := s.Otp.Check(ctx, &components.CreateCheckRequest{
        AuthenticationUUID: "eebe792b-2fcc-44a0-87f1-650e79259e02",
        CheckCode: "123456",
        CustomerUUID: "64f66a7c-4b2c-4131-a8ff-d5b954cca05f",
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.CreateCheckResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request components.CreateCheckRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.CheckResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.ErrorResponse 400 application/json
sdkerrors.SDKError 4XX, 5XX */*

CreateAuthentication

Send a code

Example Usage

package main

import(
	"context"
	dinggolang "github.com/ding-live/ding-golang"
	"github.com/ding-live/ding-golang/models/components"
	"log"
)

func main() {
    ctx := context.Background()

    s := dinggolang.New(
        dinggolang.WithSecurity("YOUR_API_KEY"),
    )

    res, err := s.Otp.CreateAuthentication(ctx, &components.CreateAuthenticationRequest{
        CustomerUUID: "cf2edc1c-7fc6-48fb-86da-b7508c6b7b71",
        Locale: dinggolang.String("fr-FR"),
        PhoneNumber: "+1234567890",
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.CreateAuthenticationResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request components.CreateAuthenticationRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.CreateAuthenticationResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.ErrorResponse 400 application/json
sdkerrors.SDKError 4XX, 5XX */*

Feedback

Send feedback

Example Usage

package main

import(
	"context"
	dinggolang "github.com/ding-live/ding-golang"
	"github.com/ding-live/ding-golang/models/components"
	"log"
)

func main() {
    ctx := context.Background()

    s := dinggolang.New(
        dinggolang.WithSecurity("YOUR_API_KEY"),
    )

    res, err := s.Otp.Feedback(ctx, &components.FeedbackRequest{
        CustomerUUID: "cc0f6c04-40de-448f-8301-3cb0e6565dff",
        PhoneNumber: "+1234567890",
        Status: components.FeedbackRequestStatusOnboarded,
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.FeedbackResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request components.FeedbackRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.FeedbackResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.ErrorResponse 400 application/json
sdkerrors.SDKError 4XX, 5XX */*

GetAuthenticationStatus

Get authentication status

Example Usage

package main

import(
	"context"
	dinggolang "github.com/ding-live/ding-golang"
	"log"
)

func main() {
    ctx := context.Background()

    s := dinggolang.New(
        dinggolang.WithSecurity("YOUR_API_KEY"),
    )

    res, err := s.Otp.GetAuthenticationStatus(ctx, "d8446450-f2fa-4dd9-806b-df5b8c661f23")
    if err != nil {
        log.Fatal(err)
    }
    if res.AuthenticationStatusResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
authUUID string ✔️ N/A
opts []operations.Option The options for this request.

Response

*operations.GetAuthenticationStatusResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.ErrorResponse 400 application/json
sdkerrors.SDKError 4XX, 5XX */*

Retry

Perform a retry

Example Usage

package main

import(
	"context"
	dinggolang "github.com/ding-live/ding-golang"
	"log"
)

func main() {
    ctx := context.Background()

    s := dinggolang.New(
        dinggolang.WithSecurity("YOUR_API_KEY"),
    )

    res, err := s.Otp.Retry(ctx, nil)
    if err != nil {
        log.Fatal(err)
    }
    if res.RetryAuthenticationResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request components.RetryAuthenticationRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.RetryResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.ErrorResponse 400 application/json
sdkerrors.SDKError 4XX, 5XX */*