packages feed

mangopay 1.4 → 1.5

raw patch · 8 files changed

+30/−17 lines, 8 filesdep +country-codes

Dependencies added: country-codes

Files

mangopay.cabal view
@@ -1,5 +1,5 @@ name:           mangopay-version:        1.4+version:        1.5 cabal-version:  >= 1.8 build-type:     Simple author:         JP Moresmau <jpmoresmau@gmail.com>@@ -50,9 +50,11 @@      , utf8-string          >= 0.3.7      , base64-bytestring    >= 1.0      , case-insensitive     >= 1.1-     , monad-logger                  >= 0.3        && < 0.4-     , vector >=0.10.9 && <0.11+     , monad-logger         >= 0.3        && < 0.4+     , vector               >=0.10.9 && <0.11      , template-haskell+     , country-codes        == 0.1.*+   if flag(conduit11)     build-depends:          conduit              == 1.1.*@@ -102,7 +104,7 @@      data-default, http-conduit, http-types, lifted-base,      monad-control, monad-logger, resourcet, template-haskell,      text, time, transformers, transformers-base,-     unordered-containers, utf8-string, vector+     unordered-containers, utf8-string, vector, country-codes       , blaze-builder      , HTF            >  0.9
src/Web/MangoPay/Accounts.hs view
@@ -14,6 +14,8 @@ import Control.Applicative import qualified Network.HTTP.Types as HT +import Data.CountryCodes (CountryCode)+ -- | create an account storeAccount ::  (MPUsableMonad m) => BankAccount -> AccessToken -> MangoPayT m BankAccount storeAccount ba at@@ -54,7 +56,7 @@   } | Other {   atAccountNumber :: Text   ,atBIC :: Text-  ,atCountry :: Text+  ,atCountry :: CountryCode   } deriving (Show,Read,Eq,Ord,Typeable)    -- | from json as per MangoPay format 
src/Web/MangoPay/Cards.hs view
@@ -65,7 +65,7 @@  -- | to json as per MangoPay format         instance ToJSON CardRegistration where-        toJSON cr=object ["Id".= crId cr -- ^ we store the ID, because in the registration workflow we may need to hang on to the registration object for a while, so let's use JSON serialization to keep it!+        toJSON cr=object ["Id".= crId cr -- we store the ID, because in the registration workflow we may need to hang on to the registration object for a while, so let's use JSON serialization to keep it!           , "Tag" .= crTag cr,"UserId" .= crUserId cr           ,"Currency" .= crCurrency cr,"RegistrationData" .= crRegistrationData cr           ,"CardRegistrationURL" .= crCardRegistrationURL cr]
src/Web/MangoPay/Refunds.hs view
@@ -41,7 +41,7 @@   ,rrFees :: Maybe Amount -- ^ In cents   }deriving (Show,Eq,Ord,Typeable) - -- | to json as per MangoPay format+-- | to json as per MangoPay format instance ToJSON RefundRequest  where     toJSON rr=object ["AuthorId" .= rrAuthorId rr,"DebitedFunds" .= rrDebitedFunds rr,       "Fees" .= rrFees rr] @@ -72,7 +72,7 @@   ,rCreditedWalletID  :: Maybe WalletID -- ^ The Id of the credited Wallet   } deriving (Show,Eq,Ord,Typeable)   - -- | from json as per MangoPay format +-- | from json as per MangoPay format  instance FromJSON Refund where         parseJSON (Object v) =Refund <$>                          v .: "Id" <*>
src/Web/MangoPay/Types.hs view
@@ -31,6 +31,7 @@ import Text.Printf (printf) import qualified Data.ByteString.Lazy as BS (toStrict) + -- | the MangoPay access point data AccessPoint = Sandbox | Production | Custom ByteString         deriving (Show,Read,Eq,Ord,Typeable)@@ -127,6 +128,7 @@                          v .: "Date"     parseJSON _= fail "MpError" +-- | from json as per MangoPay format instance FromJSON POSIXTime where     parseJSON n@(Number _)=(fromIntegral . (round::Double -> Integer)) <$> parseJSON n     parseJSON _ = fail "POSIXTime"@@ -135,6 +137,7 @@ instance ToJSON POSIXTime  where     toJSON pt=toJSON (round pt :: Integer) + -- | Pagination info for searches -- <http://docs.mangopay.com/api-references/pagination/> data Pagination = Pagination {@@ -151,6 +154,7 @@ paginationAttributes (Just p)=["page" ?+ pPage p, "per_page" ?+ pPerPage p] paginationAttributes _=[] +-- | A partial list with pagination information. data PagedList a= PagedList {   plData :: [a]   ,plItemCount :: Integer
src/Web/MangoPay/Users.hs view
@@ -5,6 +5,7 @@ import Web.MangoPay.Monad import Web.MangoPay.Types +import Data.CountryCodes (CountryCode) import Data.Text import Data.Typeable (Typeable) import Data.Aeson@@ -12,6 +13,7 @@ import Control.Applicative import qualified Network.HTTP.Types as HT + -- | create or edit a natural user storeNaturalUser ::  (MPUsableMonad m) => NaturalUser -> AccessToken -> MangoPayT m NaturalUser storeNaturalUser u at= @@ -127,8 +129,8 @@         ,uLastName :: Text -- ^  User’s lastname         ,uAddress :: Maybe Text -- ^  User’s address         ,uBirthday :: POSIXTime -- ^   User’s birthdate-        ,uNationality :: Text -- ^ User’s Nationality-        ,uCountryOfResidence:: Text -- ^User’s country of residence+        ,uNationality :: CountryCode -- ^ User’s Nationality+        ,uCountryOfResidence:: CountryCode -- ^User’s country of residence         ,uOccupation :: Maybe Text -- ^User’s occupation (ie. Work)         ,uIncomeRange :: Maybe IncomeRange -- ^ User’s income range         ,uTag :: Maybe Text -- ^  Custom data@@ -194,8 +196,8 @@         ,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-        ,lLegalRepresentativeNationality :: Text -- ^ the nationality of the company’s Legal representative person-        ,lLegalRepresentativeCountryOfResidence :: Text -- ^  The country of residence 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         ,lTag   :: Maybe Text -- ^  Custom data         ,lProofOfRegistration :: Maybe Text -- ^   The proof of registration of the company@@ -230,7 +232,8 @@                          v .:? "ProofOfRegistration" <*>                          v .:? "ShareholderDeclaration"      parseJSON _= fail "NaturalUser" -     +    +-- | Type of user.  data PersonType =  Natural | Legal         deriving (Show,Read,Eq,Ord,Bounded,Enum,Typeable)      
src/Web/MangoPay/Wallets.hs view
@@ -164,7 +164,7 @@         "Fees" .= tFees t,"DebitedWalletID" .= tDebitedWalletID t,"CreditedWalletID" .= tCreditedWalletID t,         "Tag" .= tTag t]     - -- | from json as per MangoPay format +-- | from json as per MangoPay format  instance FromJSON Transfer where         parseJSON (Object v) =Transfer <$>                          v .: "Id" <*>@@ -244,7 +244,7 @@         "Fees" .= txFees t,"DebitedWalletID" .= txDebitedWalletID t,"CreditedWalletID" .= txCreditedWalletID t,         "Tag" .= txTag t,"Type" .= txType t,"Nature" .= txNature t]     - -- | from json as per MangoPay format +-- | from json as per MangoPay format  instance FromJSON Transaction where         parseJSON (Object v) =Transaction <$>                          v .: "Id" <*>
test/Web/MangoPay/UsersTest.hs view
@@ -9,8 +9,10 @@ import Test.HUnit (Assertion) import Data.Maybe (fromJust, isJust) +import Data.CountryCodes (CountryCode(FR))+ 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 11111 FR FR          (Just "Haskell contractor") (Just IncomeRange2) Nothing Nothing Nothing   test_NaturalUser :: Assertion@@ -31,7 +33,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 222222 FR FR Nothing Nothing Nothing Nothing          test_LegalUser :: Assertion test_LegalUser = do