Skip to content

Commit 5255448

Browse files
authored
Merge pull request #2 from Ziptastic/initial-version
ziptastic-client version 0.2.0.0
2 parents d756f49 + 5a49d88 commit 5255448

File tree

6 files changed

+73
-39
lines changed

6 files changed

+73
-39
lines changed

cabal.project

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
packages:
2+
ziptastic-core/
3+
ziptastic-client/

ziptastic-client/CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Changelog
2+
3+
## 0.2.0.0
4+
5+
* For failures, provide full `ServantError` instead converting it to `String`.
6+
* Add version bounds.
7+
* Clean up documentation and meta information.
8+
* Add change log.
9+
10+
## 0.1.0.0
11+
12+
* Initial release.

ziptastic-client/src/Ziptastic/Client.hs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,42 +36,49 @@ import Data.Text (Text)
3636
import Network.HTTP.Client (Manager)
3737
import Servant.API ((:<|>)(..))
3838
import Servant.Client
39-
( BaseUrl(..), ClientEnv(..), ClientM, Scheme(..)
39+
( BaseUrl(..), ClientEnv(..), ClientM, Scheme(..), ServantError
4040
, client, runClientM
4141
)
4242

4343
import Ziptastic.Core (ApiKey, ForApi(..), LocaleInfo)
4444
import qualified Ziptastic.Core as Core
4545

46+
-- | Performs a forward geocode lookup at the given country and postal code.
47+
--
48+
-- The success result is a list because in rare cases you may receive multiple records.
49+
-- If the request fails the result will be 'Left' with an error.
4650
forwardGeocode :: ApiKey
4751
-> Manager -- ^ HTTP connection manager
4852
-> CountryCode -- ^ country
4953
-> Text -- ^ postal code
50-
-> IO (Either String [LocaleInfo])
51-
forwardGeocode apiKey manager countryCode postalCode = strLeft <$> runClientM func (ClientEnv manager baseUrl)
54+
-> IO (Either ServantError [LocaleInfo])
55+
forwardGeocode apiKey manager countryCode postalCode = runClientM func (ClientEnv manager baseUrl)
5256
where func = forwardGeocode' (apiClient apiKey) (ForApi countryCode) postalCode
5357

5458
-- | Performs a reverse geocode lookup at the given coordinates using a default radius of 5000 meters.
59+
--
60+
-- The success result is a list because in rare cases you may receive multiple records.
61+
-- If the request fails the result will be 'Left' with an error.
5562
reverseGeocode :: ApiKey
5663
-> Manager -- ^ HTTP connection manager
5764
-> Double -- ^ latitude
5865
-> Double -- ^ longitude
59-
-> IO (Either String [LocaleInfo])
66+
-> IO (Either ServantError [LocaleInfo])
6067
reverseGeocode apiKey manager lat long = reverseGeocodeWithRadius apiKey manager lat long 5000
6168

6269
-- | Performs a reverse geocode lookup at the given coordinates using a specified radius in meters.
70+
--
71+
-- The success result is a list because in rare cases you may receive multiple records.
72+
-- If the request fails the result will be 'Left' with an error.
6373
reverseGeocodeWithRadius :: ApiKey
6474
-> Manager -- ^ HTTP connection manager
6575
-> Double -- ^ latitude
6676
-> Double -- ^ longitude
6777
-> Int -- ^ radius (in meters)
68-
-> IO (Either String [LocaleInfo])
69-
reverseGeocodeWithRadius apiKey manager lat long radius = strLeft <$> runClientM func (ClientEnv manager baseUrl)
78+
-> IO (Either ServantError [LocaleInfo])
79+
reverseGeocodeWithRadius apiKey manager lat long radius = runClientM func (ClientEnv manager baseUrl)
7080
where func = reverseGeocodeWithRadius' (mkReverseGeocode (apiClient apiKey) lat long) radius
7181

72-
strLeft :: Show e => Either e a -> Either String a
73-
strLeft (Left e) = Left (show e)
74-
strLeft (Right a) = Right a
7582

7683
data ApiClient = ApiClient
7784
{ forwardGeocode' :: ForApi CountryCode -> Text -> ClientM [LocaleInfo]

ziptastic-client/ziptastic-client.cabal

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
name: ziptastic-client
2-
version: 0.1.0.0
2+
version: 0.2.0.0
33
synopsis:
4-
Core Servant specification for the Ziptastic API (https://www.getziptastic.com) for doing forward and reverse geocoding.
4+
A type-safe client for the Ziptastic API for doing forward and reverse geocoding.
55
description:
6-
This package provides a type-safe Servant specification for the Ziptastic
7-
(https://www.getziptastic.com) API for doing forward and reverse geocoding
8-
via zip/postal code, latitude, and longitude.
6+
A convenient and type-safe client library for the
7+
Ziptastic (<https://www.getziptastic.com/>) API providing forward and reverse
8+
geocoding via country, zip code (postal code), latitude, and longitude.
99
.
10-
This package is maintained by Grafted-In (https://www.graftedin.io/).
10+
This package is maintained by Grafted-In (<https://www.graftedin.io/>).
1111
homepage: https://github.com/Ziptastic/ziptastic-haskell#readme
1212
license: BSD3
1313
license-file: LICENSE
@@ -19,25 +19,23 @@ build-type: Simple
1919
extra-source-files: README.md
2020
cabal-version: >=1.10
2121
tested-with: GHC==8.0.2
22+
extra-source-files:
23+
CHANGELOG.md
24+
README.md
2225

2326
library
2427
hs-source-dirs: src
2528
exposed-modules: Ziptastic.Client
2629
build-depends:
27-
base >= 4.7 && < 5
28-
, bytestring
29-
, aeson
30-
, http-api-data
30+
base >= 4.7 && < 5
3131
, http-client
32-
, http-client-tls
3332
, iso3166-country-codes
34-
, servant
35-
, servant-client
33+
, servant >= 0.9 && <= 0.11
34+
, servant-client >= 0.9 && <= 0.11
3635
, text
37-
, tz
38-
, ziptastic-core
36+
, ziptastic-core == 0.1.0.1
3937
default-language: Haskell2010
40-
extensions:
38+
other-extensions:
4139
DataKinds
4240
TypeOperators
4341
OverloadedStrings

ziptastic-core/CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Changelog
2+
3+
## 0.1.0.1
4+
5+
* Add version bounds.
6+
* Clean up documentation and meta information.
7+
* Add change log.
8+
9+
## 0.1.0.0
10+
11+
* Initial release.

ziptastic-core/ziptastic-core.cabal

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
name: ziptastic-core
2-
version: 0.1.0.0
2+
version: 0.1.0.1
33
synopsis:
4-
Core Servant specification for the Ziptastic API (https://www.getziptastic.com) for doing forward and reverse geocoding.
4+
Core Servant specification for the Ziptastic API for doing forward and reverse geocoding.
55
description:
66
This package provides a type-safe Servant specification for the Ziptastic
7-
(https://www.getziptastic.com) API for doing forward and reverse geocoding
7+
(<https://www.getziptastic.com>) API for doing forward and reverse geocoding
88
via zip/postal code, latitude, and longitude.
99
.
10-
If you want to use the Ziptastic API in your application, try the ziptastic-client package.
10+
If you want to use the Ziptastic API in your application, try the @ziptastic-client@ package.
1111
.
12-
This package is maintained by Grafted-In (https://www.graftedin.io/).
12+
This package is maintained by Grafted-In (<https://www.graftedin.io/>).
1313
homepage: https://github.com/Ziptastic/ziptastic-haskell#readme
1414
license: BSD3
1515
license-file: LICENSE
@@ -21,21 +21,24 @@ build-type: Simple
2121
extra-source-files: README.md
2222
cabal-version: >=1.10
2323
tested-with: GHC==8.0.2
24+
extra-source-files:
25+
CHANGELOG.md
26+
README.md
2427

2528
library
2629
hs-source-dirs: src
2730
exposed-modules: Ziptastic.Core
2831
build-depends:
29-
aeson
30-
, base >= 4.7 && < 5
31-
, bytestring
32-
, http-api-data
33-
, iso3166-country-codes
34-
, servant
35-
, text
36-
, tz
32+
aeson >= 0.7 && < 1.2
33+
, base >= 4.7 && < 5
34+
, bytestring == 0.10.*
35+
, http-api-data == 0.3.*
36+
, iso3166-country-codes >= 0.20140203.8
37+
, servant >= 0.9 && < 0.11
38+
, text >= 0.11
39+
, tz == 0.1.*
3740
default-language: Haskell2010
38-
extensions:
41+
other-extensions:
3942
DataKinds
4043
DeriveGeneric
4144
FlexibleInstances

0 commit comments

Comments
 (0)