Categorygithub.com/speakeasy-sdks/Test_Bolt_API
modulepackage
0.17.3
Repository: https://github.com/speakeasy-sdks/test_bolt_api.git
Documentation: pkg.go.dev

# README

github.com/speakeasy-sdks/Test_Bolt_API

SDK Installation

go get github.com/speakeasy-sdks/Test_Bolt_API

SDK Example Usage

Example

package main

import (
	"context"
	testboltapi "github.com/speakeasy-sdks/Test_Bolt_API"
	"github.com/speakeasy-sdks/Test_Bolt_API/pkg/models/operations"
	"github.com/speakeasy-sdks/Test_Bolt_API/pkg/models/shared"
	"log"
)

func main() {
	s := testboltapi.New(
		testboltapi.WithSecurity(shared.Security{
			APIKey: testboltapi.String("<YOUR_API_KEY_HERE>"),
		}),
	)

	ctx := context.Background()
	res, err := s.Account.DeleteAddress(ctx, operations.AccountAddressDeleteRequest{
		XPublishableKey: "<value>",
		ID:              "D4g3h5tBuVYK9",
	})
	if err != nil {
		log.Fatal(err)
	}
	if res != nil {
		// handle response
	}
}

Available Resources and Operations

Account

Payments.Guest

  • Initialize - Initialize a Bolt payment for guest shoppers
  • PerformAction - Perform an irreversible action (e.g. finalize) on a pending guest payment
  • Update - Update an existing guest payment

Payments.LoggedIn

  • Initialize - Initialize a Bolt payment for logged in shoppers
  • PerformAction - Perform an irreversible action (e.g. finalize) on a pending payment
  • Update - Update an existing payment

OAuth

Testing

Special Types

Error Handling

Handling errors in this SDK should largely match your expectations. All operations return a response object or an error, they will never return both. When specified by the OpenAPI spec document, the SDK will return the appropriate subclass.

Error ObjectStatus CodeContent Type
sdkerrors.Error4XXapplication/json
sdkerrors.SDKError4xx-5xx/

Example

package main

import (
	"context"
	"errors"
	testboltapi "github.com/speakeasy-sdks/Test_Bolt_API"
	"github.com/speakeasy-sdks/Test_Bolt_API/pkg/models/operations"
	"github.com/speakeasy-sdks/Test_Bolt_API/pkg/models/sdkerrors"
	"github.com/speakeasy-sdks/Test_Bolt_API/pkg/models/shared"
	"log"
)

func main() {
	s := testboltapi.New(
		testboltapi.WithSecurity(shared.Security{
			APIKey: testboltapi.String("<YOUR_API_KEY_HERE>"),
		}),
	)

	ctx := context.Background()
	res, err := s.Account.DeleteAddress(ctx, operations.AccountAddressDeleteRequest{
		XPublishableKey: "<value>",
		ID:              "D4g3h5tBuVYK9",
	})
	if err != nil {

		var e *sdkerrors.Error
		if errors.As(err, &e) {
			// handle error
			log.Fatal(e.Error())
		}

		var e *sdkerrors.SDKError
		if errors.As(err, &e) {
			// handle error
			log.Fatal(e.Error())
		}
	}
}

Server Selection

Select Server by Index

You can override the default server globally using the WithServerIndex option when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers:

#ServerVariables
0https://{environment}.bolt.com/v3environment (default is api-sandbox)

Example

package main

import (
	"context"
	testboltapi "github.com/speakeasy-sdks/Test_Bolt_API"
	"github.com/speakeasy-sdks/Test_Bolt_API/pkg/models/operations"
	"github.com/speakeasy-sdks/Test_Bolt_API/pkg/models/shared"
	"log"
)

func main() {
	s := testboltapi.New(
		testboltapi.WithServerIndex(0),
		testboltapi.WithSecurity(shared.Security{
			APIKey: testboltapi.String("<YOUR_API_KEY_HERE>"),
		}),
	)

	ctx := context.Background()
	res, err := s.Account.DeleteAddress(ctx, operations.AccountAddressDeleteRequest{
		XPublishableKey: "<value>",
		ID:              "D4g3h5tBuVYK9",
	})
	if err != nil {
		log.Fatal(err)
	}
	if res != nil {
		// handle response
	}
}

Variables

Some of the server options above contain variables. If you want to set the values of those variables, the following options are provided for doing so:

  • WithEnvironment testboltapi.ServerEnvironment

Override Server URL Per-Client

The default server can also be overridden globally using the WithServerURL option when initializing the SDK client instance. For example:

package main

import (
	"context"
	testboltapi "github.com/speakeasy-sdks/Test_Bolt_API"
	"github.com/speakeasy-sdks/Test_Bolt_API/pkg/models/operations"
	"github.com/speakeasy-sdks/Test_Bolt_API/pkg/models/shared"
	"log"
)

func main() {
	s := testboltapi.New(
		testboltapi.WithServerURL("https://{environment}.bolt.com/v3"),
		testboltapi.WithSecurity(shared.Security{
			APIKey: testboltapi.String("<YOUR_API_KEY_HERE>"),
		}),
	)

	ctx := context.Background()
	res, err := s.Account.DeleteAddress(ctx, operations.AccountAddressDeleteRequest{
		XPublishableKey: "<value>",
		ID:              "D4g3h5tBuVYK9",
	})
	if err != nil {
		log.Fatal(err)
	}
	if res != nil {
		// handle response
	}
}

Custom HTTP Client

The Go SDK makes API calls that wrap an internal HTTP client. The requirements for the HTTP client are very simple. It must match this interface:

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

The built-in net/http client satisfies this interface and a default client based on the built-in is provided by default. To replace this default with a client of your own, you can implement this interface yourself or provide your own client configured as desired. Here's a simple example, which adds a client with a 30 second timeout.

import (
	"net/http"
	"time"
	"github.com/myorg/your-go-sdk"
)

var (
	httpClient = &http.Client{Timeout: 30 * time.Second}
	sdkClient  = sdk.New(sdk.WithClient(httpClient))
)

This can be a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration.

Authentication

Per-Client Security Schemes

This SDK supports the following security schemes globally:

NameTypeScheme
APIKeyapiKeyAPI key
Oauthoauth2OAuth2 token

You can set the security parameters through the WithSecurity option when initializing the SDK client instance. The selected scheme will be used by default to authenticate with the API for all operations that support it. For example:

package main

import (
	"context"
	testboltapi "github.com/speakeasy-sdks/Test_Bolt_API"
	"github.com/speakeasy-sdks/Test_Bolt_API/pkg/models/operations"
	"github.com/speakeasy-sdks/Test_Bolt_API/pkg/models/shared"
	"log"
)

func main() {
	s := testboltapi.New(
		testboltapi.WithSecurity(shared.Security{
			APIKey: testboltapi.String("<YOUR_API_KEY_HERE>"),
		}),
	)

	ctx := context.Background()
	res, err := s.Account.DeleteAddress(ctx, operations.AccountAddressDeleteRequest{
		XPublishableKey: "<value>",
		ID:              "D4g3h5tBuVYK9",
	})
	if err != nil {
		log.Fatal(err)
	}
	if res != nil {
		// handle response
	}
}

Per-Operation Security Schemes

Some operations in this SDK require the security scheme to be specified at the request level. For example:

package main

import (
	"context"
	testboltapi "github.com/speakeasy-sdks/Test_Bolt_API"
	"github.com/speakeasy-sdks/Test_Bolt_API/pkg/models/operations"
	"github.com/speakeasy-sdks/Test_Bolt_API/pkg/models/shared"
	"log"
)

func main() {
	s := testboltapi.New()

	operationSecurity := operations.GuestPaymentsInitializeSecurity{
		APIKey: "<YOUR_API_KEY_HERE>",
	}

	ctx := context.Background()
	res, err := s.Payments.Guest.Initialize(ctx, operations.GuestPaymentsInitializeRequest{
		XPublishableKey: "<value>",
		GuestPaymentInitializeRequest: shared.GuestPaymentInitializeRequest{
			Cart: shared.Cart{
				DisplayID:        testboltapi.String("215614191"),
				OrderDescription: testboltapi.String("Order #1234567890"),
				OrderReference:   "order_100",
				Tax: shared.Amount{
					Currency: shared.CurrencyUsd,
					Units:    900,
				},
				Total: shared.Amount{
					Currency: shared.CurrencyUsd,
					Units:    900,
				},
			},
			PaymentMethod: shared.CreatePaymentMethodPaymentMethodCreditCard(
				shared.PaymentMethodCreditCard{
					DotTag: shared.PaymentMethodCreditCardTagCreditCard,
					BillingAddress: shared.CreateAddressReferenceSchemasInput(
						shared.SchemasInput{
							DotTag:         shared.SchemasTagExplicit,
							Company:        testboltapi.String("ACME Corporation"),
							CountryCode:    shared.SchemasCountryCodeUs,
							Email:          testboltapi.String("[email protected]"),
							FirstName:      "Alice",
							LastName:       "Baker",
							Locality:       "San Francisco",
							Phone:          testboltapi.String("+14155550199"),
							PostalCode:     "94105",
							Region:         testboltapi.String("CA"),
							StreetAddress1: "535 Mission St, Ste 1401",
							StreetAddress2: testboltapi.String("c/o Shipping Department"),
						},
					),
					Bin:        "411111",
					Expiration: "2029-03",
					Last4:      "1004",
					Network:    shared.NetworkVisa,
					Token:      "a1B2c3D4e5F6G7H8i9J0k1L2m3N4o5P6Q7r8S9t0",
				},
			),
			Profile: shared.ProfileCreationData{
				CreateAccount: true,
				Email:         "[email protected]",
				FirstName:     "Alice",
				LastName:      "Baker",
				Phone:         testboltapi.String("+14155550199"),
			},
		},
	}, operationSecurity)
	if err != nil {
		log.Fatal(err)
	}
	if res.PaymentResponse != nil {
		// handle response
	}
}

Maturity

This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.

Contributions

While we value open-source contributions to this SDK, this library is generated programmatically. Feel free to open a PR or a Github issue as a proof of concept and we'll do our best to include it in a future release!

SDK Created by Speakeasy

# Packages

No description provided by the author

# Functions

Bool provides a helper function to return a pointer to a bool.
Float32 provides a helper function to return a pointer to a float32.
Float64 provides a helper function to return a pointer to a float64.
Int provides a helper function to return a pointer to an int.
Int64 provides a helper function to return a pointer to an int64.
New creates a new instance of the SDK with the provided options.
String provides a helper function to return a pointer to a string.
WithClient allows the overriding of the default HTTP client used by the SDK.
WithEnvironment allows setting the environment variable for url substitution.
No description provided by the author
WithSecurity configures the SDK to use the provided security details.
WithSecuritySource configures the SDK to invoke the Security Source function on each method call to determine authentication.
WithServerIndex allows the overriding of the default server by index.
WithServerURL allows the overriding of the default server URL.
WithTemplatedServerURL allows the overriding of the default server URL with a templated URL populated with the provided parameters.

# Constants

No description provided by the author
No description provided by the author

# Variables

ServerList contains the list of servers available to the SDK.

# Structs

Account endpoints allow you to view and manage shoppers' accounts.
No description provided by the author
No description provided by the author
OAuth - Use this endpoint to retrieve an OAuth token.
No description provided by the author
TestBolt - Bolt API Reference: A comprehensive Bolt API reference for interacting with Transactions, Orders, Product Catalog, Configuration, Testing, and much more.
Testing - Endpoints that allow you to generate and retrieve test data to verify certain flows in non-production environments.

# Interfaces

HTTPClient provides an interface for suplying the SDK with a custom HTTP client.

# Type aliases

No description provided by the author
No description provided by the author