Categorygithub.com/speakeasy-sdks/bolt-embedded-go
modulepackage
0.12.3
Repository: https://github.com/speakeasy-sdks/bolt-embedded-go.git
Documentation: pkg.go.dev

# README

github.com/speakeasy-sdks/bolt-embedded-go

SDK Installation

go get github.com/speakeasy-sdks/bolt-embedded-go

SDK Example Usage

Example

package main

import (
	"context"
	boltembeddedgo "github.com/speakeasy-sdks/bolt-embedded-go"
	"github.com/speakeasy-sdks/bolt-embedded-go/pkg/models/operations"
	"log"
)

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

	operationSecurity := operations.AddAddressSecurity{
		OAuth:   "Bearer <YOUR_ACCESS_TOKEN_HERE>",
		XAPIKey: "<YOUR_API_KEY_HERE>",
	}

	ctx := context.Background()
	res, err := s.Account.AddAddress(ctx, operations.AddAddressRequest{}, operationSecurity)
	if err != nil {
		log.Fatal(err)
	}
	if res.Object != nil {
		// handle response
	}
}

Available Resources and Operations

Account

Transactions

OAuth

Payments

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.ErrorsBoltAPIResponse403,404application/json
sdkerrors.SDKError4xx-5xx/

Example

package main

import (
	"context"
	"errors"
	boltembeddedgo "github.com/speakeasy-sdks/bolt-embedded-go"
	"github.com/speakeasy-sdks/bolt-embedded-go/pkg/models/operations"
	"github.com/speakeasy-sdks/bolt-embedded-go/pkg/models/sdkerrors"
	"log"
)

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

	operationSecurity := operations.DeletePaymentMethodSecurity{
		OAuth:   "Bearer <YOUR_ACCESS_TOKEN_HERE>",
		XAPIKey: "<YOUR_API_KEY_HERE>",
	}

	ctx := context.Background()
	res, err := s.Account.DeletePaymentMethod(ctx, operations.DeletePaymentMethodRequest{
		PaymentMethodID: "<value>",
	}, operationSecurity)
	if err != nil {

		var e *sdkerrors.ErrorsBoltAPIResponse
		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://api.bolt.comNone
1https://api-sandbox.bolt.comNone
2https://api-staging.bolt.comNone

Example

package main

import (
	"context"
	boltembeddedgo "github.com/speakeasy-sdks/bolt-embedded-go"
	"github.com/speakeasy-sdks/bolt-embedded-go/pkg/models/operations"
	"log"
)

func main() {
	s := boltembeddedgo.New(
		boltembeddedgo.WithServerIndex(2),
	)

	operationSecurity := operations.AddAddressSecurity{
		OAuth:   "Bearer <YOUR_ACCESS_TOKEN_HERE>",
		XAPIKey: "<YOUR_API_KEY_HERE>",
	}

	ctx := context.Background()
	res, err := s.Account.AddAddress(ctx, operations.AddAddressRequest{}, operationSecurity)
	if err != nil {
		log.Fatal(err)
	}
	if res.Object != nil {
		// handle response
	}
}

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"
	boltembeddedgo "github.com/speakeasy-sdks/bolt-embedded-go"
	"github.com/speakeasy-sdks/bolt-embedded-go/pkg/models/operations"
	"log"
)

func main() {
	s := boltembeddedgo.New(
		boltembeddedgo.WithServerURL("https://api.bolt.com"),
	)

	operationSecurity := operations.AddAddressSecurity{
		OAuth:   "Bearer <YOUR_ACCESS_TOKEN_HERE>",
		XAPIKey: "<YOUR_API_KEY_HERE>",
	}

	ctx := context.Background()
	res, err := s.Account.AddAddress(ctx, operations.AddAddressRequest{}, operationSecurity)
	if err != nil {
		log.Fatal(err)
	}
	if res.Object != 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
OAuthoauth2OAuth2 token
XAPIKeyapiKeyAPI key

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"
	boltembeddedgo "github.com/speakeasy-sdks/bolt-embedded-go"
	"github.com/speakeasy-sdks/bolt-embedded-go/pkg/models/operations"
	"github.com/speakeasy-sdks/bolt-embedded-go/pkg/models/shared"
	"log"
)

func main() {
	s := boltembeddedgo.New(
		boltembeddedgo.WithSecurity(shared.Security{
			OAuth: boltembeddedgo.String("Bearer <YOUR_ACCESS_TOKEN_HERE>"),
		}),
	)

	ctx := context.Background()
	res, err := s.Account.CreateAccount(ctx, operations.CreateAccountRequest{})
	if err != nil {
		log.Fatal(err)
	}
	if res.AccountDetails != 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"
	boltembeddedgo "github.com/speakeasy-sdks/bolt-embedded-go"
	"github.com/speakeasy-sdks/bolt-embedded-go/pkg/models/operations"
	"log"
)

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

	operationSecurity := operations.AddAddressSecurity{
		OAuth:   "Bearer <YOUR_ACCESS_TOKEN_HERE>",
		XAPIKey: "<YOUR_API_KEY_HERE>",
	}

	ctx := context.Background()
	res, err := s.Account.AddAddress(ctx, operations.AddAddressRequest{}, operationSecurity)
	if err != nil {
		log.Fatal(err)
	}
	if res.Object != 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.
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.

# Variables

ServerList contains the list of servers available to the SDK.

# Structs

Account - Create Embedded Accounts user flows for logged-in and guest experiences by interacting with and updating shopper data.
BoltEmbeddedAPI - Embedded API Reference: Postman Collection: [![](https://run.pstmn.io/button.svg)](https://god.gw.postman.com/run-collection/9136127-55d2bde1-a248-473f-95b5-64cfd02fb445?action=collection%2Ffork&collection-url=entityId%3D9136127-55d2bde1-a248-473f-95b5-64cfd02fb445%26entityType%3Dcollection%26workspaceId%3D78beee89-4238-4c5f-bd1f-7e98978744b4#?env%5BBolt%20Sandbox%20Environment%5D=W3sia2V5IjoiYXBpX2Jhc2VfdXJsIiwidmFsdWUiOiJodHRwczovL2FwaS1zYW5kYm94LmJvbHQuY29tIiwidHlwZSI6ImRlZmF1bHQiLCJlbmFibGVkIjp0cnVlfSx7ImtleSI6InRrX2Jhc2UiLCJ2YWx1ZSI6Imh0dHBzOi8vc2FuZGJveC5ib2x0dGsuY29tIiwidHlwZSI6ImRlZmF1bHQiLCJlbmFibGVkIjp0cnVlfSx7ImtleSI6ImFwaV9rZXkiLCJ2YWx1ZSI6IjxyZXBsYWNlIHdpdGggeW91ciBCb2x0IFNhbmRib3ggQVBJIGtleT4iLCJ0eXBlIjoic2VjcmV0IiwiZW5hYmxlZCI6dHJ1ZX0seyJrZXkiOiJwdWJsaXNoYWJsZV9rZXkiLCJ2YWx1ZSI6IjxyZXBsYWNlIHdpdGggeW91ciBCb2x0IFNhbmRib3ggcHVibGlzaGFibGUga2V5PiIsInR5cGUiOiJkZWZhdWx0IiwiZW5hYmxlZCI6dHJ1ZX0seyJrZXkiOiJkaXZpc2lvbl9pZCIsInZhbHVlIjoiPHJlcGxhY2Ugd2l0aCB5b3VyIEJvbHQgU2FuZGJveCBwdWJsaWMgZGl2aXNpb24gSUQ+IiwidHlwZSI6ImRlZmF1bHQiLCJlbmFibGVkIjp0cnVlfV0=) ## About The Embedded API reference is a consolidation of critical APIs that a developer will use when integrating with Bolt's Embedded Accounts product suite.
OAuth - Interact with Shopper data by completing the Bolt OAuth process.
Payments - Create and manage transactions for non credit card payments such as Paypal in your Embedded Accounts experience.
Testing - A collection of endpoints that provide useful functionality to assist in testing your Bolt integration.
Transactions - Authorize credit card transactions and perform operations on those transactions with Bolt's transaction API.

# Interfaces

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

# Type aliases

No description provided by the author