Documentation
¶
Overview ¶
Package plainrouter provides the official Go client for the PlainRouter Signals Conversion API.
Getting started ¶
Create one Client and reuse it. New targets the production PlainRouter API by default and applies the bearer token to every request:
client := plainrouter.New(os.Getenv("PLAINROUTER_TOKEN"))
report, response, err := client.Operations.GetEmqReport(context.Background()).Execute()
Keep tokens out of source code and load them from an environment variable or secret manager. Most methods return a decoded result, the underlying HTTP response, and an error. Inspect the response when handling API errors or reading response metadata.
API groups ¶
Client exposes three service groups:
- Client.Events submits conversion events and reads event delivery state.
- Client.Operations provides reporting, reconciliation, replay, deletion, and destination test operations.
- Client.Sandbox discovers and validates isolated synthetic sandbox events without granting access to production data.
The complete generated contract is available from the github.com/plainrouter/sdk-go/openapi subpackage and through Client.OpenAPI.
See the PlainRouter documentation for authentication, consent-aware event shapes, sandbox usage, and operational guidance.
Example ¶
package main
import (
"context"
"fmt"
"log"
"os"
plainrouter "github.com/plainrouter/sdk-go"
)
func main() {
client := plainrouter.New(os.Getenv("PLAINROUTER_TOKEN"))
report, response, err := client.Operations.GetEmqReport(context.Background()).Execute()
if response != nil {
defer response.Body.Close()
}
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", report)
}
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ContextAccessToken = openapi.ContextAccessToken
ContextAccessToken is the generated client's bearer-token context key.
Deprecated: create a curated client with New, which applies its token to every request automatically.
Functions ¶
func NewAPIClient
deprecated
func NewAPIClient(configuration *openapi.Configuration) *openapi.APIClient
NewAPIClient creates the complete generated client.
Deprecated: use New for the curated entry point or import the github.com/plainrouter/sdk-go/openapi package directly.
func NewConfiguration
deprecated
func NewConfiguration() *openapi.Configuration
NewConfiguration creates low-level generated client configuration.
Deprecated: use New with WithBaseURL, WithHTTPClient, or WithUserAgent.
Types ¶
type Client ¶ added in v0.6.0
type Client struct {
Events *openapi.EventAPIService
Operations *openapi.OperationsAPIService
Sandbox *openapi.SandboxAPIService
// contains filtered or unexported fields
}
Client is the curated entry point for the PlainRouter API.
Events, Operations, and Sandbox expose the generated service groups without placing every generated model and accessor in the root package index.
type Option ¶ added in v0.6.0
type Option func(*openapi.Configuration)
Option configures a Client created by New.
func WithBaseURL ¶ added in v0.6.0
WithBaseURL overrides the default PlainRouter API base URL. It is intended for tests, proxies, and self-hosted compatible endpoints.
func WithHTTPClient ¶ added in v0.6.0
WithHTTPClient supplies the HTTP client used for requests. A nil client is ignored and leaves the standard HTTP client in place.
func WithUserAgent ¶ added in v0.6.0
WithUserAgent overrides the generated client's default User-Agent header.