Skip to content

Latest commit

 

History

History
279 lines (210 loc) · 13.6 KB

README.md

File metadata and controls

279 lines (210 loc) · 13.6 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(
	dinggolang "github.com/ding-live/ding-golang"
	"context"
	"github.com/ding-live/ding-golang/models/components"
	"log"
)

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

    ctx := context.Background()
    res, err := s.Otp.Check(ctx, &components.CreateCheckRequest{
        AuthenticationUUID: "e0e7b0e9-739d-424b-922f-1c2cb48ab077",
        CheckCode: "123456",
        CustomerUUID: "8f1196d5-806e-4b71-9b24-5f96ec052808",
    })
    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(
	dinggolang "github.com/ding-live/ding-golang"
	"context"
	"github.com/ding-live/ding-golang/models/components"
	"log"
)

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

    ctx := context.Background()
    res, err := s.Otp.CreateAuthentication(ctx, &components.CreateAuthenticationRequest{
        CustomerUUID: "c9f826e0-deca-41ec-871f-ecd6e8efeb46",
        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(
	dinggolang "github.com/ding-live/ding-golang"
	"context"
	"github.com/ding-live/ding-golang/models/components"
	"log"
)

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

    ctx := context.Background()
    res, err := s.Otp.Feedback(ctx, &components.FeedbackRequest{
        CustomerUUID: "c0c405fa-6bcb-4094-9430-7d6e2428ff23",
        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(
	dinggolang "github.com/ding-live/ding-golang"
	"context"
	"log"
)

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

    ctx := context.Background()
    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(
	dinggolang "github.com/ding-live/ding-golang"
	"context"
	"log"
)

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

    ctx := context.Background()
    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 */*