Documentation
¶
Overview ¶
Package example implements the example provider using jsonplaceholder.typicode.com for demonstration.
Package example implements the example provider using jsonplaceholder.typicode.com for demonstration.
Index ¶
- Constants
- func GetWebhookSecret() string
- type Example
- func (e *Example) Delete(ctx context.Context, path string) (*Response, error)
- func (e *Example) Get(ctx context.Context, path string) (*Response, error)
- func (*Example) GetAccessToken(_ fiber.Ctx) (*providers.OAuthToken, error)
- func (e *Example) GetAuthorizeURL(state string) string
- func (e *Example) GetStatus(ctx context.Context, code int) (*Response, error)
- func (e *Example) GetWithDelay(ctx context.Context, seconds int) (*Response, error)
- func (e *Example) ListRawEvents(ctx context.Context, cursor string) ([]map[string]any, string, error)
- func (e *Example) Post(ctx context.Context, _ string, data any) (*Response, error)
- func (e *Example) Put(ctx context.Context, path string, data any) (*Response, error)
- type ItemsResponse
- type Response
- type WebhookPayload
Constants ¶
const ( ID = "example" EndpointKey = "endpoint" TokenKey = "token" WebhookSecretKey = "webhook_secret" )
const MaxPageSize = 100
MaxPageSize is the maximum number of items per page.
Variables ¶
This section is empty.
Functions ¶
func GetWebhookSecret ¶
func GetWebhookSecret() string
GetWebhookSecret reads the webhook HMAC secret from the example provider config.
Types ¶
type Example ¶
type Example struct {
// contains filtered or unexported fields
}
Example wraps the jsonplaceholder.typicode.com API client for demonstration purposes. It provides CRUD operations, OAuth stubs, and polling support.
func GetClient ¶
func GetClient() *Example
GetClient reads provider config and returns a new Example client. It falls back to https://jsonplaceholder.typicode.com when no endpoint is configured.
func NewExample ¶
NewExample creates an Example client with the given endpoint and optional auth token. If endpoint is empty, it defaults to https://jsonplaceholder.typicode.com.
func (*Example) Delete ¶
Delete deletes a jsonplaceholder post via DELETE /posts/{path}. If path is empty it defaults to "1".
func (*Example) Get ¶
Get fetches a jsonplaceholder post by ID via GET /posts/{path}. If path is empty it defaults to "1".
func (*Example) GetAccessToken ¶
GetAccessToken simulates an OAuth code exchange for demonstration.
func (*Example) GetAuthorizeURL ¶
GetAuthorizeURL returns a constructed OAuth authorize URL for demonstration.
func (*Example) GetStatus ¶
GetStatus fetches a jsonplaceholder post by ID to demonstrate HTTP status handling. Non-existent IDs return 404 errors.
func (*Example) GetWithDelay ¶
GetWithDelay fetches a jsonplaceholder post with a timeout context to demonstrate timeout handling patterns.
func (*Example) ListRawEvents ¶
func (e *Example) ListRawEvents(ctx context.Context, cursor string) ([]map[string]any, string, error)
ListRawEvents fetches jsonplaceholder posts as a list for polling demonstration. The cursor is used as a page number for pagination.
type ItemsResponse ¶
type ItemsResponse struct {
Items []map[string]any `json:"items"`
NextCursor string `json:"next_cursor"`
}
ItemsResponse carries a list of items with cursor for polling.