bar

package module
v0.8.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2024 License: MIT Imports: 12 Imported by: 0

README ΒΆ

github.com/speakeasy-sdks/bar-go

πŸ— Welcome to your new SDK! πŸ—

It has been generated successfully based on your OpenAPI spec. However, it is not yet ready for production use. Here are some next steps:

SDK Installation

go get github.com/speakeasy-sdks/bar

SDK Example Usage

Sign in

First you need to send an authentication request to the API by providing your username and password. In the request body, you should specify the type of token you would like to receive: API key or JSON Web Token. If your credentials are valid, you will receive a token in the response object: res.object.token: str.

package main

import (
	"context"
	"github.com/speakeasy-sdks/bar"
	"log"
)

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

	operationSecurity := bar.LoginSecurity{
		Username: "<USERNAME>",
		Password: "<PASSWORD>",
	}

	ctx := context.Background()
	res, err := s.Authentication.Login(ctx, bar.LoginRequestBody{
		Type: bar.TypeAPIKey,
	}, operationSecurity)
	if err != nil {
		log.Fatal(err)
	}
	if res.Object != nil {
		// handle response
	}
}

Browse available drinks

Once you are authenticated, you can use the token you received for all other authenticated endpoints. For example, you can filter the list of available drinks by type.

package main

import (
	"context"
	"github.com/speakeasy-sdks/bar"
	"log"
)

func main() {
	s := bar.New(
		bar.WithSecurity(bar.Security{
			APIKey: bar.String("<YOUR_API_KEY>"),
		}),
	)

	var drinkType *DrinkType = bar.DrinkTypeSpirit.ToPointer()

	ctx := context.Background()
	res, err := s.Drinks.ListDrinks(ctx, drinkType)
	if err != nil {
		log.Fatal(err)
	}
	if res.Classes != nil {
		// handle response
	}
}

Create an order

When you submit an order, you can include a callback URL along your request. This URL will get called whenever the supplier updates the status of your order.

package main

import (
	"context"
	"github.com/speakeasy-sdks/bar"
	"log"
)

func main() {
	s := bar.New(
		bar.WithSecurity(bar.Security{
			APIKey: bar.String("<YOUR_API_KEY>"),
		}),
	)

	requestBody := []bar.OrderInput{
		bar.OrderInput{
			Type:        bar.OrderTypeIngredient,
			ProductCode: "AC-A2DF3",
			Quantity:    138554,
		},
	}

	var callbackURL *string = bar.String("<value>")

	ctx := context.Background()
	res, err := s.Orders.CreateOrder(ctx, requestBody, callbackURL)
	if err != nil {
		log.Fatal(err)
	}
	if res.Order != nil {
		// handle response
	}
}

Subscribe to webhooks to receive stock updates
package main

import (
	"context"
	"github.com/speakeasy-sdks/bar"
	"log"
)

func main() {
	s := bar.New(
		bar.WithSecurity(bar.Security{
			APIKey: bar.String("<YOUR_API_KEY>"),
		}),
	)

	ctx := context.Background()
	res, err := s.Config.SubscribeToWebhooks(ctx, []bar.RequestBody{
		bar.RequestBody{},
	})
	if err != nil {
		log.Fatal(err)
	}
	if res != nil {
		// handle response
	}
}

Available Resources and Operations

Authentication
  • Login - Authenticate with the API by providing a username and password.
Drinks
Ingredients
Orders
Config

Retries

Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.

To change the default retry strategy for a single API call, simply provide a RetryConfig object to the call by using the WithRetries option:

package main

import (
	""
	"context"
	"github.com/speakeasy-sdks/bar"
	"github.com/speakeasy-sdks/bar/internal/utils"
	"log"
)

func main() {
	s := bar.New(
		bar.WithSecurity(bar.Security{
			APIKey: bar.String("<YOUR_API_KEY>"),
		}),
	)

	ctx := context.Background()
	res, err := s.Config.SubscribeToWebhooks(ctx, []bar.RequestBody{
		bar.RequestBody{},
	}, bar.WithRetries(
		utils.RetryConfig{
			Strategy: "backoff",
			Backoff: &utils.BackoffStrategy{
				InitialInterval: 1,
				MaxInterval:     50,
				Exponent:        1.1,
				MaxElapsedTime:  100,
			},
			RetryConnectionErrors: false,
		}))
	if err != nil {
		log.Fatal(err)
	}
	if res != nil {
		// handle response
	}
}

If you'd like to override the default retry strategy for all operations that support retries, you can use the WithRetryConfig option at SDK initialization:

package main

import (
	"context"
	"github.com/speakeasy-sdks/bar"
	"github.com/speakeasy-sdks/bar/internal/utils"
	"log"
)

func main() {
	s := bar.New(
		bar.WithRetryConfig(
			utils.RetryConfig{
				Strategy: "backoff",
				Backoff: &utils.BackoffStrategy{
					InitialInterval: 1,
					MaxInterval:     50,
					Exponent:        1.1,
					MaxElapsedTime:  100,
				},
				RetryConnectionErrors: false,
			}),
		bar.WithSecurity(bar.Security{
			APIKey: bar.String("<YOUR_API_KEY>"),
		}),
	)

	ctx := context.Background()
	res, err := s.Config.SubscribeToWebhooks(ctx, []bar.RequestBody{
		bar.RequestBody{},
	})
	if err != nil {
		log.Fatal(err)
	}
	if res != nil {
		// handle response
	}
}

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 Object Status Code Content Type
bar.BadRequest 400 application/json
bar.APIError 5XX application/json
bar.SDKError 4xx-5xx /
Example
package main

import (
	"context"
	"errors"
	"github.com/speakeasy-sdks/bar"
	"log"
)

func main() {
	s := bar.New(
		bar.WithSecurity(bar.Security{
			APIKey: bar.String("<YOUR_API_KEY>"),
		}),
	)

	ctx := context.Background()
	res, err := s.Config.SubscribeToWebhooks(ctx, []bar.RequestBody{
		bar.RequestBody{},
	})
	if err != nil {

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

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

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

Server Selection

Select Server by Name

You can override the default server globally using the WithServer 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 names associated with the available servers:

Name Server Variables
prod https://speakeasy.bar None
staging https://staging.speakeasy.bar None
customer https://{organization}.{environment}.speakeasy.bar organization (default is api), environment (default is prod)
Example
package main

import (
	"context"
	"github.com/speakeasy-sdks/bar"
	"log"
)

func main() {
	s := bar.New(
		bar.WithServer("customer"),
		bar.WithSecurity(bar.Security{
			APIKey: bar.String("<YOUR_API_KEY>"),
		}),
	)

	ingredients := []string{
		"<value>",
	}

	ctx := context.Background()
	res, err := s.Ingredients.ListIngredients(ctx, ingredients)
	if err != nil {
		log.Fatal(err)
	}
	if res.Classes != 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:

  • WithOrganization string
  • WithEnvironment bar.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"
	"github.com/speakeasy-sdks/bar"
	"log"
)

func main() {
	s := bar.New(
		bar.WithServerURL("https://speakeasy.bar"),
		bar.WithSecurity(bar.Security{
			APIKey: bar.String("<YOUR_API_KEY>"),
		}),
	)

	ingredients := []string{
		"<value>",
	}

	ctx := context.Background()
	res, err := s.Ingredients.ListIngredients(ctx, ingredients)
	if err != nil {
		log.Fatal(err)
	}
	if res.Classes != nil {
		// handle response
	}
}

Override Server URL Per-Operation

The server URL can also be overridden on a per-operation basis, provided a server list was specified for the operation. For example:

package main

import (
	"context"
	"github.com/speakeasy-sdks/bar"
	"log"
)

func main() {
	s := bar.New(
		bar.WithSecurity(bar.Security{
			APIKey: bar.String("<YOUR_API_KEY>"),
		}),
	)

	var drinkType *DrinkType = bar.DrinkTypeSpirit.ToPointer()

	ctx := context.Background()
	res, err := s.Drinks.ListDrinks(ctx, bar.WithServerURL("https://speakeasy.bar"), drinkType)
	if err != nil {
		log.Fatal(err)
	}
	if res.Classes != 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:

Name Type Scheme
APIKey apiKey API key
BearerAuth http HTTP Bearer

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"
	"github.com/speakeasy-sdks/bar"
	"log"
)

func main() {
	s := bar.New(
		bar.WithSecurity(bar.Security{
			APIKey: bar.String("<YOUR_API_KEY>"),
		}),
	)

	ingredients := []string{
		"<value>",
	}

	ctx := context.Background()
	res, err := s.Ingredients.ListIngredients(ctx, ingredients)
	if err != nil {
		log.Fatal(err)
	}
	if res.Classes != 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"
	"github.com/speakeasy-sdks/bar"
	"log"
)

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

	operationSecurity := bar.LoginSecurity{
		Username: "<USERNAME>",
		Password: "<PASSWORD>",
	}

	ctx := context.Background()
	res, err := s.Authentication.Login(ctx, bar.LoginRequestBody{
		Type: bar.TypeAPIKey,
	}, operationSecurity)
	if err != nil {
		log.Fatal(err)
	}
	if res.Object != nil {
		// handle response
	}
}

Special Types

Development

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

Documentation ΒΆ

Index ΒΆ

Constants ΒΆ

View Source
const (
	SupportedOptionServerURL            = "serverURL"
	SupportedOptionRetries              = "retries"
	SupportedOptionAcceptHeaderOverride = "acceptHeaderOverride"
)
View Source
const (
	// The production server.
	ServerProd string = "prod"
	// The staging server.
	ServerStaging string = "staging"
	// A per-organization and per-environment API.
	ServerCustomer string = "customer"
)

Variables ΒΆ

View Source
var ErrUnsupportedOption = errors.New("unsupported option")
View Source
var ListDrinksOpServerList = []string{
	"https://speakeasy.bar",
	"https://test.speakeasy.bar",
}
View Source
var ServerList = map[string]string{
	ServerProd:     "https://speakeasy.bar",
	ServerStaging:  "https://staging.speakeasy.bar",
	ServerCustomer: "https://{organization}.{environment}.speakeasy.bar",
}

ServerList contains the list of servers available to the SDK

Functions ΒΆ

func Bool ΒΆ

func Bool(b bool) *bool

Bool provides a helper function to return a pointer to a bool

func Float32 ΒΆ

func Float32(f float32) *float32

Float32 provides a helper function to return a pointer to a float32

func Float64 ΒΆ

func Float64(f float64) *float64

Float64 provides a helper function to return a pointer to a float64

func Int ΒΆ

func Int(i int) *int

Int provides a helper function to return a pointer to an int

func Int64 ΒΆ

func Int64(i int64) *int64

Int64 provides a helper function to return a pointer to an int64

func String ΒΆ

func String(s string) *string

String provides a helper function to return a pointer to a string

Types ΒΆ

type APIError ΒΆ

type APIError struct {
	Code    *string                `json:"code,omitempty"`
	Message *string                `json:"message,omitempty"`
	Details map[string]interface{} `json:"details,omitempty"`
}

APIError - An error occurred interacting with the API.

func (*APIError) Error ΒΆ

func (e *APIError) Error() string

type Authentication ΒΆ

type Authentication struct {
	// contains filtered or unexported fields
}

Authentication - The authentication endpoints.

func (*Authentication) Login ΒΆ

func (s *Authentication) Login(ctx context.Context, request LoginRequestBody, security LoginSecurity) (*LoginResponse, error)

Login - Authenticate with the API by providing a username and password.

type BadRequest ΒΆ added in v0.2.1

type BadRequest struct {
	// HTTP status code
	StatusCode *float64 `json:"status_code,omitempty"`
	// Contains an explanation of the status_code as defined in HTTP/1.1 standard (RFC 7231)
	Error_ *string `json:"error,omitempty"`
	// The type of error returned
	TypeName *string `json:"type_name,omitempty"`
}

func (*BadRequest) Error ΒΆ added in v0.2.1

func (e *BadRequest) Error() string

type Config ΒΆ

type Config struct {
	// contains filtered or unexported fields
}

func (*Config) SubscribeToWebhooks ΒΆ

func (s *Config) SubscribeToWebhooks(ctx context.Context, request []RequestBody, opts ...Option) (*SubscribeToWebhooksResponse, error)

SubscribeToWebhooks - Subscribe to webhooks. Subscribe to webhooks.

type CreateOrderOrderUpdateRequestBody ΒΆ

type CreateOrderOrderUpdateRequestBody struct {
	// An order for a drink or ingredient.
	Order *OrderInput `json:"order,omitempty"`
}

func (*CreateOrderOrderUpdateRequestBody) GetOrder ΒΆ

type CreateOrderOrderUpdateResponse ΒΆ

type CreateOrderOrderUpdateResponse struct {
	// HTTP response content type for this operation
	ContentType string
	// HTTP response status code for this operation
	StatusCode int
	// Raw HTTP response; suitable for custom response parsing
	RawResponse *http.Response
	// An unknown error occurred interacting with the API.
	Error *Error
}

func (*CreateOrderOrderUpdateResponse) GetContentType ΒΆ

func (o *CreateOrderOrderUpdateResponse) GetContentType() string

func (*CreateOrderOrderUpdateResponse) GetError ΒΆ added in v0.3.0

func (o *CreateOrderOrderUpdateResponse) GetError() *Error

func (*CreateOrderOrderUpdateResponse) GetRawResponse ΒΆ

func (o *CreateOrderOrderUpdateResponse) GetRawResponse() *http.Response

func (*CreateOrderOrderUpdateResponse) GetStatusCode ΒΆ

func (o *CreateOrderOrderUpdateResponse) GetStatusCode() int

type CreateOrderRequest ΒΆ

type CreateOrderRequest struct {
	RequestBody []OrderInput `request:"mediaType=application/json"`
	// The url to call when the order is updated.
	CallbackURL *string `queryParam:"style=form,explode=true,name=callback_url"`
}

func (*CreateOrderRequest) GetCallbackURL ΒΆ

func (o *CreateOrderRequest) GetCallbackURL() *string

func (*CreateOrderRequest) GetRequestBody ΒΆ

func (o *CreateOrderRequest) GetRequestBody() []OrderInput

type CreateOrderResponse ΒΆ

type CreateOrderResponse struct {
	// HTTP response content type for this operation
	ContentType string
	// HTTP response status code for this operation
	StatusCode int
	// Raw HTTP response; suitable for custom response parsing
	RawResponse *http.Response
	// The order was created successfully.
	Order *Order
	// An unknown error occurred interacting with the API.
	Error *Error
}

func (*CreateOrderResponse) GetContentType ΒΆ

func (o *CreateOrderResponse) GetContentType() string

func (*CreateOrderResponse) GetError ΒΆ added in v0.3.0

func (o *CreateOrderResponse) GetError() *Error

func (*CreateOrderResponse) GetOrder ΒΆ

func (o *CreateOrderResponse) GetOrder() *Order

func (*CreateOrderResponse) GetRawResponse ΒΆ

func (o *CreateOrderResponse) GetRawResponse() *http.Response

func (*CreateOrderResponse) GetStatusCode ΒΆ

func (o *CreateOrderResponse) GetStatusCode() int

type Drink ΒΆ

type Drink struct {
	// The name of the drink.
	Name string `json:"name"`
	// The type of drink.
	Type *DrinkType `json:"type,omitempty"`
	// The price of one unit of the drink in US cents.
	Price float64 `json:"price"`
	// The number of units of the drink in stock, only available when authenticated.
	Stock *int64 `json:"stock,omitempty"`
	// The product code of the drink, only available when authenticated.
	ProductCode *string `json:"productCode,omitempty"`
}

func (*Drink) GetName ΒΆ

func (o *Drink) GetName() string

func (*Drink) GetPrice ΒΆ

func (o *Drink) GetPrice() float64

func (*Drink) GetProductCode ΒΆ

func (o *Drink) GetProductCode() *string

func (*Drink) GetStock ΒΆ

func (o *Drink) GetStock() *int64

func (*Drink) GetType ΒΆ

func (o *Drink) GetType() *DrinkType

type DrinkInput ΒΆ

type DrinkInput struct {
	// The name of the drink.
	Name string `json:"name"`
	// The type of drink.
	Type *DrinkType `json:"type,omitempty"`
	// The price of one unit of the drink in US cents.
	Price float64 `json:"price"`
	// The product code of the drink, only available when authenticated.
	ProductCode *string `json:"productCode,omitempty"`
}

func (*DrinkInput) GetName ΒΆ

func (o *DrinkInput) GetName() string

func (*DrinkInput) GetPrice ΒΆ

func (o *DrinkInput) GetPrice() float64

func (*DrinkInput) GetProductCode ΒΆ

func (o *DrinkInput) GetProductCode() *string

func (*DrinkInput) GetType ΒΆ

func (o *DrinkInput) GetType() *DrinkType

type DrinkType ΒΆ

type DrinkType string

DrinkType - The type of drink.

const (
	DrinkTypeCocktail     DrinkType = "cocktail"
	DrinkTypeNonAlcoholic DrinkType = "non-alcoholic"
	DrinkTypeBeer         DrinkType = "beer"
	DrinkTypeWine         DrinkType = "wine"
	DrinkTypeSpirit       DrinkType = "spirit"
	DrinkTypeOther        DrinkType = "other"
)

func (DrinkType) ToPointer ΒΆ

func (e DrinkType) ToPointer() *DrinkType

func (*DrinkType) UnmarshalJSON ΒΆ

func (e *DrinkType) UnmarshalJSON(data []byte) error

type Drinks ΒΆ

type Drinks struct {
	// contains filtered or unexported fields
}

Drinks - The drinks endpoints.

func (*Drinks) GetDrink ΒΆ

func (s *Drinks) GetDrink(ctx context.Context, name string) (*GetDrinkResponse, error)

GetDrink - Get a drink. Get a drink by name, if authenticated this will include stock levels and product codes otherwise it will only include public information.

func (*Drinks) ListDrinks ΒΆ

func (s *Drinks) ListDrinks(ctx context.Context, drinkType *DrinkType, opts ...Option) (*ListDrinksResponse, error)

ListDrinks - Get a list of drinks. Get a list of drinks, if authenticated this will include stock levels and product codes otherwise it will only include public information.

type Error ΒΆ added in v0.3.0

type Error struct {
	Code    *string `json:"code,omitempty"`
	Message *string `json:"message,omitempty"`
}

func (*Error) GetCode ΒΆ added in v0.3.0

func (o *Error) GetCode() *string

func (*Error) GetMessage ΒΆ added in v0.3.0

func (o *Error) GetMessage() *string

type GetDrinkRequest ΒΆ

type GetDrinkRequest struct {
	Name string `pathParam:"style=simple,explode=false,name=name"`
}

func (*GetDrinkRequest) GetName ΒΆ

func (o *GetDrinkRequest) GetName() string

type GetDrinkResponse ΒΆ

type GetDrinkResponse struct {
	// HTTP response content type for this operation
	ContentType string
	// HTTP response status code for this operation
	StatusCode int
	// Raw HTTP response; suitable for custom response parsing
	RawResponse *http.Response
	// A drink.
	Drink *Drink
	// An unknown error occurred interacting with the API.
	Error *Error
}

func (*GetDrinkResponse) GetContentType ΒΆ

func (o *GetDrinkResponse) GetContentType() string

func (*GetDrinkResponse) GetDrink ΒΆ

func (o *GetDrinkResponse) GetDrink() *Drink

func (*GetDrinkResponse) GetError ΒΆ added in v0.3.0

func (o *GetDrinkResponse) GetError() *Error

func (*GetDrinkResponse) GetRawResponse ΒΆ

func (o *GetDrinkResponse) GetRawResponse() *http.Response

func (*GetDrinkResponse) GetStatusCode ΒΆ

func (o *GetDrinkResponse) GetStatusCode() int

type HTTPClient ΒΆ

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

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

type Ingredient ΒΆ

type Ingredient struct {
	// The name of the ingredient.
	Name string `json:"name"`
	// The type of ingredient.
	Type IngredientType `json:"type"`
	// The number of units of the ingredient in stock, only available when authenticated.
	Stock *int64 `json:"stock,omitempty"`
	// The product code of the ingredient, only available when authenticated.
	ProductCode *string `json:"productCode,omitempty"`
}

func (*Ingredient) GetName ΒΆ

func (o *Ingredient) GetName() string

func (*Ingredient) GetProductCode ΒΆ

func (o *Ingredient) GetProductCode() *string

func (*Ingredient) GetStock ΒΆ

func (o *Ingredient) GetStock() *int64

func (*Ingredient) GetType ΒΆ

func (o *Ingredient) GetType() IngredientType

type IngredientInput ΒΆ

type IngredientInput struct {
	// The name of the ingredient.
	Name string `json:"name"`
	// The type of ingredient.
	Type IngredientType `json:"type"`
	// The product code of the ingredient, only available when authenticated.
	ProductCode *string `json:"productCode,omitempty"`
}

func (*IngredientInput) GetName ΒΆ

func (o *IngredientInput) GetName() string

func (*IngredientInput) GetProductCode ΒΆ

func (o *IngredientInput) GetProductCode() *string

func (*IngredientInput) GetType ΒΆ

func (o *IngredientInput) GetType() IngredientType

type IngredientType ΒΆ

type IngredientType string

IngredientType - The type of ingredient.

const (
	IngredientTypeFresh    IngredientType = "fresh"
	IngredientTypeLongLife IngredientType = "long-life"
	IngredientTypePackaged IngredientType = "packaged"
)

func (IngredientType) ToPointer ΒΆ

func (e IngredientType) ToPointer() *IngredientType

func (*IngredientType) UnmarshalJSON ΒΆ

func (e *IngredientType) UnmarshalJSON(data []byte) error

type Ingredients ΒΆ

type Ingredients struct {
	// contains filtered or unexported fields
}

Ingredients - The ingredients endpoints.

func (*Ingredients) ListIngredients ΒΆ

func (s *Ingredients) ListIngredients(ctx context.Context, ingredients []string) (*ListIngredientsResponse, error)

ListIngredients - Get a list of ingredients. Get a list of ingredients, if authenticated this will include stock levels and product codes otherwise it will only include public information.

type ListDrinksRequest ΒΆ

type ListDrinksRequest struct {
	// The type of drink to filter by. If not provided all drinks will be returned.
	DrinkType *DrinkType `queryParam:"style=form,explode=true,name=drinkType"`
}

func (*ListDrinksRequest) GetDrinkType ΒΆ

func (o *ListDrinksRequest) GetDrinkType() *DrinkType

type ListDrinksResponse ΒΆ

type ListDrinksResponse struct {
	// HTTP response content type for this operation
	ContentType string
	// HTTP response status code for this operation
	StatusCode int
	// Raw HTTP response; suitable for custom response parsing
	RawResponse *http.Response
	// A list of drinks.
	Classes []Drink
	// An unknown error occurred interacting with the API.
	Error *Error
}

func (*ListDrinksResponse) GetClasses ΒΆ

func (o *ListDrinksResponse) GetClasses() []Drink

func (*ListDrinksResponse) GetContentType ΒΆ

func (o *ListDrinksResponse) GetContentType() string

func (*ListDrinksResponse) GetError ΒΆ added in v0.3.0

func (o *ListDrinksResponse) GetError() *Error

func (*ListDrinksResponse) GetRawResponse ΒΆ

func (o *ListDrinksResponse) GetRawResponse() *http.Response

func (*ListDrinksResponse) GetStatusCode ΒΆ

func (o *ListDrinksResponse) GetStatusCode() int

type ListIngredientsRequest ΒΆ

type ListIngredientsRequest struct {
	// A list of ingredients to filter by. If not provided all ingredients will be returned.
	Ingredients []string `queryParam:"style=form,explode=false,name=ingredients"`
}

func (*ListIngredientsRequest) GetIngredients ΒΆ

func (o *ListIngredientsRequest) GetIngredients() []string

type ListIngredientsResponse ΒΆ

type ListIngredientsResponse struct {
	// HTTP response content type for this operation
	ContentType string
	// HTTP response status code for this operation
	StatusCode int
	// Raw HTTP response; suitable for custom response parsing
	RawResponse *http.Response
	// A list of ingredients.
	Classes []Ingredient
	// An unknown error occurred interacting with the API.
	Error *Error
}

func (*ListIngredientsResponse) GetClasses ΒΆ

func (o *ListIngredientsResponse) GetClasses() []Ingredient

func (*ListIngredientsResponse) GetContentType ΒΆ

func (o *ListIngredientsResponse) GetContentType() string

func (*ListIngredientsResponse) GetError ΒΆ added in v0.3.0

func (o *ListIngredientsResponse) GetError() *Error

func (*ListIngredientsResponse) GetRawResponse ΒΆ

func (o *ListIngredientsResponse) GetRawResponse() *http.Response

func (*ListIngredientsResponse) GetStatusCode ΒΆ

func (o *ListIngredientsResponse) GetStatusCode() int

type LoginRequestBody ΒΆ

type LoginRequestBody struct {
	Type Type `json:"type"`
}

func (*LoginRequestBody) GetType ΒΆ

func (o *LoginRequestBody) GetType() Type

type LoginResponse ΒΆ

type LoginResponse struct {
	// HTTP response content type for this operation
	ContentType string
	// HTTP response status code for this operation
	StatusCode int
	// Raw HTTP response; suitable for custom response parsing
	RawResponse *http.Response
	// The api key to use for authenticated endpoints.
	Object *LoginResponseBody
	// An unknown error occurred interacting with the API.
	Error *Error
}

func (*LoginResponse) GetContentType ΒΆ

func (o *LoginResponse) GetContentType() string

func (*LoginResponse) GetError ΒΆ added in v0.3.0

func (o *LoginResponse) GetError() *Error

func (*LoginResponse) GetObject ΒΆ

func (o *LoginResponse) GetObject() *LoginResponseBody

func (*LoginResponse) GetRawResponse ΒΆ

func (o *LoginResponse) GetRawResponse() *http.Response

func (*LoginResponse) GetStatusCode ΒΆ

func (o *LoginResponse) GetStatusCode() int

type LoginResponseBody ΒΆ

type LoginResponseBody struct {
	Token *string `json:"token,omitempty"`
}

LoginResponseBody - The api key to use for authenticated endpoints.

func (*LoginResponseBody) GetToken ΒΆ

func (o *LoginResponseBody) GetToken() *string

type LoginSecurity ΒΆ

type LoginSecurity struct {
	Username string `security:"scheme,type=http,subtype=basic,name=username"`
	Password string `security:"scheme,type=http,subtype=basic,name=password"`
}

func (*LoginSecurity) GetPassword ΒΆ

func (o *LoginSecurity) GetPassword() string

func (*LoginSecurity) GetUsername ΒΆ

func (o *LoginSecurity) GetUsername() string

type Option ΒΆ

type Option func(*Options, ...string) error

func WithMethodServerURL ΒΆ

func WithMethodServerURL(serverURL string) Option

WithMethodServerURL allows providing an alternative server URL.

func WithMethodTemplatedServerURL ΒΆ

func WithMethodTemplatedServerURL(serverURL string, params map[string]string) Option

WithMethodTemplatedServerURL allows providing an alternative server URL with templated parameters.

func WithRetries ΒΆ

func WithRetries(config utils.RetryConfig) Option

WithRetries allows customizing the default retry configuration.

type Options ΒΆ

type Options struct {
	ServerURL *string
	Retries   *utils.RetryConfig
}

type Order ΒΆ

type Order struct {
	// The type of order.
	Type OrderType `json:"type"`
	// The product code of the drink or ingredient.
	ProductCode string `json:"productCode"`
	// The number of units of the drink or ingredient to order.
	Quantity int64 `json:"quantity"`
	// The status of the order.
	Status Status `json:"status"`
}

Order - An order for a drink or ingredient.

func (*Order) GetProductCode ΒΆ

func (o *Order) GetProductCode() string

func (*Order) GetQuantity ΒΆ

func (o *Order) GetQuantity() int64

func (*Order) GetStatus ΒΆ

func (o *Order) GetStatus() Status

func (*Order) GetType ΒΆ

func (o *Order) GetType() OrderType

type OrderInput ΒΆ

type OrderInput struct {
	// The type of order.
	Type OrderType `json:"type"`
	// The product code of the drink or ingredient.
	ProductCode string `json:"productCode"`
	// The number of units of the drink or ingredient to order.
	Quantity int64 `json:"quantity"`
}

OrderInput - An order for a drink or ingredient.

func (*OrderInput) GetProductCode ΒΆ

func (o *OrderInput) GetProductCode() string

func (*OrderInput) GetQuantity ΒΆ

func (o *OrderInput) GetQuantity() int64

func (*OrderInput) GetType ΒΆ

func (o *OrderInput) GetType() OrderType

type OrderType ΒΆ

type OrderType string

OrderType - The type of order.

const (
	OrderTypeDrink      OrderType = "drink"
	OrderTypeIngredient OrderType = "ingredient"
)

func (OrderType) ToPointer ΒΆ

func (e OrderType) ToPointer() *OrderType

func (*OrderType) UnmarshalJSON ΒΆ

func (e *OrderType) UnmarshalJSON(data []byte) error

type Orders ΒΆ

type Orders struct {
	// contains filtered or unexported fields
}

Orders - The orders endpoints.

func (*Orders) CreateOrder ΒΆ

func (s *Orders) CreateOrder(ctx context.Context, requestBody []OrderInput, callbackURL *string) (*CreateOrderResponse, error)

CreateOrder - Create an order. Create an order for a drink.

type RequestBody ΒΆ

type RequestBody struct {
	URL     *string  `json:"url,omitempty"`
	Webhook *Webhook `json:"webhook,omitempty"`
}

func (*RequestBody) GetURL ΒΆ

func (o *RequestBody) GetURL() *string

func (*RequestBody) GetWebhook ΒΆ

func (o *RequestBody) GetWebhook() *Webhook

type SDKError ΒΆ

type SDKError struct {
	Message     string
	StatusCode  int
	Body        string
	RawResponse *http.Response
}

func NewSDKError ΒΆ

func NewSDKError(message string, statusCode int, body string, httpRes *http.Response) *SDKError

func (*SDKError) Error ΒΆ

func (e *SDKError) Error() string

type SDKOption ΒΆ

type SDKOption func(*Speakeasy)

func WithClient ΒΆ

func WithClient(client HTTPClient) SDKOption

WithClient allows the overriding of the default HTTP client used by the SDK

func WithEnvironment ΒΆ

func WithEnvironment(environment ServerEnvironment) SDKOption

WithEnvironment allows setting the environment variable for url substitution

func WithOrganization ΒΆ

func WithOrganization(organization string) SDKOption

WithOrganization allows setting the organization variable for url substitution

func WithRetryConfig ΒΆ

func WithRetryConfig(retryConfig utils.RetryConfig) SDKOption

func WithSecurity ΒΆ

func WithSecurity(security Security) SDKOption

WithSecurity configures the SDK to use the provided security details

func WithSecuritySource ΒΆ

func WithSecuritySource(security func(context.Context) (Security, error)) SDKOption

WithSecuritySource configures the SDK to invoke the Security Source function on each method call to determine authentication

func WithServer ΒΆ

func WithServer(server string) SDKOption

WithServer allows the overriding of the default server by name

func WithServerURL ΒΆ

func WithServerURL(serverURL string) SDKOption

WithServerURL allows the overriding of the default server URL

func WithTemplatedServerURL ΒΆ

func WithTemplatedServerURL(serverURL string, params map[string]string) SDKOption

WithTemplatedServerURL allows the overriding of the default server URL with a templated URL populated with the provided parameters

type Security ΒΆ

type Security struct {
	APIKey     *string `security:"scheme,type=apiKey,subtype=header,name=Authorization"`
	BearerAuth *string `security:"scheme,type=http,subtype=bearer,name=Authorization"`
}

func (*Security) GetAPIKey ΒΆ

func (o *Security) GetAPIKey() *string

func (*Security) GetBearerAuth ΒΆ

func (o *Security) GetBearerAuth() *string

type ServerEnvironment ΒΆ

type ServerEnvironment string

ServerEnvironment - The environment name. Defaults to the production environment.

const (
	ServerEnvironmentProd    ServerEnvironment = "prod"
	ServerEnvironmentStaging ServerEnvironment = "staging"
	ServerEnvironmentDev     ServerEnvironment = "dev"
)

func (ServerEnvironment) ToPointer ΒΆ

func (e ServerEnvironment) ToPointer() *ServerEnvironment

func (*ServerEnvironment) UnmarshalJSON ΒΆ

func (e *ServerEnvironment) UnmarshalJSON(data []byte) error

type Speakeasy ΒΆ

type Speakeasy struct {
	// The authentication endpoints.
	Authentication *Authentication
	// The drinks endpoints.
	Drinks *Drinks
	// The ingredients endpoints.
	Ingredients *Ingredients
	// The orders endpoints.
	Orders *Orders
	Config *Config
	// contains filtered or unexported fields
}

The Speakeasy Bar: A bar that serves drinks. A secret underground bar that serves drinks to those in the know.

https://docs.speakeasy.bar - The Speakeasy Bar Documentation.

func New ΒΆ

func New(opts ...SDKOption) *Speakeasy

New creates a new instance of the SDK with the provided options

type Status ΒΆ

type Status string

Status - The status of the order.

const (
	StatusPending    Status = "pending"
	StatusProcessing Status = "processing"
	StatusComplete   Status = "complete"
)

func (Status) ToPointer ΒΆ

func (e Status) ToPointer() *Status

func (*Status) UnmarshalJSON ΒΆ

func (e *Status) UnmarshalJSON(data []byte) error

type StockUpdateRequestBody ΒΆ

type StockUpdateRequestBody struct {
	Drink      *DrinkInput      `json:"drink,omitempty"`
	Ingredient *IngredientInput `json:"ingredient,omitempty"`
}

func (*StockUpdateRequestBody) GetDrink ΒΆ

func (o *StockUpdateRequestBody) GetDrink() *DrinkInput

func (*StockUpdateRequestBody) GetIngredient ΒΆ

func (o *StockUpdateRequestBody) GetIngredient() *IngredientInput

type StockUpdateResponse ΒΆ

type StockUpdateResponse struct {
	// HTTP response content type for this operation
	ContentType string
	// HTTP response status code for this operation
	StatusCode int
	// Raw HTTP response; suitable for custom response parsing
	RawResponse *http.Response
	// An unknown error occurred interacting with the API.
	Error *Error
}

func (*StockUpdateResponse) GetContentType ΒΆ

func (o *StockUpdateResponse) GetContentType() string

func (*StockUpdateResponse) GetError ΒΆ added in v0.3.0

func (o *StockUpdateResponse) GetError() *Error

func (*StockUpdateResponse) GetRawResponse ΒΆ

func (o *StockUpdateResponse) GetRawResponse() *http.Response

func (*StockUpdateResponse) GetStatusCode ΒΆ

func (o *StockUpdateResponse) GetStatusCode() int

type SubscribeToWebhooksResponse ΒΆ

type SubscribeToWebhooksResponse struct {
	// HTTP response content type for this operation
	ContentType string
	// HTTP response status code for this operation
	StatusCode int
	// Raw HTTP response; suitable for custom response parsing
	RawResponse *http.Response
	// An unknown error occurred interacting with the API.
	Error *Error
}

func (*SubscribeToWebhooksResponse) GetContentType ΒΆ

func (o *SubscribeToWebhooksResponse) GetContentType() string

func (*SubscribeToWebhooksResponse) GetError ΒΆ added in v0.3.0

func (o *SubscribeToWebhooksResponse) GetError() *Error

func (*SubscribeToWebhooksResponse) GetRawResponse ΒΆ

func (o *SubscribeToWebhooksResponse) GetRawResponse() *http.Response

func (*SubscribeToWebhooksResponse) GetStatusCode ΒΆ

func (o *SubscribeToWebhooksResponse) GetStatusCode() int

type Type ΒΆ

type Type string
const (
	TypeAPIKey Type = "apiKey"
	TypeJwt    Type = "JWT"
)

func (Type) ToPointer ΒΆ

func (e Type) ToPointer() *Type

func (*Type) UnmarshalJSON ΒΆ

func (e *Type) UnmarshalJSON(data []byte) error

type Webhook ΒΆ

type Webhook string
const (
	WebhookStockUpdate Webhook = "stockUpdate"
)

func (Webhook) ToPointer ΒΆ

func (e Webhook) ToPointer() *Webhook

func (*Webhook) UnmarshalJSON ΒΆ

func (e *Webhook) UnmarshalJSON(data []byte) error

Directories ΒΆ

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL