Skip to content

Latest commit

 

History

History
181 lines (135 loc) · 12.4 KB

README.md

File metadata and controls

181 lines (135 loc) · 12.4 KB

Testing

(Testing)

Overview

Use the Testing API to generate and retrieve test data to verify a subset of flows in non-production environments.

Available Operations

CreateAccount

Create a Bolt shopper account for testing purposes.

Example Usage

package main

import(
	"context"
	boltgo "github.com/BoltApp/bolt-go"
	"github.com/BoltApp/bolt-go/models/components"
	"github.com/BoltApp/bolt-go/models/operations"
	"log"
)

func main() {
    ctx := context.Background()
    
    s := boltgo.New()

    res, err := s.Testing.CreateAccount(ctx, operations.TestingAccountCreateSecurity{
        APIKey: "<YOUR_API_KEY_HERE>",
    }, "<value>", components.AccountTestCreationData{
        EmailState: components.EmailStateUnverified,
        PhoneState: components.PhoneStateVerified,
        IsMigrated: boltgo.Bool(true),
        HasAddress: boltgo.Bool(true),
        HasCreditCard: boltgo.Bool(true),
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.AccountTestCreationData != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
security operations.TestingAccountCreateSecurity ✔️ The security requirements to use for the request.
xPublishableKey string ✔️ The publicly shareable identifier used to identify your Bolt merchant division.
accountTestCreationData components.AccountTestCreationData ✔️ N/A
opts []operations.Option The options for this request.

Response

*operations.TestingAccountCreateResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.TestingAccountCreateResponseBody 4XX application/json
sdkerrors.SDKError 5XX */*

TestingAccountPhoneGet

Get a random, fictitious phone number that is not assigned to any existing Bolt account.

Example Usage

package main

import(
	"context"
	boltgo "github.com/BoltApp/bolt-go"
	"github.com/BoltApp/bolt-go/models/operations"
	"log"
)

func main() {
    ctx := context.Background()
    
    s := boltgo.New()

    res, err := s.Testing.TestingAccountPhoneGet(ctx, operations.TestingAccountPhoneGetSecurity{
        APIKey: "<YOUR_API_KEY_HERE>",
    }, "<value>")
    if err != nil {
        log.Fatal(err)
    }
    if res.AccountTestPhoneData != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
security operations.TestingAccountPhoneGetSecurity ✔️ The security requirements to use for the request.
xPublishableKey string ✔️ The publicly shareable identifier used to identify your Bolt merchant division.
opts []operations.Option The options for this request.

Response

*operations.TestingAccountPhoneGetResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.TestingAccountPhoneGetResponseBody 4XX application/json
sdkerrors.SDKError 5XX */*

GetCreditCard

Retrieve a test credit card that can be used to process payments in your Bolt testing environment. The response includes the card's Bolt credit card token.

Example Usage

package main

import(
	"context"
	boltgo "github.com/BoltApp/bolt-go"
	"github.com/BoltApp/bolt-go/models/operations"
	"log"
)

func main() {
    ctx := context.Background()
    
    s := boltgo.New()

    res, err := s.Testing.GetCreditCard(ctx, operations.TestingCreditCardGetRequestBody{
        Type: operations.TypeApprove,
    }, operations.TestingCreditCardGetSecurity{
        APIKey: "<YOUR_API_KEY_HERE>",
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.TestCreditCard != nil {
        // handle response
    }
}

Parameters

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

Response

*operations.TestingCreditCardGetResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.TestingCreditCardGetResponseBody 4XX application/json
sdkerrors.SDKError 5XX */*