requests

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: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAPIKeyExpiredError added in v1.7.9

func IsAPIKeyExpiredError(err error) bool

IsAPIKeyExpiredError returns true if the provided error was caused by a request returning an `api_key_expired` error code.

See https://stripe.com/docs/error-codes/api-key-expired.

func SignRequest added in v1.14.2

func SignRequest(req *http.Request, privKey string) error

SignRequest takes the http request and signs the request to send to Stripe. You MUST call this function AFTER all headers on the request have been set.

func WebhookEndpointCreate added in v1.7.12

func WebhookEndpointCreate(ctx context.Context, baseURL, apiVersion, apiKey, url, description string, connect bool, profile *config.Profile) error

WebhookEndpointCreate creates a new webhook endpoint

Types

type Base

type Base struct {
	Cmd *cobra.Command

	Method  string
	Profile *config.Profile

	Parameters RequestParameters

	// SuppressOutput is used by `trigger` to hide output
	SuppressOutput bool

	DarkStyle bool

	APIBaseURL string

	Livemode bool
	// contains filtered or unexported fields
}

Base encapsulates the required information needed to make requests to the API

func (*Base) BuildDataForRequest added in v1.12.2

func (rb *Base) BuildDataForRequest(params *RequestParameters) (string, error)

BuildDataForRequest builds request payload Note: We converted to using two arrays to track keys and values, with our own implementation of Go's url.Values Encode function due to our query parameters being order sensitive for API requests involving arrays like `items` for `/v1/orders`. Go's url.Values uses Go's map, which jumbles the key ordering, and their Encode implementation sorts keys by alphabetical order, but this doesn't work for us since some API endpoints have required parameter ordering. Yes, this is hacky, but it works.

func (*Base) Confirm added in v1.5.6

func (rb *Base) Confirm() (bool, error)

Confirm calls the confirmCommand() function, triggering the confirmation process

func (*Base) InitFlags

func (rb *Base) InitFlags()

InitFlags initialize shared flags for all requests commands

func (*Base) MakeMultiPartRequest added in v1.7.9

func (rb *Base) MakeMultiPartRequest(ctx context.Context, apiKey, path string, params *RequestParameters, errOnStatus bool) ([]byte, error)

MakeMultiPartRequest will make a multipart/form-data request to the Stripe API with the specific variables given to it. Similar to making a multipart request using curl, add the local filepath to params arg with @ prefix. e.g. params.AppendData([]string{"photo=@/path/to/local/file.png"})

func (*Base) MakeRequest

func (rb *Base) MakeRequest(ctx context.Context, apiKey, path string, params *RequestParameters, errOnStatus bool) ([]byte, error)

MakeRequest will make a request to the Stripe API with the specific variables given to it

func (*Base) MakeRequestWithClient added in v1.14.1

func (rb *Base) MakeRequestWithClient(ctx context.Context, client stripe.RequestPerformer, path string, params *RequestParameters, errOnStatus bool) ([]byte, error)

MakeRequestWithClient will make a request to the Stripe API with the specific variables given to it using the provided client.

func (*Base) RunRequestsCmd

func (rb *Base) RunRequestsCmd(cmd *cobra.Command, args []string) error

RunRequestsCmd is the interface exposed for the CLI to run network requests through

type PluginData added in v1.8.0

type PluginData struct {
	PluginBaseURL       string   `json:"base_url"`
	AdditionalManifests []string `json:"additional_manifests,omitempty"`
}

PluginData contains the plugin download information

func GetPluginData added in v1.8.0

func GetPluginData(ctx context.Context, baseURL, apiVersion, apiKey string, profile *config.Profile) (PluginData, error)

GetPluginData returns the plugin download information

type RequestError added in v1.5.9

type RequestError struct {
	StatusCode int
	ErrorType  string
	ErrorCode  string
	Body       interface{} // the raw response body
	// contains filtered or unexported fields
}

RequestError captures the response of the request that resulted in an error

func (RequestError) Error added in v1.5.9

func (e RequestError) Error() string

type RequestParameters added in v0.2.1

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

RequestParameters captures the structure of the parameters that can be sent to Stripe

func (*RequestParameters) AppendData added in v0.5.0

func (r *RequestParameters) AppendData(data []string)

AppendData appends data to the request parameters.

func (*RequestParameters) AppendExpand added in v1.6.0

func (r *RequestParameters) AppendExpand(fields []string)

AppendExpand appends fields to the expand parameter.

func (*RequestParameters) SetIdempotency added in v1.6.0

func (r *RequestParameters) SetIdempotency(value string)

SetIdempotency sets the value for the `Idempotency-Key` header.

func (*RequestParameters) SetStripeAccount added in v1.3.1

func (r *RequestParameters) SetStripeAccount(value string)

SetStripeAccount sets the value for the `Stripe-Account` header.

func (*RequestParameters) SetVersion added in v1.6.0

func (r *RequestParameters) SetVersion(value string)

SetVersion sets the value for the `Stripe-Version` header.

type TracedTransport added in v1.8.2

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

TracedTransport is an http.RoundTripper that keeps track of the in-flight request and implements hooks to report HTTP tracing events this is a different RoundTripper implementation to stripe.verboseTransport and is not designed for Stripe API requests

func (*TracedTransport) DNSDone added in v1.8.2

func (t *TracedTransport) DNSDone(dnsInfo httptrace.DNSDoneInfo)

DNSDone will trace log each DNS lookup for the current request

func (*TracedTransport) GotConn added in v1.8.2

func (t *TracedTransport) GotConn(connInfo httptrace.GotConnInfo)

GotConn will trace log each connection for the current request

func (*TracedTransport) RoundTrip added in v1.8.2

func (t *TracedTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip wraps http.DefaultTransport.RoundTrip to keep track of the current request

type WebhookEndpoint

type WebhookEndpoint struct {
	Application   string   `json:"application"`
	EnabledEvents []string `json:"enabled_events"`
	URL           string   `json:"url"`
	Status        string   `json:"status"`
}

WebhookEndpoint contains the data for each webhook endpoint

type WebhookEndpointList

type WebhookEndpointList struct {
	Data []WebhookEndpoint `json:"data"`
}

WebhookEndpointList contains the list of webhook endpoints for the account

func WebhookEndpointsList added in v0.9.0

func WebhookEndpointsList(ctx context.Context, baseURL, apiVersion, apiKey string, profile *config.Profile) WebhookEndpointList

WebhookEndpointsList returns all the webhook endpoints on a users' account

func WebhookEndpointsListWithClient added in v1.14.1

func WebhookEndpointsListWithClient(ctx context.Context, client stripe.RequestPerformer, apiVersion string, profile *config.Profile) WebhookEndpointList

WebhookEndpointsListWithClient returns all the webhook endpoints on a users' account

Jump to

Keyboard shortcuts

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