Skip to content

Commit 1aac59c

Browse files
committed
Fixed lat/long params
Signed-off-by: Vishal Rana <[email protected]>
1 parent db473dc commit 1aac59c

File tree

4 files changed

+40
-13
lines changed

4 files changed

+40
-13
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
func main() {
2525
client := labstack.NewClient("<API_KEY>")
2626
geocode := client.Geocode()
27-
res, err := geocode.Address("eiffel tower", labstack.GeocodeAddressOptions{})
27+
res, err := geocode.Address("eiffel tower")
2828
if err != nil {
2929
fmt.Println(err)
3030
} else {
@@ -39,4 +39,4 @@ From terminal run your app:
3939
go run app.go
4040
```
4141

42-
## [Docs](https://labstack.com/docs) | [Forum](https://forum.labstack.com)
42+
## [Docs](https://labstack.com/docs/api) | [Forum](https://forum.labstack.com)

geocode.go

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,21 @@ type (
88
}
99

1010
GeocodeAddressOptions struct {
11-
Longitude float64
1211
Latitude float64
12+
Longitude float64
1313
OSMTag string
1414
Language string
15+
Foramt string
1516
Limit int
1617
}
1718

19+
GeocodeIPOptions struct {
20+
Foramt string
21+
}
22+
1823
GeocodeReverseOptions struct {
19-
Limit int
24+
Foramt string
25+
Limit int
2026
}
2127

2228
GeocodeGeometry struct {
@@ -36,16 +42,21 @@ type (
3642
}
3743
)
3844

39-
func (g *Geocode) Address(location string, options GeocodeAddressOptions) (*GeocodeResponse, *APIError) {
45+
func (g *Geocode) Address(location string) (*GeocodeResponse, *APIError) {
46+
return g.AddressWithOptions(location, GeocodeAddressOptions{})
47+
}
48+
49+
func (g *Geocode) AddressWithOptions(location string, options GeocodeAddressOptions) (*GeocodeResponse, *APIError) {
4050
res := new(GeocodeResponse)
4151
err := new(APIError)
4252
r, e := g.resty.R().
4353
SetQueryParams(map[string]string{
4454
"location": location,
45-
"longitude": strconv.FormatFloat(options.Longitude, 'f', -1, 64),
4655
"latitude": strconv.FormatFloat(options.Latitude, 'f', -1, 64),
56+
"longitude": strconv.FormatFloat(options.Longitude, 'f', -1, 64),
4757
"osm_tag": options.OSMTag,
4858
"language": options.Language,
59+
"foramt": options.Foramt,
4960
"limit": strconv.Itoa(options.Limit),
5061
}).
5162
SetResult(res).
@@ -63,11 +74,16 @@ func (g *Geocode) Address(location string, options GeocodeAddressOptions) (*Geoc
6374
}
6475

6576
func (g *Geocode) IP(ip string) (*GeocodeResponse, *APIError) {
77+
return g.IPWithOptions(ip, GeocodeIPOptions{})
78+
}
79+
80+
func (g *Geocode) IPWithOptions(ip string, options GeocodeIPOptions) (*GeocodeResponse, *APIError) {
6681
res := new(GeocodeResponse)
6782
err := new(APIError)
6883
r, e := g.resty.R().
6984
SetQueryParams(map[string]string{
70-
"ip": ip,
85+
"ip": ip,
86+
"foramt": options.Foramt,
7187
}).
7288
SetResult(res).
7389
SetError(err).
@@ -83,13 +99,18 @@ func (g *Geocode) IP(ip string) (*GeocodeResponse, *APIError) {
8399
return res, nil
84100
}
85101

86-
func (g *Geocode) Reverse(longitude, latitude float64, options GeocodeReverseOptions) (*GeocodeResponse, *APIError) {
102+
func (g *Geocode) Reverse(latitude, longitude float64) (*GeocodeResponse, *APIError) {
103+
return g.ReverseWithOptions(latitude, longitude, GeocodeReverseOptions{})
104+
}
105+
106+
func (g *Geocode) ReverseWithOptions(latitude, longitude float64, options GeocodeReverseOptions) (*GeocodeResponse, *APIError) {
87107
res := new(GeocodeResponse)
88108
err := new(APIError)
89109
r, e := g.resty.R().
90110
SetQueryParams(map[string]string{
91-
"longitude": strconv.FormatFloat(longitude, 'f', -1, 64),
92111
"latitude": strconv.FormatFloat(latitude, 'f', -1, 64),
112+
"longitude": strconv.FormatFloat(longitude, 'f', -1, 64),
113+
"foramt": options.Foramt,
93114
"limit": strconv.Itoa(options.Limit),
94115
}).
95116
SetResult(res).

watermark.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ type (
88
}
99

1010
WatermarkImageOptions struct {
11-
File string
12-
Text string
1311
Font string
1412
Size int
1513
Color string
@@ -23,7 +21,11 @@ type (
2321
}
2422
)
2523

26-
func (w *Watermark) Image(file, text string, options WatermarkImageOptions) (*WatermarkImageResponse, *APIError) {
24+
func (w *Watermark) Image(file, text string) (*WatermarkImageResponse, *APIError) {
25+
return w.ImageWithOptions(file, text, WatermarkImageOptions{})
26+
}
27+
28+
func (w *Watermark) ImageWithOptions(file, text string, options WatermarkImageOptions) (*WatermarkImageResponse, *APIError) {
2729
res := new(WatermarkImageResponse)
2830
err := new(APIError)
2931
r, e := w.resty.R().

webpage.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ type (
1515
}
1616
)
1717

18-
func (w *Webpage) PDF(url string, options WebpagePDFOptions) (*WebpagePDFResponse, *APIError) {
18+
func (w *Webpage) PDF(url string) (*WebpagePDFResponse, *APIError) {
19+
return w.PDFWithOptions(url, WebpagePDFOptions{})
20+
}
21+
22+
func (w *Webpage) PDFWithOptions(url string, options WebpagePDFOptions) (*WebpagePDFResponse, *APIError) {
1923
res := new(WebpagePDFResponse)
2024
err := new(APIError)
2125
r, e := w.resty.R().

0 commit comments

Comments
 (0)