Files
m3o-go/examples/evchargers/README.md
2022-02-16 09:26:30 +00:00

128 lines
2.6 KiB
Markdown
Executable File

# Evchargers
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/evchargers/api](https://m3o.com/evchargers/api).
Endpoints:
## ReferenceData
Retrieve reference data as used by this API and in conjunction with the Search endpoint
[https://m3o.com/evchargers/api#ReferenceData](https://m3o.com/evchargers/api#ReferenceData)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/evchargers"
)
// Retrieve reference data as used by this API and in conjunction with the Search endpoint
func GetReferenceData() {
evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN"))
rsp, err := evchargersService.ReferenceData(&evchargers.ReferenceDataRequest{
})
fmt.Println(rsp, err)
}
```
## Search
Search by giving a coordinate and a max distance, or bounding box and optional filters
[https://m3o.com/evchargers/api#Search](https://m3o.com/evchargers/api#Search)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/evchargers"
)
// Search by giving a coordinate and a max distance, or bounding box and optional filters
func SearchByLocation() {
evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN"))
rsp, err := evchargersService.Search(&evchargers.SearchRequest{
Distance: 2000,
Location: &evchargers.Coordinates{
Latitude: 51.53336351319885,
Longitude: -0.0252,
},
})
fmt.Println(rsp, err)
}
```
## Search
Search by giving a coordinate and a max distance, or bounding box and optional filters
[https://m3o.com/evchargers/api#Search](https://m3o.com/evchargers/api#Search)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/evchargers"
)
// Search by giving a coordinate and a max distance, or bounding box and optional filters
func SearchByBoundingBox() {
evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN"))
rsp, err := evchargersService.Search(&evchargers.SearchRequest{
Box: &evchargers.BoundingBox{
},
})
fmt.Println(rsp, err)
}
```
## Search
Search by giving a coordinate and a max distance, or bounding box and optional filters
[https://m3o.com/evchargers/api#Search](https://m3o.com/evchargers/api#Search)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/evchargers"
)
// Search by giving a coordinate and a max distance, or bounding box and optional filters
func SearchWithFiltersFastChargersOnly() {
evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN"))
rsp, err := evchargersService.Search(&evchargers.SearchRequest{
Distance: 2000,
Levels: []string{"3"},
Location: &evchargers.Coordinates{
Latitude: 51.53336351319885,
Longitude: -0.0252,
},
})
fmt.Println(rsp, err)
}
```