An API-client for Sendcloud written in Golang.
This package currently supports:
- parcels
- parcel documents
- labels
- methods
- addresses
- integrations
go get github.com/afosto/sendcloud-go
Some examples on how to use the client are found below.
To initialize the client:
api := client.API{}
api.Init("api_key", "api_secret")
To list shipping methods:
methods, err := api.Method.GetMethods()
if err != nil {
log.Fatal(err)
}
for _, m := range methods {
log.Print(*m)
}
Create a parcel:
params := &sendcloud.ParcelParams{
Name: "Sendcloud-GO",
CompanyName: "Afosto SaaS BV",
Street: "Grondzijl",
HouseNumber: "16",
City: "Groningen",
PostalCode: "9731DG",
PhoneNumber: "0507119519",
EmailAddress: "[email protected]",
CountryCode: "NL",
IsLabelRequested: true,
Method: 8,
ExternalID: uuid.New().String(),
}
parcel, err := api.Parcel.New(params)
resolve a service point id from postnl,dhl,dpd to a sendcloud service point id
spid, err := api.ServicePoint.GetServicePoint(servicepoint.Matcher{
SPID: "NL-972301",
Carrier: "dhl",
Country: "NL",
PostalCode: "9731AR",
HouseNumber: "41",
Latitude: 53.226994,
Longitude: 6.608120,
})
fmt.PrintLn(spid)
this service point id can then be placed on an parcel on creation
All contributions / suggestions are welcome. Please raise an issue or submit a PR.
This package was heavily inspired by stripe-go
.
This package is developed by Afosto SaaS BV.
MIT.