mangopay 1.11.5 → 1.12
raw patch · 13 files changed
+54/−62 lines, 13 filesdep ~transformersdep ~waidep ~warp
Dependency ranges changed: transformers, wai, warp
Files
- mangopay.cabal +4/−4
- src/Web/MangoPay.hs +1/−0
- src/Web/MangoPay/Accounts.hs +1/−2
- src/Web/MangoPay/Cards.hs +2/−3
- src/Web/MangoPay/Documents.hs +3/−5
- src/Web/MangoPay/Events.hs +10/−11
- src/Web/MangoPay/Payins.hs +4/−5
- src/Web/MangoPay/Payouts.hs +2/−3
- src/Web/MangoPay/Refunds.hs +2/−3
- src/Web/MangoPay/Types.hs +11/−8
- src/Web/MangoPay/Users.hs +5/−6
- src/Web/MangoPay/Wallets.hs +7/−10
- test/Web/MangoPay/UsersTest.hs +2/−2
mangopay.cabal view
@@ -1,5 +1,5 @@ name: mangopay-version: 1.11.5+version: 1.12 cabal-version: >= 1.8 build-type: Simple author: JP Moresmau <jpmoresmau@gmail.com>@@ -31,7 +31,7 @@ base >= 4 && < 5 , bytestring >= 0.9 , text >= 0.11- , transformers >= 0.2 && < 0.5+ , transformers >= 0.2 && < 0.6 , transformers-base , monad-control , resourcet@@ -58,8 +58,8 @@ , async >= 2.0 , blaze-builder , HUnit >= 1.2.5- , wai >= 3.0 && < 3.1- , warp >= 3.0 && < 3.2+ , wai >= 3.0 && < 3.3+ , warp >= 3.0 && < 3.3 -- Needed for withWorkaroundManager , tls
src/Web/MangoPay.hs view
@@ -14,6 +14,7 @@ ,OAuthToken(..) ,Pagination(..) ,PagedList(..)+ ,MpTime(..) ,MPUsableMonad ,ToHtQuery(..) ,CardExpiration(..)
src/Web/MangoPay/Accounts.hs view
@@ -14,7 +14,6 @@ import Data.Aeson import Data.Aeson.Types import Data.Maybe (fromMaybe)-import Data.Time.Clock.POSIX (POSIXTime) import Control.Applicative import qualified Data.ByteString as BS@@ -115,7 +114,7 @@ -- | bank account details data BankAccount = BankAccount { baId :: Maybe BankAccountId- ,baCreationDate :: Maybe POSIXTime+ ,baCreationDate :: Maybe MpTime ,baUserId :: Maybe AnyUserId ,baTag :: Maybe Text ,baDetails :: BankAccountDetails
src/Web/MangoPay/Cards.hs view
@@ -12,7 +12,6 @@ import Data.Text import Data.Typeable (Typeable) import Data.Aeson-import Data.Time.Clock.POSIX (POSIXTime) import Control.Applicative import qualified Data.HashMap.Lazy as HM@@ -46,7 +45,7 @@ -- | a card registration data CardRegistration = CardRegistration { crId :: Maybe CardRegistrationId -- ^ The Id of the object- ,crCreationDate :: Maybe POSIXTime -- ^ The creation date of the object+ ,crCreationDate :: Maybe MpTime -- ^ The creation date of the object ,crTag :: Maybe Text -- ^ Custom data ,crUserId :: AnyUserId -- ^ The Id of the author ,crCurrency :: Currency -- ^ The currency of the card registrated@@ -113,7 +112,7 @@ -- | a registered card data Card=Card { cId :: CardId- ,cCreationDate :: POSIXTime+ ,cCreationDate :: MpTime ,cTag :: Maybe Text ,cExpirationDate :: CardExpiration -- ^ MMYY ,cAlias :: Text -- ^ Example: 497010XXXXXX4414
src/Web/MangoPay/Documents.hs view
@@ -3,7 +3,6 @@ -- | handle documents and pages module Web.MangoPay.Documents where - import Web.MangoPay.Monad import Web.MangoPay.Types import Web.MangoPay.Users@@ -13,7 +12,6 @@ import Data.Text hiding (any) import Data.Typeable (Typeable) import Data.Aeson-import Data.Time.Clock.POSIX (POSIXTime) import Control.Applicative import qualified Data.ByteString as BS@@ -98,7 +96,7 @@ -- | a document data Document = Document { dId :: Maybe DocumentId- ,dCreationDate :: Maybe POSIXTime+ ,dCreationDate :: Maybe MpTime ,dTag :: Maybe Text -- ^ custom data for client ,dType :: DocumentType ,dStatus :: Maybe DocumentStatus@@ -169,8 +167,8 @@ -- | A filter for document lists. data DocumentFilter = DocumentFilter {- dfBefore :: Maybe POSIXTime- , dfAfter :: Maybe POSIXTime+ dfBefore :: Maybe MpTime+ , dfAfter :: Maybe MpTime , dfStatus :: Maybe DocumentStatus , dfType :: Maybe DocumentType } deriving (Show,Eq,Ord,Typeable)
src/Web/MangoPay/Events.hs view
@@ -10,7 +10,6 @@ import Data.Text hiding (filter,map,toLower) import Data.Typeable (Typeable) import Data.Aeson-import Data.Time.Clock.POSIX (POSIXTime) import Data.Default import Control.Applicative import qualified Network.HTTP.Types as HT@@ -104,8 +103,8 @@ -- | search parameters for events data EventSearchParams=EventSearchParams{ espEventType :: Maybe EventType- ,espBeforeDate :: Maybe POSIXTime- ,espAfterDate :: Maybe POSIXTime+ ,espBeforeDate :: Maybe MpTime+ ,espAfterDate :: Maybe MpTime ,espPagination :: Maybe Pagination ,espSortByDate :: Maybe SortDirection }@@ -131,7 +130,7 @@ data Event=Event { eResourceId :: Text ,eEventType :: EventType- ,eDate :: POSIXTime+ ,eDate :: MpTime } deriving (Show,Eq,Ord,Typeable) @@ -152,9 +151,9 @@ -- v2 works the same, the event is passed via parameters of the query string eventFromQueryString :: HT.Query -> Maybe Event eventFromQueryString q=do- rid<-fmap TE.decodeUtf8 $ join $ findAssoc q "RessourceId" -- yes, two ss here- et<-join $ fmap (maybeRead . BS.unpack) $ join $ findAssoc q "EventType"- d<-fmap fromIntegral $ join $ fmap ((maybeRead :: String -> Maybe Integer). BS.unpack) $ join $ findAssoc q "Date"+ rid <- fmap TE.decodeUtf8 $ join $ findAssoc q "RessourceId" -- yes, two ss here+ et <- join $ fmap (maybeRead . BS.unpack) $ join $ findAssoc q "EventType"+ d <- fmap (MpTime . fromIntegral) $ join $ fmap ((maybeRead :: String -> Maybe Integer). BS.unpack) $ join $ findAssoc q "Date" return $ Event rid et d @@ -163,9 +162,9 @@ -- v2 works the same, the event is passed via parameters of the query string eventFromQueryStringT :: [(Text, Text)] -> Maybe Event eventFromQueryStringT q=do- rid<- findAssoc q "RessourceId" -- yes, two ss here- et<-join $ fmap (maybeRead . unpack) $ findAssoc q "EventType"- d<-fmap fromIntegral $ join $ fmap ((maybeRead :: String -> Maybe Integer). unpack) $ findAssoc q "Date"+ rid <- findAssoc q "RessourceId" -- yes, two ss here+ et <- join $ fmap (maybeRead . unpack) $ findAssoc q "EventType"+ d <- fmap (MpTime . fromIntegral) $ join $ fmap ((maybeRead :: String -> Maybe Integer). unpack) $ findAssoc q "Date" return $ Event rid et d -- | status of notification hook@@ -204,7 +203,7 @@ -- | a notification hook data Hook=Hook { hId :: Maybe HookId -- ^ The Id of the hook details- ,hCreationDate :: Maybe POSIXTime+ ,hCreationDate :: Maybe MpTime ,hTag :: Maybe Text -- ^ Custom data ,hUrl :: Text -- ^This is the URL where you receive notification for each EventType ,hStatus :: HookStatus
src/Web/MangoPay/Payins.hs view
@@ -12,7 +12,6 @@ import Data.Text import Data.Typeable (Typeable) import Data.Aeson-import Data.Time.Clock.POSIX (POSIXTime) import Control.Applicative -- | create a bankwire pay-in@@ -64,7 +63,7 @@ -- so this could probably become a "Payment" type data BankWire=BankWire { bwId :: Maybe BankWireId- ,bwCreationDate :: Maybe POSIXTime+ ,bwCreationDate :: Maybe MpTime ,bwTag :: Maybe Text -- ^ custom data ,bwAuthorId :: AnyUserId -- ^ The user Id of the author ,bwCreditedUserId :: AnyUserId -- ^ It represents the amount credited on the targeted e-wallet.@@ -80,7 +79,7 @@ ,bwStatus :: Maybe TransferStatus -- ^ The status of the payment ,bwResultCode :: Maybe Text -- ^ The transaction result code ,bwResultMessage :: Maybe Text -- ^ The transaction result Message- ,bwExecutionDate :: Maybe POSIXTime -- ^ The date when the payment is processed+ ,bwExecutionDate :: Maybe MpTime -- ^ The date when the payment is processed ,bwType :: Maybe TransactionType -- ^ The type of the transaction ,bwNature :: Maybe TransactionNature -- ^ The nature of the transaction: ,bwPaymentType :: Maybe PaymentType -- ^ The type of the payment (which type of mean of payment is used).@@ -133,7 +132,7 @@ -- | direct pay in via registered card data CardPayin=CardPayin { cpId :: Maybe CardPayinId- ,cpCreationDate :: Maybe POSIXTime+ ,cpCreationDate :: Maybe MpTime ,cpTag :: Maybe Text -- ^ custom data ,cpAuthorId :: AnyUserId -- ^ The user Id of the author ,cpCreditedUserId :: AnyUserId -- ^ The user Id of the owner of the credited wallet@@ -149,7 +148,7 @@ ,cpStatus :: Maybe TransferStatus -- ^ The status of the payment ,cpResultCode :: Maybe Text -- ^ The transaction result code ,cpResultMessage :: Maybe Text -- ^ The transaction result Message- ,cpExecutionDate :: Maybe POSIXTime -- The date when the payment is processed+ ,cpExecutionDate :: Maybe MpTime -- The date when the payment is processed ,cpType :: Maybe TransactionType -- ^ The type of the transaction ,cpNature :: Maybe TransactionNature -- ^ The nature of the transaction: ,cpPaymentType :: Maybe Text -- ^ The type of the payment (which type of mean of payment is used).
src/Web/MangoPay/Payouts.hs view
@@ -12,7 +12,6 @@ import Data.Text import Data.Typeable (Typeable) import Data.Aeson-import Data.Time.Clock.POSIX (POSIXTime) import Control.Applicative -- | create a payout@@ -34,7 +33,7 @@ -- | payout data Payout=Payout { ptId :: Maybe PayoutId- ,ptCreationDate :: Maybe POSIXTime+ ,ptCreationDate :: Maybe MpTime ,ptTag :: Maybe Text -- ^ custom data for client ,ptAuthorId :: AnyUserId -- ^ The user Id of the author ,ptDebitedWalletId :: WalletId@@ -46,7 +45,7 @@ ,ptStatus :: Maybe TransferStatus ,ptResultCode :: Maybe Text -- ^ The transaction result code ,ptResultMessage :: Maybe Text -- ^ The transaction result code- ,ptExecutionDate :: Maybe POSIXTime+ ,ptExecutionDate :: Maybe MpTime ,ptType :: Maybe TransactionType ,ptNature :: Maybe TransactionNature ,ptPaymentType :: Maybe PaymentType
src/Web/MangoPay/Refunds.hs view
@@ -12,7 +12,6 @@ import Data.Text import Data.Typeable (Typeable) import Data.Aeson-import Data.Time.Clock.POSIX (POSIXTime) import Control.Applicative -- | refund a transfer@@ -51,7 +50,7 @@ -- | refund of a transfer data Refund=Refund{ rId :: RefundId -- ^ Id of the refund- ,rCreationDate :: POSIXTime+ ,rCreationDate :: MpTime ,rTag :: Maybe Text -- ^ Custom data ,rAuthorId :: AnyUserId -- ^ The user Id of the author ,rDebitedFunds :: Amount -- ^ Strictly positive amount. In cents.@@ -60,7 +59,7 @@ ,rStatus :: TransferStatus ,rResultCode :: Text -- ^ The transaction result code ,rResultMessage :: Maybe Text -- ^ The transaction result Message- ,rExecutionDate :: Maybe POSIXTime+ ,rExecutionDate :: Maybe MpTime ,rType :: TransactionType ,rNature :: TransactionNature ,rCreditedUserId :: Maybe AnyUserId -- ^ Id of the user owner of the credited wallet
src/Web/MangoPay/Types.hs view
@@ -135,7 +135,7 @@ igeId :: Text ,igeType :: Text ,igeMessage :: Text- ,igeDate :: Maybe POSIXTime+ ,igeDate :: Maybe MpTime } deriving (Show,Eq,Ord,Typeable) @@ -154,14 +154,17 @@ v .: "Date" parseJSON _= fail "MpError" +-- | @newtype@ of 'POSIXTime' with MangoPay's JSON format.+newtype MpTime = MpTime { unMpTime :: POSIXTime } deriving (Eq, Ord, Show)+ -- | from json as per MangoPay format-instance FromJSON POSIXTime where- parseJSON n@(Number _)=(fromIntegral . (round::Double -> Integer)) <$> parseJSON n- parseJSON o = fail $ "POSIXTime: " ++ show o+instance FromJSON MpTime where+ parseJSON n@(Number _) = (MpTime . fromIntegral . (round::Double -> Integer)) <$> parseJSON n+ parseJSON o = fail $ "MpTime: " ++ show o -- | to json as per MangoPay format-instance ToJSON POSIXTime where- toJSON pt=toJSON (round pt :: Integer)+instance ToJSON MpTime where+ toJSON (MpTime pt) = toJSON (round pt :: Integer) -- | Pagination info for searches@@ -399,8 +402,8 @@ instance ToHtQuery (Maybe Integer) where n ?+ d=n ?+ fmap show d -instance ToHtQuery (Maybe POSIXTime) where- n ?+ d=n ?+ fmap (show . (round :: POSIXTime -> Integer)) d+instance ToHtQuery (Maybe MpTime) where+ n ?+ d=n ?+ fmap (show . (round :: POSIXTime -> Integer) . unMpTime) d instance ToHtQuery (Maybe T.Text) where n ?+ d=(n,fmap TE.encodeUtf8 d)
src/Web/MangoPay/Users.hs view
@@ -11,7 +11,6 @@ import Data.Text import Data.Typeable (Typeable) import Data.Aeson-import Data.Time.Clock.POSIX (POSIXTime) import Control.Applicative @@ -91,12 +90,12 @@ -- <http://docs.mangopay.com/api-references/users/natural-users/> data NaturalUser=NaturalUser { uId :: Maybe NaturalUserId -- ^ The Id of the object- ,uCreationDate :: Maybe POSIXTime -- ^ The creation date of the user object+ ,uCreationDate :: Maybe MpTime -- ^ The creation date of the user object ,uEmail :: Text -- ^ User’s e-mail ,uFirstName :: Text -- ^ User’s firstname ,uLastName :: Text -- ^ User’s lastname ,uAddress :: Maybe Text -- ^ User’s address- ,uBirthday :: POSIXTime -- ^ User’s birthdate+ ,uBirthday :: MpTime -- ^ User’s birthdate ,uNationality :: CountryCode -- ^ User’s Nationality ,uCountryOfResidence:: CountryCode -- ^User’s country of residence ,uOccupation :: Maybe Text -- ^User’s occupation (ie. Work)@@ -154,7 +153,7 @@ -- <http://docs.mangopay.com/api-references/users/legal-users/> data LegalUser=LegalUser { lId :: Maybe Text -- ^ The Id of the object- ,lCreationDate :: Maybe POSIXTime -- ^ The creation date of the user object+ ,lCreationDate :: Maybe MpTime -- ^ The creation date of the user object ,lEmail :: Text -- ^ The email of the company or the organization ,lName :: Text -- ^ The name of the company or the organization ,lLegalPersonType :: LegalUserType -- ^ The type of the legal user (‘BUSINESS’ or ’ORGANIZATION’)@@ -163,7 +162,7 @@ ,lLegalRepresentativeLastName :: Text -- ^ The lastname of the company’s Legal representative person ,lLegalRepresentativeAddress :: Maybe Text -- ^ The address of the company’s Legal representative person ,lLegalRepresentativeEmail :: Maybe Text -- ^ The email of the company’s Legal representative person- ,lLegalRepresentativeBirthday :: POSIXTime -- ^ The birthdate of the company’s Legal representative person+ ,lLegalRepresentativeBirthday :: MpTime -- ^ The birthdate of the company’s Legal representative person ,lLegalRepresentativeNationality :: CountryCode -- ^ the nationality of the company’s Legal representative person ,lLegalRepresentativeCountryOfResidence :: CountryCode -- ^ The country of residence of the company’s Legal representative person ,lStatute :: Maybe Text -- ^ The business statute of the company@@ -219,7 +218,7 @@ -- | a short user reference data UserRef=UserRef { urId :: AnyUserId- , urCreationDate :: POSIXTime+ , urCreationDate :: MpTime , urPersonType :: PersonType , urEmail :: Text , urTag :: Maybe Text
src/Web/MangoPay/Wallets.hs view
@@ -4,7 +4,6 @@ -- | handle wallets module Web.MangoPay.Wallets where - import Web.MangoPay.Monad import Web.MangoPay.Types import Web.MangoPay.Users@@ -13,7 +12,6 @@ import Data.Text hiding (map,toLower) import Data.Typeable (Typeable) import Data.Aeson-import Data.Time.Clock.POSIX (POSIXTime) import Control.Applicative import qualified Data.HashMap.Lazy as HM (delete) import Data.Default (Default(..))@@ -62,7 +60,7 @@ -- | a wallet data Wallet = Wallet { wId :: Maybe WalletId -- ^ The Id of the wallet- ,wCreationDate :: Maybe POSIXTime -- ^ The creation date of the object+ ,wCreationDate :: Maybe MpTime -- ^ The creation date of the object ,wTag :: Maybe Text -- ^ Custom data ,wOwners :: [Text] -- ^ The owner of the wallet ,wDescription :: Text -- ^ A description of the wallet@@ -111,7 +109,7 @@ -- | transfer between wallets data Transfer = Transfer{ tId :: Maybe TransferId -- ^ Id of the transfer- ,tCreationDate :: Maybe POSIXTime -- ^ The creation date of the object+ ,tCreationDate :: Maybe MpTime -- ^ The creation date of the object ,tTag :: Maybe Text -- ^ Custom data ,tAuthorId :: AnyUserId -- ^ The Id of the author ,tCreditedUserId :: Maybe AnyUserId -- ^ The Id of the user owner of the credited wallet@@ -123,7 +121,7 @@ ,tStatus :: Maybe TransferStatus -- ^ The status of the transfer: ,tResultCode :: Maybe Text -- ^ The transaction result code ,tResultMessage :: Maybe Text -- ^ The transaction result message- ,tExecutionDate :: Maybe POSIXTime -- ^ The execution date of the transfer+ ,tExecutionDate :: Maybe MpTime -- ^ The execution date of the transfer } deriving (Show,Eq,Ord,Typeable) @@ -189,7 +187,7 @@ -- | any transaction data Transaction = Transaction{ txId :: Maybe TransactionId -- ^ Id of the transfer- ,txCreationDate :: Maybe POSIXTime -- ^ The creation date of the object+ ,txCreationDate :: Maybe MpTime -- ^ The creation date of the object ,txTag :: Maybe Text -- ^ Custom data ,txAuthorId :: AnyUserId -- ^ The Id of the author ,txCreditedUserId :: Maybe AnyUserId -- ^ The Id of the user owner of the credited wallet@@ -201,7 +199,7 @@ ,txStatus :: Maybe TransferStatus -- ^ The status of the transfer: ,txResultCode :: Maybe Text -- ^ The transaction result code ,txResultMessage :: Maybe Text -- ^ The transaction result message- ,txExecutionDate :: Maybe POSIXTime -- ^ The execution date of the transfer+ ,txExecutionDate :: Maybe MpTime -- ^ The execution date of the transfer ,txType :: TransactionType -- ^ The type of the transaction ,txNature :: TransactionNature -- ^ The nature of the transaction: }@@ -237,8 +235,8 @@ -- | A filter for transaction lists. data TransactionFilter = TransactionFilter- { tfBefore :: Maybe POSIXTime- , tfAfter :: Maybe POSIXTime+ { tfBefore :: Maybe MpTime+ , tfAfter :: Maybe MpTime , tfNature :: Maybe TransactionNature , tfStatus :: Maybe TransferStatus , tfType :: Maybe TransactionType@@ -268,4 +266,3 @@ transactionSortAttributes TxNoSort = [] transactionSortAttributes (TxByCreationDate dir)=["Sort" ?+ ("CreationDate:" ++ (map toLower $ show dir))] transactionSortAttributes (TxByExecutionDate dir)=["Sort" ?+ ("ExecutionDate:" ++ (map toLower $ show dir))]-
test/Web/MangoPay/UsersTest.hs view
@@ -13,7 +13,7 @@ import Data.Default testNaturalUser :: NaturalUser-testNaturalUser=NaturalUser Nothing Nothing "jpmoresmau@gmail.com" "JP" "Moresmau" Nothing 11111 FR FR+testNaturalUser=NaturalUser Nothing Nothing "jpmoresmau@gmail.com" "JP" "Moresmau" Nothing (MpTime 11111) FR FR (Just "Haskell contractor") (Just IncomeRange2) Nothing Nothing Nothing test_NaturalUser :: Assertion@@ -35,7 +35,7 @@ testLegalUser :: LegalUser testLegalUser = LegalUser Nothing Nothing "jpmoresmau@gmail.com" "JP Moresmau" Business Nothing- "JP" "Moresmau" (Just "my house") Nothing 222222 FR FR Nothing Nothing Nothing Nothing+ "JP" "Moresmau" (Just "my house") Nothing (MpTime 222222) FR FR Nothing Nothing Nothing Nothing test_LegalUser :: Assertion test_LegalUser = do