@@ -3,6 +3,10 @@ package labstack
33import "strconv"
44
55type (
6+ Geocode struct {
7+ * Client
8+ }
9+
610 GeocodeAddressRequest struct {
711 Location string
812 Longitude float64
@@ -40,10 +44,10 @@ type (
4044 }
4145)
4246
43- func (c * Client ) GeocodeAddress (req * GeocodeAddressRequest ) (* GeocodeResponse , * APIError ) {
47+ func (g * Geocode ) Address (req * GeocodeAddressRequest ) (* GeocodeResponse , * APIError ) {
4448 res := new (GeocodeResponse )
4549 err := new (APIError )
46- r , e := c .resty .R ().
50+ r , e := g .resty .R ().
4751 SetQueryParams (map [string ]string {
4852 "location" : req .Location ,
4953 "longitude" : strconv .FormatFloat (req .Longitude , 'f' , - 1 , 64 ),
@@ -60,16 +64,16 @@ func (c *Client) GeocodeAddress(req *GeocodeAddressRequest) (*GeocodeResponse, *
6064 Message : e .Error (),
6165 }
6266 }
63- if c .error (r ) {
67+ if g .error (r ) {
6468 return nil , err
6569 }
6670 return res , nil
6771}
6872
69- func (c * Client ) GeocodeIP (req * GeocodeIPRequest ) (* GeocodeResponse , * APIError ) {
73+ func (g * Geocode ) IP (req * GeocodeIPRequest ) (* GeocodeResponse , * APIError ) {
7074 res := new (GeocodeResponse )
7175 err := new (APIError )
72- r , e := c .resty .R ().
76+ r , e := g .resty .R ().
7377 SetQueryParams (map [string ]string {
7478 "ip" : req .IP ,
7579 }).
@@ -81,16 +85,16 @@ func (c *Client) GeocodeIP(req *GeocodeIPRequest) (*GeocodeResponse, *APIError)
8185 Message : e .Error (),
8286 }
8387 }
84- if c .error (r ) {
88+ if g .error (r ) {
8589 return nil , err
8690 }
8791 return res , nil
8892}
8993
90- func (c * Client ) GeocodeReverse (req * GeocodeReverseRequest ) (* GeocodeResponse , * APIError ) {
94+ func (g * Geocode ) Reverse (req * GeocodeReverseRequest ) (* GeocodeResponse , * APIError ) {
9195 res := new (GeocodeResponse )
9296 err := new (APIError )
93- r , e := c .resty .R ().
97+ r , e := g .resty .R ().
9498 SetQueryParams (map [string ]string {
9599 "longitude" : strconv .FormatFloat (req .Longitude , 'f' , - 1 , 64 ),
96100 "latitude" : strconv .FormatFloat (req .Latitude , 'f' , - 1 , 64 ),
@@ -105,7 +109,7 @@ func (c *Client) GeocodeReverse(req *GeocodeReverseRequest) (*GeocodeResponse, *
105109 Message : e .Error (),
106110 }
107111 }
108- if c .error (r ) {
112+ if g .error (r ) {
109113 return nil , err
110114 }
111115 return res , nil
0 commit comments