stripe

package
v1.19.4 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const APIVersion = "2019-03-14"

APIVersion is API version used in CLI

View Source
const DefaultAPIBaseURL = "https://api.stripe.com"

DefaultAPIBaseURL is the default base URL for API requests

View Source
const DefaultDashboardBaseURL = "https://dashboard.stripe.com"

DefaultDashboardBaseURL is the default base URL for dashboard requests

View Source
const DefaultFilesAPIBaseURL = "https://files.stripe.com"

DefaultFilesAPIBaseURL is the default base URL for Files API requsts

View Source
const DefaultTelemetryEndpoint = "https://r.stripe.com/0"

DefaultTelemetryEndpoint is the default URL for the telemetry destination

Variables

This section is empty.

Functions

func TelemetryOptedOut added in v1.7.4

func TelemetryOptedOut(optoutVar string) bool

TelemetryOptedOut returns true if the user has opted out of telemetry, false otherwise.

func WithEventMetadata added in v1.7.4

func WithEventMetadata(ctx context.Context, metadata *CLIAnalyticsEventMetadata) context.Context

WithEventMetadata returns a new copy of context.Context with the provided CLIAnalyticsEventMetadata

func WithTelemetryClient added in v1.7.4

func WithTelemetryClient(ctx context.Context, client TelemetryClient) context.Context

WithTelemetryClient returns a new copy of context.Context with the provided telemetryClient

Types

type AnalyticsTelemetryClient added in v1.7.4

type AnalyticsTelemetryClient struct {
	BaseURL *url.URL

	HTTPClient *http.Client
	// contains filtered or unexported fields
}

AnalyticsTelemetryClient sends event information to r.stripe.com

func (*AnalyticsTelemetryClient) SendAPIRequestEvent added in v1.7.4

func (a *AnalyticsTelemetryClient) SendAPIRequestEvent(ctx context.Context, requestID string, livemode bool) (*http.Response, error)

SendAPIRequestEvent is a special function for API requests

func (*AnalyticsTelemetryClient) SendEvent added in v1.7.4

func (a *AnalyticsTelemetryClient) SendEvent(ctx context.Context, eventName string, eventValue string)

SendEvent sends a telemetry event to r.stripe.com

func (*AnalyticsTelemetryClient) Wait added in v1.7.4

func (a *AnalyticsTelemetryClient) Wait()

Wait will return when all in-flight telemetry requests are complete.

type CLIAnalyticsEventMetadata added in v1.7.4

type CLIAnalyticsEventMetadata struct {
	InvocationID      string `url:"invocation_id"`      // The invocation id is unique to each context object and represents all events coming from one command / gRPC method call
	UserAgent         string `url:"user_agent"`         // the application that is used to create this request
	CommandPath       string `url:"command_path"`       // the command or gRPC method that initiated this request
	Merchant          string `url:"merchant"`           // the merchant ID: ex. acct_xxxx
	CLIVersion        string `url:"cli_version"`        // the version of the CLI
	OS                string `url:"os"`                 // the OS of the system
	GeneratedResource bool   `url:"generated_resource"` // whether or not this was a generated resource
}

CLIAnalyticsEventMetadata is the structure that holds telemetry data context that is ultimately sent to the Stripe Analytics Service.

func GetEventMetadata added in v1.7.4

func GetEventMetadata(ctx context.Context) *CLIAnalyticsEventMetadata

GetEventMetadata returns the CLIAnalyticsEventMetadata from the provided context

func NewEventMetadata added in v1.7.4

func NewEventMetadata() *CLIAnalyticsEventMetadata

NewEventMetadata initializes an instance of CLIAnalyticsEventContext

func (*CLIAnalyticsEventMetadata) SetCobraCommandContext added in v1.7.4

func (e *CLIAnalyticsEventMetadata) SetCobraCommandContext(cmd *cobra.Command)

SetCobraCommandContext sets the telemetry values for the command being executed.

func (*CLIAnalyticsEventMetadata) SetCommandPath added in v1.7.4

func (e *CLIAnalyticsEventMetadata) SetCommandPath(commandPath string)

SetCommandPath sets the commandPath on the CLIAnalyticsEventContext object

func (*CLIAnalyticsEventMetadata) SetMerchant added in v1.7.4

func (e *CLIAnalyticsEventMetadata) SetMerchant(merchant string)

SetMerchant sets the merchant on the CLIAnalyticsEventContext object

func (*CLIAnalyticsEventMetadata) SetUserAgent added in v1.7.4

func (e *CLIAnalyticsEventMetadata) SetUserAgent(userAgent string)

SetUserAgent sets the userAgent on the CLIAnalyticsEventContext object

type Client

type Client struct {
	// The base URL (protocol + hostname) used for all requests sent by this
	// client.
	BaseURL *url.URL

	// API key used to authenticate requests sent by this client. If left
	// empty, the `Authorization` header will be omitted.
	APIKey string

	// When this is enabled, request and response headers will be printed to
	// stdout.
	Verbose bool

	// List of request and response headers that should be printed when Verbose is true.
	// Defaults to the standard set of relevant for Stripe headers.
	VerbosePrintableHeaders []string
	// contains filtered or unexported fields
}

Client is the API client used to sent requests to Stripe.

func (*Client) PerformRequest

func (c *Client) PerformRequest(ctx context.Context, method, path string, params string, configure func(*http.Request) error) (*http.Response, error)

PerformRequest sends a request to Stripe and returns the response.

type NoOpTelemetryClient added in v1.7.4

type NoOpTelemetryClient struct {
}

NoOpTelemetryClient does not call any endpoint and returns an empty response

func (*NoOpTelemetryClient) SendAPIRequestEvent added in v1.7.4

func (a *NoOpTelemetryClient) SendAPIRequestEvent(ctx context.Context, requestID string, livemode bool) (*http.Response, error)

SendAPIRequestEvent does nothing

func (*NoOpTelemetryClient) SendEvent added in v1.7.4

func (a *NoOpTelemetryClient) SendEvent(ctx context.Context, eventName string, eventValue string)

SendEvent does nothing

type RequestPerformer added in v1.14.1

type RequestPerformer interface {
	PerformRequest(ctx context.Context, method, path string, params string, configure func(*http.Request) error) (*http.Response, error)
}

RequestPerformer is an interface for executing requests against the Stripe API, usually satisfied by providing a stripe.Client.

type TelemetryClient added in v1.7.4

type TelemetryClient interface {
	SendAPIRequestEvent(ctx context.Context, requestID string, livemode bool) (*http.Response, error)
	SendEvent(ctx context.Context, eventName string, eventValue string)
}

TelemetryClient is an interface that can send two types of events: an API request, and just general events.

func GetTelemetryClient added in v1.7.4

func GetTelemetryClient(ctx context.Context) TelemetryClient

GetTelemetryClient returns the CLIAnalyticsEventMetadata from the provided context

Jump to

Keyboard shortcuts

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