bitx-bitcoin 0.9.0.1 → 0.10.0.0
raw patch · 7 files changed
+34/−15 lines, 7 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Network.Bitcoin.BitX: aesToRec :: BitXAesRecordConvert recd => Aes recd -> recd
- Network.Bitcoin.BitX: class FromJSON (Aes recd) => BitXAesRecordConvert recd where type Aes recd where {
- Network.Bitcoin.BitX: type family Aes recd;
- Network.Bitcoin.BitX: }
+ Network.Bitcoin.BitX.Types: [newWithdrawalBeneficiaryId] :: NewWithdrawal -> Maybe Text
+ Network.Bitcoin.BitX.Types: beneficiaryId :: HasBeneficiaryId s a => Lens' s a
+ Network.Bitcoin.BitX.Types: class HasBeneficiaryId s a | s -> a
+ Network.Bitcoin.BitX.Types: instance Network.Bitcoin.BitX.Types.HasBeneficiaryId Network.Bitcoin.BitX.Types.NewWithdrawal (GHC.Base.Maybe Data.Text.Internal.Text)
- Network.Bitcoin.BitX.Types: NewWithdrawal :: WithdrawalType -> Scientific -> NewWithdrawal
+ Network.Bitcoin.BitX.Types: NewWithdrawal :: WithdrawalType -> Scientific -> Maybe Text -> NewWithdrawal
Files
- CHANGES +3/−0
- bitx-bitcoin.cabal +1/−1
- src/Network/Bitcoin/BitX/Internal.hs +2/−2
- src/Network/Bitcoin/BitX/Types.hs +5/−3
- src/Network/Bitcoin/BitX/Types/Internal.hs +8/−6
- test/Network/Bitcoin/BitX/Spec/Specs/LensSpec.hs +2/−1
- test/Network/Bitcoin/BitX/Spec/Specs/PostSpec.hs +13/−2
CHANGES view
@@ -1,3 +1,6 @@+v0.10.0.0+* New optional beneficiary ID field for withdrawal requests.+ v0.9.0.1 * Compatibility with http-client-0.5.0 and http-client-tls-0.3.0.
bitx-bitcoin.cabal view
@@ -1,5 +1,5 @@ name: bitx-bitcoin-version: 0.9.0.1+version: 0.10.0.0 synopsis: A Haskell library for working with the BitX bitcoin exchange. description:
src/Network/Bitcoin/BitX/Internal.hs view
@@ -50,8 +50,8 @@ globalManager = NetCon.newManager NetCon.tlsManagerSettings psUrl :: MonadThrow m => String -> m Request-#if MIN_VERSION_http_client(0,5,0)-psUrl = NetCon.parseRequest+#if MIN_VERSION_http_client(0,4,30)+psUrl = NetCon.parseUrlThrow #else psUrl = NetCon.parseUrl #endif
src/Network/Bitcoin/BitX/Types.hs view
@@ -126,7 +126,8 @@ HasExercised(..), HasName(..), HasIsBuy(..),- HasStatus(..)+ HasStatus(..),+ HasBeneficiaryId(..) ) where import Data.Aeson (FromJSON(..))@@ -389,13 +390,14 @@ -- | A request to withdraw from an account. data NewWithdrawal = NewWithdrawal {newWithdrawalWithdrawalType :: WithdrawalType,- newWithdrawalAmount :: Scientific } deriving (Eq, Show)+ newWithdrawalAmount :: Scientific,+ newWithdrawalBeneficiaryId :: Maybe Text} deriving (Eq, Show) makeFields ''NewWithdrawal -- |@mkNewWithdrawal = NewWithdrawal ZAR_EFT 0@ mkNewWithdrawal :: NewWithdrawal-mkNewWithdrawal = NewWithdrawal ZAR_EFT 0+mkNewWithdrawal = NewWithdrawal ZAR_EFT 0 Nothing -- | A request to send bitcoin to a bitcoin address or email address. data BitcoinSendRequest = BitcoinSendRequest
src/Network/Bitcoin/BitX/Types/Internal.hs view
@@ -60,6 +60,10 @@ -- prop> \ n -> (timeToTimestamp $ timestampParse_ $ _unUnixStampMS n) == _unUnixStampMS n -- +ifJustText :: ByteString -> Maybe Text -> [(ByteString, ByteString)]+ifJustText lbl (Just a) = [(lbl, Txt.encodeUtf8 a)]+ifJustText _ Nothing = []+ class FromJSON (Aes recd) => BitXAesRecordConvert recd where type Aes recd aesToRec :: Aes recd -> recd@@ -499,6 +503,7 @@ postEncode nwthd = [("type", showableToBytestring_ (nwthd ^. Types.withdrawalType)), ("amount", realToDecimalByteString_ (nwthd ^. Types.amount))]+ ++ ifJustText "beneficiary_id" (nwthd ^. Types.beneficiaryId) -------------------------------------- BitcoinSendRequest type ------------------------------------- @@ -506,12 +511,9 @@ postEncode oreq = [("amount", realToDecimalByteString_ (oreq ^. Types.amount)), ("currency", showableToBytestring_ (oreq ^. Types.currency)),- ("address", Txt.encodeUtf8 (oreq ^. Types.address)),- ("description", Txt.encodeUtf8 . unjustText $ (oreq ^. Types.description)),- ("message", Txt.encodeUtf8 . unjustText $ (oreq ^. Types.message))]- where- unjustText (Just a) = a- unjustText Nothing = ""+ ("address", Txt.encodeUtf8 (oreq ^. Types.address))]+ ++ ifJustText "description" (oreq ^. Types.description)+ ++ ifJustText "message" (oreq ^. Types.message) ----------------------------------------- QuoteRequest type ----------------------------------------
test/Network/Bitcoin/BitX/Spec/Specs/LensSpec.hs view
@@ -141,9 +141,10 @@ _newWithdrawal :: Maybe Int _newWithdrawal = do- let x = BitX.NewWithdrawal ZAR_EFT 0+ let x = BitX.NewWithdrawal ZAR_EFT 0 Nothing let _ = x ^. BitX.withdrawalType let _ = x ^. BitX.amount+ let _ = x ^. BitX.beneficiaryId Nothing _bitcoinSendRequest :: Maybe Int
test/Network/Bitcoin/BitX/Spec/Specs/PostSpec.hs view
@@ -27,11 +27,22 @@ postEncode ZAR `shouldBe` [("asset", "ZAR")]- it "NewWithdrawal is post-encoded properly" $+ it "NewWithdrawal is post-encoded properly with beneficiary" $ postEncode NewWithdrawal {newWithdrawalWithdrawalType = ZAR_EFT,- newWithdrawalAmount = 83.02}+ newWithdrawalAmount = 83.02,+ newWithdrawalBeneficiaryId = Just "Some guy"}+ `shouldBe`+ [("type", "ZAR_EFT"),+ ("amount", "83.02"),+ ("beneficiary_id","Some guy")]+ it "NewWithdrawal is post-encoded properly with no beneficiary" $+ postEncode+ NewWithdrawal+ {newWithdrawalWithdrawalType = ZAR_EFT,+ newWithdrawalAmount = 83.02,+ newWithdrawalBeneficiaryId = Nothing} `shouldBe` [("type", "ZAR_EFT"), ("amount", "83.02")]