Skip to content

quiqupltd/epglgo

Repository files navigation

epglgo

Go client for the EPGL (Regulatory and Licensing) API.

Installation

go get github.com/quiqupltd/epglgo

Usage

Create a client

client, err := epglgo.NewClient("https://api-stg.epgl.ae")
if err != nil {
    log.Fatal(err)
}

Authenticate

resp, err := client.AuthenticateClient(ctx, epglgo.AuthenticateClientJSONRequestBody{
    ClientId:     "your-client-id",
    ClientSecret: "your-client-secret",
})

Create/Update a shipment

resp, err := client.CreateUpdateShipment(ctx, epglgo.CreateUpdateShipmentJSONRequestBody{
    // ... shipment details
})

Create a shipment invoice

resp, err := client.CreateShipmentInvoice(ctx, epglgo.CreateShipmentInvoiceJSONRequestBody{
    // ... invoice details
})

Using Bearer authentication

client, err := epglgo.NewClient("https://api-stg.epgl.ae",
    epglgo.WithRequestEditorFn(func(ctx context.Context, req *http.Request) error {
        req.Header.Set("Authorization", "Bearer "+token)
        return nil
    }),
)

OpenTelemetry Tracing

The client supports OpenTelemetry tracing out of the box. Use the OTEL-enabled constructors to automatically instrument all HTTP requests with distributed tracing:

// Create a client with OpenTelemetry tracing
client, err := epglgo.NewClientWithResponsesWithOTEL("https://api-stg.epgl.ae")
if err != nil {
    log.Fatal(err)
}

// All requests will automatically create spans
resp, err := client.AuthenticateClientWithResponse(ctx, epglgo.AuthenticateClientJSONRequestBody{
    ClientId:     "your-client-id",
    ClientSecret: "your-client-secret",
})

You can combine OTEL tracing with other client options:

client, err := epglgo.NewClientWithResponsesWithOTEL("https://api-stg.epgl.ae",
    epglgo.WithRequestEditorFn(func(ctx context.Context, req *http.Request) error {
        req.Header.Set("Authorization", "Bearer "+token)
        return nil
    }),
)

Note: You must configure an OpenTelemetry trace provider in your application for traces to be exported. See the OpenTelemetry Go documentation for setup instructions.

Development

Regenerate client from OpenAPI spec

go generate ./...

OpenAPI spec location

The OpenAPI specification is at spec/apispec.json.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors 2

  •  
  •  

Languages