Documentation
¶
Index ¶
- Constants
- func Bool(b bool) *bool
- func BoolValue(b *bool) bool
- func Float64(f float64) *float64
- func Float64Value(f *float64) float64
- func GenerateBearerToken(c IClient, apiKey, apiKeySecret string) (string, error)
- func Int(i int) *int
- func IntValue(i *int) int
- func NewMockHTTPClient(in *MockInput) *http.Client
- func String(s string) *string
- func StringValue(s *string) string
- func Time(t time.Time) *time.Time
- func TimeValue(t *time.Time) time.Time
- type AuthenticationMethod
- type Client
- func (c *Client) APIKey() string
- func (c *Client) APIKeySecret() string
- func (c *Client) AccessToken() string
- func (c *Client) AuthenticationMethod() AuthenticationMethod
- func (c *Client) CallAPI(ctx context.Context, endpoint, method string, p util.Parameters, ...) error
- func (c *Client) Exec(req *http.Request, i util.Response) (*resources.Non2XXError, error)
- func (c *Client) IsReady() bool
- func (c *Client) OAuthConsumerKey() string
- func (c *Client) OAuthToken() string
- func (c *Client) SetAccessToken(v string)
- func (c *Client) SetAuthenticationMethod(v AuthenticationMethod)
- func (c *Client) SetOAuthConsumerKey(v string)
- func (c *Client) SetOAuthToken(v string)
- func (c *Client) SetSigningKey(v string)
- func (c *Client) SigningKey() string
- type ClientResponse
- type CreateOAuthSignatureInput
- type CreateOAuthSignatureOutput
- type Endpoint
- type EndpointInfo
- type GotwiError
- type IClient
- type MockAPIParameter
- type MockAPIResponse
- type MockFuncInput
- type MockGotwiClient
- func (m *MockGotwiClient) AccessToken() string
- func (m *MockGotwiClient) AuthenticationMethod() AuthenticationMethod
- func (m *MockGotwiClient) CallAPI(ctx context.Context, endpoint, method string, p util.Parameters, ...) error
- func (m *MockGotwiClient) Exec(req *http.Request, i util.Response) (*resources.Non2XXError, error)
- func (m *MockGotwiClient) IsReady() bool
- func (m *MockGotwiClient) OAuthConsumerKey() string
- func (m *MockGotwiClient) OAuthToken() string
- func (m *MockGotwiClient) SigningKey() string
- type MockInput
- type NewClientInput
- type NewClientWithAccessTokenInput
- type OAuth2TokenResponse
- type RoundTripFunc
- type StreamClient
- type TypedClient
- func (c *TypedClient[T]) AccessToken() string
- func (c *TypedClient[T]) AuthenticationMethod() AuthenticationMethod
- func (c *TypedClient[T]) CallAPI(ctx context.Context, endpoint, method string, p util.Parameters, ...) error
- func (c *TypedClient[T]) CallStreamAPI(ctx context.Context, endpoint, method string, p util.Parameters) (*StreamClient[T], error)
- func (c *TypedClient[T]) Exec(req *http.Request, i util.Response) (*resources.Non2XXError, error)
- func (c *TypedClient[T]) ExecStream(req *http.Request) (*http.Response, *resources.Non2XXError, error)
- func (c *TypedClient[T]) IsReady() bool
- func (c *TypedClient[T]) OAuthConsumerKey() string
- func (c *TypedClient[T]) OAuthToken() string
- func (c *TypedClient[T]) SigningKey() string
Constants ¶
View Source
const ( APIKeyEnvName = "GOTWI_API_KEY" APIKeySecretEnvName = "GOTWI_API_KEY_SECRET" )
View Source
const ( AuthenMethodOAuth1UserContext = "OAuth 1.0a User context" AuthenMethodOAuth2BearerToken = "OAuth 2.0 Bearer token" )
View Source
const ( OAuthVersion10 = "1.0" OAuthSignatureMethodHMACSHA1 = "HMAC-SHA1" )
View Source
const OAuth2TokenEndpoint = "https://api.x.com/oauth2/token"
Variables ¶
This section is empty.
Functions ¶
func Float64Value ¶
func GenerateBearerToken ¶
func NewMockHTTPClient ¶
func StringValue ¶
Types ¶
type AuthenticationMethod ¶
type AuthenticationMethod string
func (AuthenticationMethod) Valid ¶
func (a AuthenticationMethod) Valid() bool
type Client ¶
func NewClient ¶
func NewClient(in *NewClientInput) (*Client, error)
func NewClientWithAccessToken ¶
func NewClientWithAccessToken(in *NewClientWithAccessTokenInput) (*Client, error)
func (*Client) APIKeySecret ¶
func (*Client) AccessToken ¶
func (*Client) AuthenticationMethod ¶
func (c *Client) AuthenticationMethod() AuthenticationMethod
func (*Client) OAuthConsumerKey ¶
func (*Client) OAuthToken ¶
func (*Client) SetAccessToken ¶
func (*Client) SetAuthenticationMethod ¶
func (c *Client) SetAuthenticationMethod(v AuthenticationMethod)
func (*Client) SetOAuthConsumerKey ¶
func (*Client) SetOAuthToken ¶
func (*Client) SetSigningKey ¶
func (*Client) SigningKey ¶
type ClientResponse ¶
type CreateOAuthSignatureOutput ¶
type CreateOAuthSignatureOutput struct {
OAuthNonce string
OAuthSignatureMethod string
OAuthTimestamp string
OAuthVersion string
OAuthSignature string
}
func CreateOAuthSignature ¶
func CreateOAuthSignature(in *CreateOAuthSignatureInput) (*CreateOAuthSignatureOutput, error)
type Endpoint ¶
type Endpoint string
func (Endpoint) Detail ¶
func (e Endpoint) Detail() (*EndpointInfo, error)
type EndpointInfo ¶
type GotwiError ¶
type GotwiError struct {
OnAPI bool
resources.Non2XXError
// contains filtered or unexported fields
}
func (*GotwiError) Error ¶
func (e *GotwiError) Error() string
func (*GotwiError) Unwrap ¶
func (e *GotwiError) Unwrap() error
type IClient ¶
type IClient interface {
Exec(req *http.Request, i util.Response) (*resources.Non2XXError, error)
IsReady() bool
AccessToken() string
AuthenticationMethod() AuthenticationMethod
OAuthToken() string
OAuthConsumerKey() string
SigningKey() string
CallAPI(ctx context.Context, endpoint, method string, p util.Parameters, i util.Response) error
}
type MockAPIParameter ¶
type MockAPIParameter struct{}
func (MockAPIParameter) AccessToken ¶
func (mp MockAPIParameter) AccessToken() string
func (MockAPIParameter) ParameterMap ¶
func (mp MockAPIParameter) ParameterMap() map[string]string
func (MockAPIParameter) ResolveEndpoint ¶
func (mp MockAPIParameter) ResolveEndpoint(endpointBase string) string
func (MockAPIParameter) SetAccessToken ¶
func (mp MockAPIParameter) SetAccessToken(token string)
type MockAPIResponse ¶
type MockAPIResponse struct{}
func (MockAPIResponse) HasPartialError ¶
func (mr MockAPIResponse) HasPartialError() bool
type MockFuncInput ¶
type MockFuncInput struct {
MockExec func(req *http.Request, i util.Response) (*resources.Non2XXError, error)
MockIsReady func() bool
MockAccessToken func() string
MockAuthenticationMethod func() AuthenticationMethod
MockOAuthToken func() string
MockOAuthConsumerKey func() string
MockSigningKey func() string
MockCallAPI func(ctx context.Context, endpoint, method string, p util.Parameters, i util.Response) error
}
type MockGotwiClient ¶
type MockGotwiClient struct {
Client *http.Client
MockExec func(req *http.Request, i util.Response) (*resources.Non2XXError, error)
MockIsReady func() bool
MockAccessToken func() string
MockAuthenticationMethod func() AuthenticationMethod
MockOAuthToken func() string
MockOAuthConsumerKey func() string
MockSigningKey func() string
MockCallAPI func(ctx context.Context, endpoint, method string, p util.Parameters, i util.Response) error
}
func NewMockGotwiClient ¶
func NewMockGotwiClient(returnedToken string, execHasError, hasNot200Error bool) *MockGotwiClient
func NewMockGotwiClientWithFunc ¶
func NewMockGotwiClientWithFunc(in MockFuncInput) *MockGotwiClient
func (*MockGotwiClient) AccessToken ¶
func (m *MockGotwiClient) AccessToken() string
func (*MockGotwiClient) AuthenticationMethod ¶
func (m *MockGotwiClient) AuthenticationMethod() AuthenticationMethod
func (*MockGotwiClient) CallAPI ¶
func (m *MockGotwiClient) CallAPI(ctx context.Context, endpoint, method string, p util.Parameters, i util.Response) error
func (*MockGotwiClient) Exec ¶
func (m *MockGotwiClient) Exec(req *http.Request, i util.Response) (*resources.Non2XXError, error)
func (*MockGotwiClient) IsReady ¶
func (m *MockGotwiClient) IsReady() bool
func (*MockGotwiClient) OAuthConsumerKey ¶
func (m *MockGotwiClient) OAuthConsumerKey() string
func (*MockGotwiClient) OAuthToken ¶
func (m *MockGotwiClient) OAuthToken() string
func (*MockGotwiClient) SigningKey ¶
func (m *MockGotwiClient) SigningKey() string
type MockInput ¶
type MockInput struct {
ResponseStatusCode int
ResponseHeader map[string][]string
ResponseBody io.ReadCloser
}
type NewClientInput ¶
type OAuth2TokenResponse ¶
type OAuth2TokenResponse struct {
TokenType string `json:"token_type"`
AccessToken string `json:"access_token"`
}
func (OAuth2TokenResponse) HasPartialError ¶
func (o OAuth2TokenResponse) HasPartialError() bool
type RoundTripFunc ¶
type StreamClient ¶
func (*StreamClient[T]) Read ¶
func (s *StreamClient[T]) Read() (T, error)
func (*StreamClient[T]) Receive ¶
func (s *StreamClient[T]) Receive() bool
func (*StreamClient[T]) Stop ¶
func (s *StreamClient[T]) Stop()
type TypedClient ¶
type TypedClient[T util.Response] struct { Client *http.Client // contains filtered or unexported fields }
func NewTypedClient ¶
func NewTypedClient[T util.Response](c *Client) *TypedClient[T]
func (*TypedClient[T]) AccessToken ¶
func (c *TypedClient[T]) AccessToken() string
func (*TypedClient[T]) AuthenticationMethod ¶
func (c *TypedClient[T]) AuthenticationMethod() AuthenticationMethod
func (*TypedClient[T]) CallAPI ¶
func (c *TypedClient[T]) CallAPI(ctx context.Context, endpoint, method string, p util.Parameters, i util.Response) error
This method exists only to satisfy the IClient interface. It will never be called directly since TypedClient uses its own implementation.
func (*TypedClient[T]) CallStreamAPI ¶
func (c *TypedClient[T]) CallStreamAPI(ctx context.Context, endpoint, method string, p util.Parameters) (*StreamClient[T], error)
func (*TypedClient[T]) Exec ¶
func (c *TypedClient[T]) Exec(req *http.Request, i util.Response) (*resources.Non2XXError, error)
func (*TypedClient[T]) ExecStream ¶
func (c *TypedClient[T]) ExecStream(req *http.Request) (*http.Response, *resources.Non2XXError, error)
func (*TypedClient[T]) IsReady ¶
func (c *TypedClient[T]) IsReady() bool
func (*TypedClient[T]) OAuthConsumerKey ¶
func (c *TypedClient[T]) OAuthConsumerKey() string
func (*TypedClient[T]) OAuthToken ¶
func (c *TypedClient[T]) OAuthToken() string
func (*TypedClient[T]) SigningKey ¶
func (c *TypedClient[T]) SigningKey() string
Source Files
¶
Click to show internal directories.
Click to hide internal directories.