A Go client library for the Briq messaging platform API. This SDK provides programmatic access to Briq's SMS messaging services, including instant messaging, campaign management, and workspace organization.
- Instant Messaging: Send immediate SMS messages to recipients
- Campaign Management: Create and manage messaging campaigns
- Workspace Management: Organize campaigns within workspaces
- Message Logging: Track message history and delivery status
- Authentication: API key-based authentication with environment variable support
go get github.com/AnoRebel/BriqGoSdkpackage main
import (
"fmt"
"log"
"github.com/AnoRebel/BriqGoSdk/client"
)
func main() {
// Initialize client with API key
apiKey := "your-api-key"
client := client.NewClient(&apiKey, nil)
// Use the client to make API calls
resp, err := client.Get("workspaces", nil)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
fmt.Printf("Status: %d\n", resp.StatusCode)
}Create a .env file in your project root:
BRIQ_API_KEY=your-api-key
BRIQ_BASE_URL=http://karibu.briq.tz # optionalThen initialize the client without parameters:
client := client.NewClient(nil, nil) // Will load from environmentThe SDK provides structured data models for all API operations:
import (
"github.com/AnoRebel/BriqGoSdk/client"
"github.com/AnoRebel/BriqGoSdk/models"
)
// Create a workspace
workspaceReq := models.WorkspaceCreateRequest{
Name: "My Workspace",
Description: "A workspace for my campaigns",
}
// Validate the request
if err := workspaceReq.Validate(); err != nil {
log.Fatal("Invalid request:", err)
}
// Send instant message
messageReq := models.InstantMessageRequest{
Content: "Hello from Briq Go SDK!",
Recipients: []string{"+1234567890", "+0987654321"},
SenderID: "sender123",
}
if err := messageReq.Validate(); err != nil {
log.Fatal("Invalid message request:", err)
}The main client provides several HTTP convenience methods:
// GET request with query parameters
resp, err := client.Get("endpoint", map[string]string{
"param1": "value1",
"param2": "value2",
})
// POST request with JSON body
data := map[string]interface{}{
"name": "example",
"value": 123,
}
resp, err := client.Post("endpoint", data)
// PATCH request with JSON body
resp, err := client.Patch("endpoint", data)
// Generic request method
resp, err := client.Request("PUT", "endpoint", data, params)The client provides access to different API modules:
- client.Workspace: Workspace management operations
- client.Campaign: Campaign management operations
- client.Message: Message sending and history operations
The SDK includes comprehensive data models for type-safe API interactions:
WorkspaceCreateRequest: Create new workspaceWorkspaceUpdateRequest: Update existing workspaceWorkspaceResponse: Workspace API response
CampaignCreateRequest: Create new campaignCampaignUpdateRequest: Update existing campaignCampaignResponse: Campaign API response
InstantMessageRequest: Send instant messagesCampaignMessageRequest: Send campaign messagesMessageResponse: Message API responseMessageLogResponse: Message delivery logs
APIErrorResponse: API error responsesListResponse: Paginated list responses
All request models include built-in validation methods:
req := models.WorkspaceCreateRequest{Name: "Test"}
if err := req.Validate(); err != nil {
// Handle validation error
}The SDK supports configuration through environment variables or direct initialization:
| Environment Variable | Description | Default |
|---|---|---|
BRIQ_API_KEY |
Your Briq API key | Required |
BRIQ_BASE_URL |
Base URL for the API | http://karibu.briq.tz |
The SDK provides custom error types for different scenarios:
BriqAuthError: Authentication failures (401)BriqAPIError: General API errors (4xx, 5xx)BriqRequestError: Request construction or network errors
resp, err := client.Get("endpoint", nil)
if err != nil {
switch e := err.(type) {
case *exceptions.BriqAuthError:
fmt.Println("Authentication failed:", e.Message)
case *exceptions.BriqAPIError:
fmt.Printf("API error %d: %s\n", e.Code, e.Message)
default:
fmt.Println("Request error:", err)
}
}go build ./...go test ./...go fmt ./...
go vet ./...This project is licensed under the same terms as the original Python SDK.
Contributions are welcome! Please ensure all code is properly formatted and tested before submitting pull requests.