packages feed

paypal-api 0.1 → 0.2

raw patch · 5 files changed

+38/−30 lines, 5 filesdep +conduitdep +http-conduitdep +mtldep −enumeratordep −http-enumeratordep −monads-fddep ~bytestringdep ~containersdep ~failurePVP ok

version bump matches the API change (PVP)

Dependencies added: conduit, http-conduit, mtl

Dependencies removed: enumerator, http-enumerator, monads-fd, web-encodings

Dependency ranges changed: bytestring, containers, failure, http-types, wai

API changes (from Hackage documentation)

- Network.PayPal.ButtonManager: class ToText bt => ButtonType bt where { data family Variables bt :: *; type family Amount bt :: *; type family Shipping bt :: *; type family UndefinedQuantity bt :: *; }
+ Network.PayPal.ButtonManager: class ToText bt => ButtonType bt where data family Variables bt :: * type family Amount bt :: * type family Shipping bt :: * type family UndefinedQuantity bt :: *
- Network.PayPal.ButtonManager: class Rank r where { type family RankPrice r :: *; }
+ Network.PayPal.ButtonManager: class Rank r where type family RankPrice r :: *
- Network.PayPal.NVP: processResponse :: (PayPalRequest req, Monad m) => req -> Status -> ResponseHeaders -> Iteratee ByteString m (Either Response (Status (PayPalResponse req)))
+ Network.PayPal.NVP: processResponse :: (PayPalRequest req, MonadIO m) => req -> Response ByteString -> m (Either (Response ByteString) (Status (PayPalResponse req)))
- Network.PayPal.NVP: submit :: (Failure HttpException m, MonadIO m, PayPalRequest req) => Service -> Credentials -> req -> m (Either Response (Status (PayPalResponse req)))
+ Network.PayPal.NVP: submit :: (Failure HttpException m, MonadIO m, PayPalRequest req) => Service -> Credentials -> req -> m (Either (Response ByteString) (Status (PayPalResponse req)))
- Network.PayPal.Types: class ToVariables req => PayPalRequest req where { data family PayPalResponse req :: *; }
+ Network.PayPal.Types: class ToVariables req => PayPalRequest req where data family PayPalResponse req :: *

Files

Network/PayPal/ButtonManager.hs view
@@ -73,8 +73,7 @@ import qualified Data.Text.Encoding as T import Data.Time.Format import Debug.Trace-import Network.HTTP.Enumerator-import Web.Encodings (decodeUrlPairs)+import Network.HTTP.Conduit import Numeric  
Network/PayPal/NVP.hs view
@@ -20,13 +20,12 @@ import qualified Data.ByteString as B import qualified Data.ByteString.Char8 as C import qualified Data.ByteString.Lazy as L+import Data.Maybe import Data.Monoid-import Network.HTTP.Enumerator as HTTP+import Network.HTTP.Conduit as HTTP import Network.HTTP.Types as HTTP-import Web.Encodings (decodeUrlPairs) import System.IO.Unsafe-import Data.Enumerator (Iteratee (..), run_)-import Data.Enumerator.List (consume)+import Data.Conduit import qualified Network.Wai as W  @@ -54,14 +53,14 @@           Service        -> Credentials        -> req-       -> m (Either Response (PayPal.Status (PayPalResponse req)))+       -> m (Either (Response L.ByteString) (PayPal.Status (PayPalResponse req))) submit service cred req = do     -- Re-using connections (i.e. not creating a new manager each time) fails with     -- an exception for some reason:     --     -- too few bytes. Failed reading at byte position 1-    mgr <- liftIO newManager-    run_ $ httpRedirect (prepareRequest service cred req) (processResponse req) mgr+    res <- liftIO $ withManager $ httpLbs (prepareRequest service cred req)+    processResponse req res  -- | Construct an HTTP request for the specified PayPal request. prepareRequest :: (Monad m, PayPalRequest req) =>@@ -78,18 +77,17 @@          ("VERSION", version),          ("SIGNATURE", sig)] ++ toVariables req -processResponse :: (PayPalRequest req, Monad m) =>+processResponse :: (PayPalRequest req, MonadIO m) =>                    req-                -> HTTP.Status-                -> ResponseHeaders-                -> Iteratee B.ByteString m (Either Response (PayPal.Status (PayPalResponse req)))-processResponse req (Status statusCode _) headers = do-    body <- L.fromChunks <$> consume+                -> Response L.ByteString+                -> m (Either (Response L.ByteString) (PayPal.Status (PayPalResponse req)))+processResponse req res = do+    let Status statusCode _ = responseStatus res+        body = responseBody res     return $ case statusCode of         200 -> Right . decodeResponseChecking-                     . map (textify *** textify)-                     . decodeUrlPairs $ body-        _   -> Left $ Response statusCode headers body-  where-    textify = mconcat . L.toChunks+                     . map (second (fromMaybe mempty))+                     . parseQuery+                     . (mconcat . L.toChunks) $ body+        _   -> Left res 
Network/PayPal/Types.hs view
@@ -10,8 +10,7 @@         FromText(..),         ToVariables(..),         FromVariables(..),-        PayPalRequest(decodeResponse),-        PayPalResponse(..),+        PayPalRequest(decodeResponse, type PayPalResponse),         -- * Helpers         decodeResponseChecking,         toTextTime,
example.hs view
@@ -7,7 +7,7 @@ import Data.Time.Calendar import Data.Time.LocalTime import Control.Monad-import Network.HTTP.Enumerator (newManager)+import Network.HTTP.Conduit  me = Credentials {         crUsername = "your_username_here",
paypal-api.cabal view
@@ -1,5 +1,5 @@ name: paypal-api-version: 0.1+version: 0.2 cabal-version: >=1.6 build-type: Simple license: BSD3@@ -7,7 +7,7 @@ copyright: Copyright (C) 2011 by Stephen Blackheath maintainer: http://blacksapphire.com/antispam/ stability: alpha-homepage: http://code.haskell.org/paypal-api/+homepage: http://projects.haskell.org/paypal-api/ package-url: bug-reports: synopsis: PayPal API, currently supporting "ButtonManager"@@ -37,10 +37,13 @@              beyond pathetic. category: Network author: Stephen Blackheath- Extra-Source-Files:   example.hs +source-repository head+    type:     darcs+    location: http://code.haskell.org/paypal-api/+ library   exposed-modules:       Network.PayPal.ButtonManager@@ -48,10 +51,19 @@       Network.PayPal.Types   exposed: True   buildable: True-  build-depends: base >=4 && <5, bytestring -any, containers -any,-               enumerator -any, failure -any, http-enumerator -any,-               http-types -any, monads-fd -any, old-locale -any, text -any,-               time -any, wai -any, web-encodings -any+  build-depends:+      base >=4 && <5,+      bytestring >= 0.9.1.4 && < 0.10,+      containers >= 0.2,+      conduit == 0.5.*,+      failure >= 0.1,+      http-conduit == 1.5.*,+      http-types >= 0.6.0 && < 0.8.0,+      mtl -any,+      old-locale -any,+      text -any,+      time -any,+      wai == 1.3.*   ghc-options:       -fwarn-unused-binds       -fwarn-incomplete-patterns