{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE OverloadedStrings          #-}
{-# LANGUAGE TemplateHaskell            #-}

module CoinbasePro.Authenticated.Deposit
    ( DepositDetails (..)
    , DepositRequest (..)
    , DepositResponse (..)
    , CoinbaseDepositRequest (..)
    , CryptoDepositAddress (..)
    ) where

import           Data.Aeson.Casing                  (snakeCase)
import           Data.Aeson.TH                      (defaultOptions, deriveJSON,
                                                     fieldLabelModifier)
import           Data.Text                          (Text)
import           Data.Time.Clock                    (UTCTime)
import           Data.UUID                          (UUID)

import           CoinbasePro.Authenticated.Accounts (AccountId)
import           CoinbasePro.Authenticated.Payment  (PaymentMethodId (..))
import           CoinbasePro.Types                  (CreatedAt)


data DepositDetails = DepositDetails
    { DepositDetails -> Maybe Text
cryptoAddress         :: Maybe Text
    , DepositDetails -> Maybe Text
destinationTag        :: Maybe Text
    , DepositDetails -> AccountId
coinbaseAccountId     :: AccountId
    , DepositDetails -> Maybe Text
destinationTagName    :: Maybe Text
    , DepositDetails -> Text
coinbaseTransactionId :: Text
    , DepositDetails -> Maybe Text
cryptoTransactionHash :: Maybe Text
    } deriving (DepositDetails -> DepositDetails -> Bool
(DepositDetails -> DepositDetails -> Bool)
-> (DepositDetails -> DepositDetails -> Bool) -> Eq DepositDetails
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DepositDetails -> DepositDetails -> Bool
$c/= :: DepositDetails -> DepositDetails -> Bool
== :: DepositDetails -> DepositDetails -> Bool
$c== :: DepositDetails -> DepositDetails -> Bool
Eq, Int -> DepositDetails -> ShowS
[DepositDetails] -> ShowS
DepositDetails -> String
(Int -> DepositDetails -> ShowS)
-> (DepositDetails -> String)
-> ([DepositDetails] -> ShowS)
-> Show DepositDetails
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DepositDetails] -> ShowS
$cshowList :: [DepositDetails] -> ShowS
show :: DepositDetails -> String
$cshow :: DepositDetails -> String
showsPrec :: Int -> DepositDetails -> ShowS
$cshowsPrec :: Int -> DepositDetails -> ShowS
Show)


deriveJSON defaultOptions { fieldLabelModifier = snakeCase } ''DepositDetails


data DepositRequest = DepositRequest
    { DepositRequest -> Double
amount          :: Double
    , DepositRequest -> Text
currency        :: Text
    , DepositRequest -> PaymentMethodId
paymentMethodId :: PaymentMethodId
    } deriving (DepositRequest -> DepositRequest -> Bool
(DepositRequest -> DepositRequest -> Bool)
-> (DepositRequest -> DepositRequest -> Bool) -> Eq DepositRequest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DepositRequest -> DepositRequest -> Bool
$c/= :: DepositRequest -> DepositRequest -> Bool
== :: DepositRequest -> DepositRequest -> Bool
$c== :: DepositRequest -> DepositRequest -> Bool
Eq, Int -> DepositRequest -> ShowS
[DepositRequest] -> ShowS
DepositRequest -> String
(Int -> DepositRequest -> ShowS)
-> (DepositRequest -> String)
-> ([DepositRequest] -> ShowS)
-> Show DepositRequest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DepositRequest] -> ShowS
$cshowList :: [DepositRequest] -> ShowS
show :: DepositRequest -> String
$cshow :: DepositRequest -> String
showsPrec :: Int -> DepositRequest -> ShowS
$cshowsPrec :: Int -> DepositRequest -> ShowS
Show)


deriveJSON defaultOptions { fieldLabelModifier = snakeCase } ''DepositRequest


data CoinbaseDepositRequest = CoinbaseDepositRequest
    { CoinbaseDepositRequest -> Double
cAmount            :: Double
    , CoinbaseDepositRequest -> Text
cCurrency          :: Text
    , CoinbaseDepositRequest -> AccountId
cCoinbaseAccountId :: AccountId
    } deriving (CoinbaseDepositRequest -> CoinbaseDepositRequest -> Bool
(CoinbaseDepositRequest -> CoinbaseDepositRequest -> Bool)
-> (CoinbaseDepositRequest -> CoinbaseDepositRequest -> Bool)
-> Eq CoinbaseDepositRequest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CoinbaseDepositRequest -> CoinbaseDepositRequest -> Bool
$c/= :: CoinbaseDepositRequest -> CoinbaseDepositRequest -> Bool
== :: CoinbaseDepositRequest -> CoinbaseDepositRequest -> Bool
$c== :: CoinbaseDepositRequest -> CoinbaseDepositRequest -> Bool
Eq, Int -> CoinbaseDepositRequest -> ShowS
[CoinbaseDepositRequest] -> ShowS
CoinbaseDepositRequest -> String
(Int -> CoinbaseDepositRequest -> ShowS)
-> (CoinbaseDepositRequest -> String)
-> ([CoinbaseDepositRequest] -> ShowS)
-> Show CoinbaseDepositRequest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CoinbaseDepositRequest] -> ShowS
$cshowList :: [CoinbaseDepositRequest] -> ShowS
show :: CoinbaseDepositRequest -> String
$cshow :: CoinbaseDepositRequest -> String
showsPrec :: Int -> CoinbaseDepositRequest -> ShowS
$cshowsPrec :: Int -> CoinbaseDepositRequest -> ShowS
Show)


deriveJSON defaultOptions { fieldLabelModifier = snakeCase . drop 1 } ''CoinbaseDepositRequest


data DepositResponse = DepositResponse
    { DepositResponse -> UUID
rId       :: UUID
    , DepositResponse -> Double
rAmount   :: Double
    , DepositResponse -> Text
rCurrency :: Text
    , DepositResponse -> UTCTime
rPayoutAt :: UTCTime
    } deriving (DepositResponse -> DepositResponse -> Bool
(DepositResponse -> DepositResponse -> Bool)
-> (DepositResponse -> DepositResponse -> Bool)
-> Eq DepositResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DepositResponse -> DepositResponse -> Bool
$c/= :: DepositResponse -> DepositResponse -> Bool
== :: DepositResponse -> DepositResponse -> Bool
$c== :: DepositResponse -> DepositResponse -> Bool
Eq, Int -> DepositResponse -> ShowS
[DepositResponse] -> ShowS
DepositResponse -> String
(Int -> DepositResponse -> ShowS)
-> (DepositResponse -> String)
-> ([DepositResponse] -> ShowS)
-> Show DepositResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DepositResponse] -> ShowS
$cshowList :: [DepositResponse] -> ShowS
show :: DepositResponse -> String
$cshow :: DepositResponse -> String
showsPrec :: Int -> DepositResponse -> ShowS
$cshowsPrec :: Int -> DepositResponse -> ShowS
Show)


deriveJSON defaultOptions { fieldLabelModifier = snakeCase . drop 1 } ''DepositResponse


data AddressInfo = AddressInfo
    { AddressInfo -> Text
aiAddress        :: Text
    , AddressInfo -> Maybe Int
aiDestinationTag :: Maybe Int
    } deriving Int -> AddressInfo -> ShowS
[AddressInfo] -> ShowS
AddressInfo -> String
(Int -> AddressInfo -> ShowS)
-> (AddressInfo -> String)
-> ([AddressInfo] -> ShowS)
-> Show AddressInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AddressInfo] -> ShowS
$cshowList :: [AddressInfo] -> ShowS
show :: AddressInfo -> String
$cshow :: AddressInfo -> String
showsPrec :: Int -> AddressInfo -> ShowS
$cshowsPrec :: Int -> AddressInfo -> ShowS
Show


deriveJSON defaultOptions { fieldLabelModifier = snakeCase . drop 2 } ''AddressInfo


data CryptoDepositAddress = CryptoDepositAddress
    { CryptoDepositAddress -> UUID
cdaId                     :: UUID
    , CryptoDepositAddress -> Text
cdaAddress                :: Text
    , CryptoDepositAddress -> Maybe Int
cdaDestinationTag         :: Maybe Int
    , CryptoDepositAddress -> AddressInfo
cdaAddressInfo            :: AddressInfo
    , CryptoDepositAddress -> CreatedAt
cdaCreatedAt              :: CreatedAt
    , CryptoDepositAddress -> UTCTime
cdaUpdatedAt              :: UTCTime
    , CryptoDepositAddress -> Text
cdaNetwork                :: Text
    , CryptoDepositAddress -> Text
cdaResource               :: Text
    , CryptoDepositAddress -> Text
cdaDepositUri             :: Text
    , CryptoDepositAddress -> Bool
cdaExchangeDepositAddress :: Bool
    } deriving Int -> CryptoDepositAddress -> ShowS
[CryptoDepositAddress] -> ShowS
CryptoDepositAddress -> String
(Int -> CryptoDepositAddress -> ShowS)
-> (CryptoDepositAddress -> String)
-> ([CryptoDepositAddress] -> ShowS)
-> Show CryptoDepositAddress
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CryptoDepositAddress] -> ShowS
$cshowList :: [CryptoDepositAddress] -> ShowS
show :: CryptoDepositAddress -> String
$cshow :: CryptoDepositAddress -> String
showsPrec :: Int -> CryptoDepositAddress -> ShowS
$cshowsPrec :: Int -> CryptoDepositAddress -> ShowS
Show


deriveJSON defaultOptions { fieldLabelModifier = snakeCase . drop 3 } ''CryptoDepositAddress