Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
permissions:
contents: read # for golangci-lint-action
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v7
with:
lfs: true
- name: Setup Go ${{ matrix.go-version }}
Expand All @@ -41,4 +41,4 @@ jobs:
- name: Lint
uses: golangci/golangci-lint-action@v9
with:
version: v2.8.0
version: v2.12.2
11 changes: 7 additions & 4 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
---
version: "2"
linters:
enable: # list taken from https://golangci-lint.run/usage/linters/ - last updated 2026-01-09 for v2.8.0
enable: # list taken from https://golangci-lint.run/usage/linters/ - last updated 2026-05-11 for v2.12.2
# enabled by default, but list them here to be explicit
- errcheck
- govet
Expand All @@ -16,6 +16,7 @@ linters:
- bidichk # checks for dangerous unicode character sequences
- bodyclose # checks whether HTTP response body is closed successfully
- canonicalheader # checks for canonical names in HTTP headers
- clickhouselint # detects common mistakes with the ClickHouse native Go driver API
- containedctx # detects struct contained context.Context field
#- contextcheck # checks for inherited context.Context
- copyloopvar # detects places where loop variables are copied
Expand Down Expand Up @@ -45,15 +46,16 @@ linters:
- gochecknoinits # checks that no init functions are present in Go code
- gochecksumtype # checks exhaustiveness on Go "sum types"
#- gocognit # Computes and checks the cognitive complexity of functions
- goconst # finds repeated strings that could be replaced by a constant
#- goconst # finds repeated strings that could be replaced by a constant
- gocritic # provides diagnostics that check for bugs, performance and style issues
#- gocyclo # Computes and checks the cyclomatic complexity of functions
- godoclint # Checks golang docs best practices (godoc)
#- godot # Check if comments end in a period
#- godox # Tool for detection of FIXME, TODO and other comment keywords
#- goheader # Checks is file header matches to pattern
- gomoddirectives # manages the use of 'replace', 'retract', and 'excludes' directives in go.mod
- gomodguard # allow and block lists linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations
#- gomodguard # allow and block lists linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations
- gomodguard_v2 # Allow and blocklist linter for direct Go module dependencies
- goprintffuncname # checks that printf-like functions are named with f at the end
- gosec # inspects source code for security problems
- gosmopolitan # Report certain i18n/l10n anti-patterns in your Go codebase.
Expand Down Expand Up @@ -143,6 +145,7 @@ linters:
tagalign:
order:
- flag
- arg
- env
- default
- secret
Expand Down Expand Up @@ -171,4 +174,4 @@ formatters:
- gci
- gofmt
- gofumpt
- goimports
- goimports
36 changes: 20 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@

A Go SDK for interacting with [Loops's](https://loops.so) API.

## API Documentation

- Official Loops API documentation: [Loops API reference](https://app.loops.so/docs/api-reference/)
- This client targets the vendored [openapi.json](openapi.json) spec version `1.16.0`. For the latest Loops OpenAPI spec, see [https://app.loops.so/openapi.json](https://app.loops.so/openapi.json).

## Contributing

Contributions are welcome! If the Loops API changes, community PRs that update [openapi.json](openapi.json), models, client methods, examples, and endpoint tests are very welcome.

## Installation

```bash
Expand All @@ -22,8 +31,9 @@ package main

import (
"context"
"github.com/tilebox/loops-go"
"log/slog"

"github.com/tilebox/loops-go"
)

func main() {
Expand All @@ -33,7 +43,7 @@ func main() {
slog.Error("failed to create client", slog.Any("error", err.Error()))
return
}

// now use the client to make requests
}
```
Expand All @@ -49,7 +59,7 @@ contactID, err := client.CreateContact(ctx, &loops.Contact{
UserGroup: loops.String("Astronauts"),
Subscribed: true,
// custom user defined properties for contacts
Properties: map[string]interface{}{
Properties: map[string]any{
"role": "Astronaut",
},
})
Expand Down Expand Up @@ -84,7 +94,7 @@ if err != nil {
**List contact properties**
```go
properties, err := client.GetContactProperties(ctx, loops.ContactPropertyListOptions{
List: loops.ContactPropertyTypeCustom, // only return your teams custom properties
List: loops.ContactPropertyTypeCustom, // only return your team's custom properties
})
if err != nil {
slog.Error("failed to get contact properties", slog.Any("error", err.Error()))
Expand All @@ -99,7 +109,7 @@ if err != nil {
err = client.SendEvent(ctx, &loops.Event{
Email: loops.String("neil.armstrong@moon.space"),
EventName: "joinedMission",
EventProperties: &map[string]interface{}{
EventProperties: map[string]any{
"mission": "Apollo 11",
},
})
Expand All @@ -114,10 +124,10 @@ if err != nil {
**Send a transactional email**

```go
err = client.SendTransactionalEmail(ctx, &loops.TransactionalEmail{
TransactionalId: "cm...",
err = client.SendTransactionalEmail(ctx, &loops.TransactionalRequest{
TransactionalID: "cm...",
Email: "recipient@example.com",
DataVariables: &map[string]interface{}{
DataVariables: map[string]any{
"name": "Recipient Name",
},
})
Expand All @@ -143,13 +153,7 @@ for _, email := range emailsPage.Data {
}
```

## API Documentation

The API documentation is part of the official Loops Documentation and can be found [here](https://app.loops.so/docs/api-reference/).

## Contributing

Contributions are welcome! Especially if the loops API is updated, please feel free to open PRs for new or updated endpoints.
For more complete flows, see the [transactional email lifecycle](examples/transactional-email-lifecycle) and [image upload](examples/upload-image-asset) examples.

## Authors

Expand All @@ -171,4 +175,4 @@ go test ./...

```bash
golangci-lint run --fix ./...
```
```
Loading
Loading