smtpbz 1.0.1 → 1.1.0
raw patch · 5 files changed
+15/−24 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Smtpbz: type Lens s t a b = forall f. Functor f => (a -> f b) -> s -> f t
- Smtpbz: type Lens' s a = Lens s s a a
- Smtpbz.Internal.Has: type Lens s t a b = forall f. Functor f => (a -> f b) -> s -> f t
- Smtpbz.Internal.Has: type Lens' s a = Lens s s a a
- Smtpbz.Internal.Has: view :: Lens s t a b -> s -> a
- Smtpbz: apiKey :: Has t => Lens' t ByteString
+ Smtpbz: apiKey :: Has t => t -> ByteString
- Smtpbz: baseUrl :: Has t => Lens' t Text
+ Smtpbz: baseUrl :: Has t => t -> Text
- Smtpbz: httpMan :: Has t => Lens' t Manager
+ Smtpbz: httpMan :: Has t => t -> Manager
- Smtpbz.Internal.Has: apiKey :: Has t => Lens' t ByteString
+ Smtpbz.Internal.Has: apiKey :: Has t => t -> ByteString
- Smtpbz.Internal.Has: baseUrl :: Has t => Lens' t Text
+ Smtpbz.Internal.Has: baseUrl :: Has t => t -> Text
- Smtpbz.Internal.Has: httpMan :: Has t => Lens' t Manager
+ Smtpbz.Internal.Has: httpMan :: Has t => t -> Manager
Files
- CHANGELOG.markdown +5/−0
- smtpbz.cabal +2/−2
- src/Smtpbz.hs +1/−1
- src/Smtpbz/Internal/Api.hs +4/−4
- src/Smtpbz/Internal/Has.hs +3/−17
CHANGELOG.markdown view
@@ -1,3 +1,8 @@+1.1.0+=====++ * Simplified Smtpbz.Has+ 1.0.0 =====
smtpbz.cabal view
@@ -1,11 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.34.7.+-- This file has been generated from package.yaml by hpack version 0.36.0. -- -- see: https://github.com/sol/hpack name: smtpbz-version: 1.0.1+version: 1.1.0 synopsis: Unofficial API client for smtp.bz description: See README.markdown category: Web
src/Smtpbz.hs view
@@ -3,5 +3,5 @@ , module Smtpbz.Internal.Api ) where -import Smtpbz.Internal.Has (Has(..), Lens, Lens')+import Smtpbz.Internal.Has (Has(..)) import Smtpbz.Internal.Api
src/Smtpbz/Internal/Api.hs view
@@ -40,7 +40,7 @@ import qualified Network.HTTP.Types as Http import Text.Printf (printf) -import Smtpbz.Internal.Has (Has(..), view)+import Smtpbz.Internal.Has (Has(..)) -- | User data.@@ -189,14 +189,14 @@ prepareApiCall :: Has smtpbz => smtpbz -> String -> IO Http.Request prepareApiCall smtpbz path = do- req <- Http.parseRequest (printf "%s/%s" (view baseUrl smtpbz) path)+ req <- Http.parseRequest (printf "%s/%s" (baseUrl smtpbz) path) pure req- { Http.requestHeaders = ("Authorization", view apiKey smtpbz) : Http.requestHeaders req+ { Http.requestHeaders = ("Authorization", apiKey smtpbz) : Http.requestHeaders req } callApi :: Has smtpbz => smtpbz -> Http.Request -> IO (Http.Response Lazy.ByteString) callApi smtpbz req =- Http.httpLbs req (view httpMan smtpbz)+ Http.httpLbs req (httpMan smtpbz) -- | Check if response status code is in [200, 300). successfulCall :: Http.Response Lazy.ByteString -> Bool
src/Smtpbz/Internal/Has.hs view
@@ -1,13 +1,9 @@ {-# LANGUAGE RankNTypes #-} module Smtpbz.Internal.Has ( Has(..)- , Lens- , Lens'- , view ) where import Data.ByteString (ByteString)-import Data.Functor.Const (Const(..)) import Data.Text (Text) import qualified Network.HTTP.Conduit as Http @@ -16,18 +12,8 @@ -- and the user may want to override. class Has t where -- | API key; get one at https://smtp.bz/panel/user- apiKey :: Lens' t ByteString+ apiKey :: t -> ByteString -- | API base URL; Most likely, https://api.smtp.bz/v1- baseUrl :: Lens' t Text+ baseUrl :: t -> Text -- | The 'Http.Manager' under which all requests will be made.- httpMan :: Lens' t Http.Manager---- | Type changing stabby lenses.-type Lens s t a b = forall f. Functor f => (a -> f b) -> s -> f t---- | Stabby lenses that can't change the type.-type Lens' s a = Lens s s a a--view :: Lens s t a b -> s -> a-view l x = getConst (l Const x)-{-# INLINE view #-}+ httpMan :: t -> Http.Manager