https://github.com/affise/go-sdk
https://github.com/affise/go-sdk
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/affise/go-sdk
- Owner: affise
- Created: 2021-01-26T08:28:40.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-01-26T08:29:40.000Z (over 4 years ago)
- Last Synced: 2023-05-05T13:59:20.665Z (about 2 years ago)
- Language: Go
- Size: 104 KB
- Stars: 0
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# go-sdk
API v3.1 SDK (Golang)The public API documentation is available at [api.affise.com](https://api.affise.com/docs3.1/)
## Example
```go
package mainimport (
"context"
"log"
"net/http"
"time""github.com/affise/go-sdk/affise"
)func main() {
// custom HTTP client
httpClient := &http.Client{
Timeout: 5 * time.Second,
}client, err := affise.NewClient(
affise.WithAPIKey("key"),
affise.WithBaseURL("https://base.example.com"),
affise.WithAdminURL("https://admin.example.com"),
affise.WithHTTPClient(httpClient),
)
if err != nil{
log.Fatalf("creating client err: %v", err)
}ctx := context.TODO()
// Get statistic by date
opts := &affise.StatisticGetByDateOpts{
StatFilter: affise.StatFilter{
DateFrom: "2021-01-01",
DateTo: "2021-01-04",
},
Timezone: "Europe/Berlin",
}stats, _ , err := client.Statistic.GetByDate(ctx, opts)
if err != nil{
log.Fatalf("get statistic by date err: %v", err)
}// Get partner by ID (admin method)
partner, _, err := client.AdminAffiliate.Get(ctx, 1)
if err != nil{
log.Fatalf("get partner by ID err: %v", err)
}
}
```