Skip to content

way-platform/ileap-go

Repository files navigation

iLEAP Go

PkgGoDev GoReportCard CI

A Go SDK for logistics emissions data compatible with the iLEAP Technical Specifications.

SDK

Features

Installing

$ go get github.com/way-platform/ileap-go@latest

Using

client := ileap.NewClient(
    ileap.WithBaseURL(os.Getenv("BASE_URL")),
    ileap.WithOAuth2(os.Getenv("CLIENT_ID"), os.Getenv("CLIENT_SECRET")),
)
footprint, err := client.GetFootprint(context.Background(), &ileap.GetFootprintRequest{
    ID: "91715e5e-fd0b-4d1c-8fab-76290c46e6ed",
})
if err != nil {
    // TODO: Handle error.
}
fmt.Println(footprint)

Developing

Build project

The project is built using Mage, see magefile.go.

$ go tool mage build

For all available build tasks, see:

$ go tool mage

CLI tool

Installing

go install github.com/way-platform/ileap-go/cmd/ileap@latest

Prebuilt binaries for Linux, Windows, and Mac are available from the Releases.

Using

The following example logs in to the SINE Foundation's demo API.

$ ileap auth login \
  --base-url https://ileap.wayplatform.com \
  --client-id hello \
  --client-secret pathfinder

Logged in to https://api.ileap.sine.dev.
$ ileap footprint 91715e5e-fd0b-4d1c-8fab-76290c46e6ed
{
  "data": {
    "id": "91715e5e-fd0b-4d1c-8fab-76290c46e6ed",
    "specVersion": "2.0.0",
    "version": 1,
    "created": "2022-03-01T09:32:20Z",
    "status": "Active",
    "validityPeriodStart": "2022-03-01T09:32:20Z",
    "validityPeriodEnd": "2024-12-31T00:00:00Z",
    "companyName": "My Corp",
    "companyIds": [
      "urn:uuid:69585GB6-56T9-6958-E526-6FDGZJHU1326",
      "urn:epc:id:sgln:562958.00000.4"
    ],
    "productDescription": "Bio-Ethanol 98%, corn feedstock (bulk - no packaging)",
    "..."
}