-- | Asset queries

module Blockfrost.Client.Cardano.Assets
  ( getAssets
  , getAssets'
  , getAssetDetails
  , getAssetHistory
  , getAssetHistory'
  , getAssetTransactions
  , getAssetTransactions'
  , getAssetAddresses
  , getAssetAddresses'
  , getAssetsByPolicy
  , getAssetsByPolicy'
  ) where

import Blockfrost.API
import Blockfrost.Client.Types
import Blockfrost.Types

assetsClient :: MonadBlockfrost m => Project -> AssetsAPI (AsClientT m)
assetsClient :: Project -> AssetsAPI (AsClientT m)
assetsClient = (((Paged -> SortOrder -> m [AssetInfo])
  :<|> ((AssetId -> m AssetDetails)
        :<|> (AssetId -> Paged -> SortOrder -> m [AssetHistory])))
 :<|> ((AssetId -> Paged -> SortOrder -> m [AssetTransaction])
       :<|> ((AssetId -> Paged -> SortOrder -> m [AssetAddress])
             :<|> (PolicyId -> Paged -> SortOrder -> m [AssetInfo]))))
-> AssetsAPI (AsClientT m)
forall (routes :: * -> *) mode.
GenericServant routes mode =>
ToServant routes mode -> routes mode
fromServant ((((Paged -> SortOrder -> m [AssetInfo])
   :<|> ((AssetId -> m AssetDetails)
         :<|> (AssetId -> Paged -> SortOrder -> m [AssetHistory])))
  :<|> ((AssetId -> Paged -> SortOrder -> m [AssetTransaction])
        :<|> ((AssetId -> Paged -> SortOrder -> m [AssetAddress])
              :<|> (PolicyId -> Paged -> SortOrder -> m [AssetInfo]))))
 -> AssetsAPI (AsClientT m))
-> (Project
    -> ((Paged -> SortOrder -> m [AssetInfo])
        :<|> ((AssetId -> m AssetDetails)
              :<|> (AssetId -> Paged -> SortOrder -> m [AssetHistory])))
       :<|> ((AssetId -> Paged -> SortOrder -> m [AssetTransaction])
             :<|> ((AssetId -> Paged -> SortOrder -> m [AssetAddress])
                   :<|> (PolicyId -> Paged -> SortOrder -> m [AssetInfo]))))
-> Project
-> AssetsAPI (AsClientT m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CardanoAPI (AsClientT m)
-> ((Paged -> SortOrder -> m [AssetInfo])
    :<|> ((AssetId -> m AssetDetails)
          :<|> (AssetId -> Paged -> SortOrder -> m [AssetHistory])))
   :<|> ((AssetId -> Paged -> SortOrder -> m [AssetTransaction])
         :<|> ((AssetId -> Paged -> SortOrder -> m [AssetAddress])
               :<|> (PolicyId -> Paged -> SortOrder -> m [AssetInfo])))
forall route.
CardanoAPI route
-> route
   :- ("assets"
       :> (Tag "Cardano \187 Assets" :> ToServantApi AssetsAPI))
_assets (CardanoAPI (AsClientT m)
 -> ((Paged -> SortOrder -> m [AssetInfo])
     :<|> ((AssetId -> m AssetDetails)
           :<|> (AssetId -> Paged -> SortOrder -> m [AssetHistory])))
    :<|> ((AssetId -> Paged -> SortOrder -> m [AssetTransaction])
          :<|> ((AssetId -> Paged -> SortOrder -> m [AssetAddress])
                :<|> (PolicyId -> Paged -> SortOrder -> m [AssetInfo]))))
-> (Project -> CardanoAPI (AsClientT m))
-> Project
-> ((Paged -> SortOrder -> m [AssetInfo])
    :<|> ((AssetId -> m AssetDetails)
          :<|> (AssetId -> Paged -> SortOrder -> m [AssetHistory])))
   :<|> ((AssetId -> Paged -> SortOrder -> m [AssetTransaction])
         :<|> ((AssetId -> Paged -> SortOrder -> m [AssetAddress])
               :<|> (PolicyId -> Paged -> SortOrder -> m [AssetInfo])))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Project -> CardanoAPI (AsClientT m)
forall (m :: * -> *).
MonadBlockfrost m =>
Project -> CardanoAPI (AsClientT m)
cardanoClient

getAssets_ :: MonadBlockfrost m => Project -> Paged -> SortOrder -> m [AssetInfo]
getAssets_ :: Project -> Paged -> SortOrder -> m [AssetInfo]
getAssets_ = AssetsAPI (AsClientT m) -> Paged -> SortOrder -> m [AssetInfo]
forall route.
AssetsAPI route
-> route
   :- (Summary "Assets"
       :> (Description "List of assets."
           :> (Pagination :> (Sorting :> Get '[JSON] [AssetInfo]))))
_listAssets (AssetsAPI (AsClientT m) -> Paged -> SortOrder -> m [AssetInfo])
-> (Project -> AssetsAPI (AsClientT m))
-> Project
-> Paged
-> SortOrder
-> m [AssetInfo]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Project -> AssetsAPI (AsClientT m)
forall (m :: * -> *).
MonadBlockfrost m =>
Project -> AssetsAPI (AsClientT m)
assetsClient

-- | List all assets
-- Allows custom paging and ordering using @Paged@ and @SortOrder@.
getAssets' :: MonadBlockfrost m => Paged -> SortOrder -> m [AssetInfo]
getAssets' :: Paged -> SortOrder -> m [AssetInfo]
getAssets' Paged
pg SortOrder
s = (Project -> m [AssetInfo]) -> m [AssetInfo]
forall (m :: * -> *) a.
MonadBlockfrost m =>
(Project -> m a) -> m a
go (\Project
p -> Project -> Paged -> SortOrder -> m [AssetInfo]
forall (m :: * -> *).
MonadBlockfrost m =>
Project -> Paged -> SortOrder -> m [AssetInfo]
getAssets_ Project
p Paged
pg SortOrder
s)

-- | List all assets
getAssets :: MonadBlockfrost m => m [AssetInfo]
getAssets :: m [AssetInfo]
getAssets = Paged -> SortOrder -> m [AssetInfo]
forall (m :: * -> *).
MonadBlockfrost m =>
Paged -> SortOrder -> m [AssetInfo]
getAssets' Paged
forall a. Default a => a
def SortOrder
forall a. Default a => a
def

getAssetDetails_ :: MonadBlockfrost m => Project -> AssetId -> m AssetDetails
getAssetDetails_ :: Project -> AssetId -> m AssetDetails
getAssetDetails_ = AssetsAPI (AsClientT m) -> AssetId -> m AssetDetails
forall route.
AssetsAPI route
-> route
   :- (Summary "Specific asset"
       :> (Description "Information about a specific asset."
           :> (Capture "asset" AssetId :> Get '[JSON] AssetDetails)))
_assetDetails (AssetsAPI (AsClientT m) -> AssetId -> m AssetDetails)
-> (Project -> AssetsAPI (AsClientT m))
-> Project
-> AssetId
-> m AssetDetails
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Project -> AssetsAPI (AsClientT m)
forall (m :: * -> *).
MonadBlockfrost m =>
Project -> AssetsAPI (AsClientT m)
assetsClient

-- | Information about a specific asset
getAssetDetails :: MonadBlockfrost m => AssetId -> m AssetDetails
getAssetDetails :: AssetId -> m AssetDetails
getAssetDetails AssetId
a = (Project -> m AssetDetails) -> m AssetDetails
forall (m :: * -> *) a.
MonadBlockfrost m =>
(Project -> m a) -> m a
go (Project -> AssetId -> m AssetDetails
forall (m :: * -> *).
MonadBlockfrost m =>
Project -> AssetId -> m AssetDetails
`getAssetDetails_` AssetId
a)

getAssetHistory_ :: MonadBlockfrost m => Project -> AssetId -> Paged -> SortOrder -> m [AssetHistory]
getAssetHistory_ :: Project -> AssetId -> Paged -> SortOrder -> m [AssetHistory]
getAssetHistory_ = AssetsAPI (AsClientT m)
-> AssetId -> Paged -> SortOrder -> m [AssetHistory]
forall route.
AssetsAPI route
-> route
   :- (Summary "Asset history"
       :> (Description "History of a specific asset."
           :> (Capture "asset" AssetId
               :> ("history"
                   :> (Pagination :> (Sorting :> Get '[JSON] [AssetHistory]))))))
_assetHistory (AssetsAPI (AsClientT m)
 -> AssetId -> Paged -> SortOrder -> m [AssetHistory])
-> (Project -> AssetsAPI (AsClientT m))
-> Project
-> AssetId
-> Paged
-> SortOrder
-> m [AssetHistory]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Project -> AssetsAPI (AsClientT m)
forall (m :: * -> *).
MonadBlockfrost m =>
Project -> AssetsAPI (AsClientT m)
assetsClient

-- | History of a specific asset
-- Allows custom paging and ordering using @Paged@ and @SortOrder@.
getAssetHistory' :: MonadBlockfrost m => AssetId -> Paged -> SortOrder -> m [AssetHistory]
getAssetHistory' :: AssetId -> Paged -> SortOrder -> m [AssetHistory]
getAssetHistory' AssetId
a Paged
pg SortOrder
s = (Project -> m [AssetHistory]) -> m [AssetHistory]
forall (m :: * -> *) a.
MonadBlockfrost m =>
(Project -> m a) -> m a
go (\Project
p -> Project -> AssetId -> Paged -> SortOrder -> m [AssetHistory]
forall (m :: * -> *).
MonadBlockfrost m =>
Project -> AssetId -> Paged -> SortOrder -> m [AssetHistory]
getAssetHistory_ Project
p AssetId
a Paged
pg SortOrder
s)

-- | History of a specific asset
getAssetHistory :: MonadBlockfrost m => AssetId -> m [AssetHistory]
getAssetHistory :: AssetId -> m [AssetHistory]
getAssetHistory AssetId
a = AssetId -> Paged -> SortOrder -> m [AssetHistory]
forall (m :: * -> *).
MonadBlockfrost m =>
AssetId -> Paged -> SortOrder -> m [AssetHistory]
getAssetHistory' AssetId
a Paged
forall a. Default a => a
def SortOrder
forall a. Default a => a
def

getAssetTransactions_ :: MonadBlockfrost m => Project -> AssetId -> Paged -> SortOrder -> m [AssetTransaction]
getAssetTransactions_ :: Project -> AssetId -> Paged -> SortOrder -> m [AssetTransaction]
getAssetTransactions_ = AssetsAPI (AsClientT m)
-> AssetId -> Paged -> SortOrder -> m [AssetTransaction]
forall route.
AssetsAPI route
-> route
   :- (Summary "Asset transactions"
       :> (Description "List of a specific asset transactions"
           :> (Capture "asset" AssetId
               :> ("transactions"
                   :> (Pagination :> (Sorting :> Get '[JSON] [AssetTransaction]))))))
_assetTransactions (AssetsAPI (AsClientT m)
 -> AssetId -> Paged -> SortOrder -> m [AssetTransaction])
-> (Project -> AssetsAPI (AsClientT m))
-> Project
-> AssetId
-> Paged
-> SortOrder
-> m [AssetTransaction]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Project -> AssetsAPI (AsClientT m)
forall (m :: * -> *).
MonadBlockfrost m =>
Project -> AssetsAPI (AsClientT m)
assetsClient

-- | List of a specific asset transactions
-- Allows custom paging and ordering using @Paged@ and @SortOrder@.
getAssetTransactions' :: MonadBlockfrost m => AssetId -> Paged -> SortOrder -> m [AssetTransaction]
getAssetTransactions' :: AssetId -> Paged -> SortOrder -> m [AssetTransaction]
getAssetTransactions' AssetId
a Paged
pg SortOrder
s = (Project -> m [AssetTransaction]) -> m [AssetTransaction]
forall (m :: * -> *) a.
MonadBlockfrost m =>
(Project -> m a) -> m a
go (\Project
p -> Project -> AssetId -> Paged -> SortOrder -> m [AssetTransaction]
forall (m :: * -> *).
MonadBlockfrost m =>
Project -> AssetId -> Paged -> SortOrder -> m [AssetTransaction]
getAssetTransactions_ Project
p AssetId
a Paged
pg SortOrder
s)

-- | List of a specific asset transactions
getAssetTransactions :: MonadBlockfrost m => AssetId -> m [AssetTransaction]
getAssetTransactions :: AssetId -> m [AssetTransaction]
getAssetTransactions AssetId
a = AssetId -> Paged -> SortOrder -> m [AssetTransaction]
forall (m :: * -> *).
MonadBlockfrost m =>
AssetId -> Paged -> SortOrder -> m [AssetTransaction]
getAssetTransactions' AssetId
a Paged
forall a. Default a => a
def SortOrder
forall a. Default a => a
def

getAssetAddresses_ :: MonadBlockfrost m => Project -> AssetId -> Paged -> SortOrder -> m [AssetAddress]
getAssetAddresses_ :: Project -> AssetId -> Paged -> SortOrder -> m [AssetAddress]
getAssetAddresses_ = AssetsAPI (AsClientT m)
-> AssetId -> Paged -> SortOrder -> m [AssetAddress]
forall route.
AssetsAPI route
-> route
   :- (Summary "Asset addresses"
       :> (Description "List of a addresses containing a specific asset"
           :> (Capture "asset" AssetId
               :> ("addresses"
                   :> (Pagination :> (Sorting :> Get '[JSON] [AssetAddress]))))))
_assetAddresses (AssetsAPI (AsClientT m)
 -> AssetId -> Paged -> SortOrder -> m [AssetAddress])
-> (Project -> AssetsAPI (AsClientT m))
-> Project
-> AssetId
-> Paged
-> SortOrder
-> m [AssetAddress]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Project -> AssetsAPI (AsClientT m)
forall (m :: * -> *).
MonadBlockfrost m =>
Project -> AssetsAPI (AsClientT m)
assetsClient

-- | List of a addresses containing a specific asset
-- Allows custom paging and ordering using @Paged@ and @SortOrder@.
getAssetAddresses' :: MonadBlockfrost m => AssetId -> Paged -> SortOrder -> m [AssetAddress]
getAssetAddresses' :: AssetId -> Paged -> SortOrder -> m [AssetAddress]
getAssetAddresses' AssetId
a Paged
pg SortOrder
s = (Project -> m [AssetAddress]) -> m [AssetAddress]
forall (m :: * -> *) a.
MonadBlockfrost m =>
(Project -> m a) -> m a
go (\Project
p -> Project -> AssetId -> Paged -> SortOrder -> m [AssetAddress]
forall (m :: * -> *).
MonadBlockfrost m =>
Project -> AssetId -> Paged -> SortOrder -> m [AssetAddress]
getAssetAddresses_ Project
p AssetId
a Paged
pg SortOrder
s)

-- | List of a addresses containing a specific asset
getAssetAddresses :: MonadBlockfrost m => AssetId -> m [AssetAddress]
getAssetAddresses :: AssetId -> m [AssetAddress]
getAssetAddresses AssetId
a = AssetId -> Paged -> SortOrder -> m [AssetAddress]
forall (m :: * -> *).
MonadBlockfrost m =>
AssetId -> Paged -> SortOrder -> m [AssetAddress]
getAssetAddresses' AssetId
a Paged
forall a. Default a => a
def SortOrder
forall a. Default a => a
def

getAssetsByPolicy_ :: MonadBlockfrost m => Project -> PolicyId -> Paged -> SortOrder -> m [AssetInfo]
getAssetsByPolicy_ :: Project -> PolicyId -> Paged -> SortOrder -> m [AssetInfo]
getAssetsByPolicy_ = AssetsAPI (AsClientT m)
-> PolicyId -> Paged -> SortOrder -> m [AssetInfo]
forall route.
AssetsAPI route
-> route
   :- (Summary "Assets of a specific policy"
       :> (Description "List of asset minted under a specific policy."
           :> ("policy"
               :> (Capture "policy_id" PolicyId
                   :> (Pagination :> (Sorting :> Get '[JSON] [AssetInfo]))))))
_listAssetsPolicy (AssetsAPI (AsClientT m)
 -> PolicyId -> Paged -> SortOrder -> m [AssetInfo])
-> (Project -> AssetsAPI (AsClientT m))
-> Project
-> PolicyId
-> Paged
-> SortOrder
-> m [AssetInfo]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Project -> AssetsAPI (AsClientT m)
forall (m :: * -> *).
MonadBlockfrost m =>
Project -> AssetsAPI (AsClientT m)
assetsClient

-- | List of asset minted under a specific policy
-- Allows custom paging and ordering using @Paged@ and @SortOrder@.
getAssetsByPolicy' :: MonadBlockfrost m => PolicyId -> Paged -> SortOrder -> m [AssetInfo]
getAssetsByPolicy' :: PolicyId -> Paged -> SortOrder -> m [AssetInfo]
getAssetsByPolicy' PolicyId
a Paged
pg SortOrder
s = (Project -> m [AssetInfo]) -> m [AssetInfo]
forall (m :: * -> *) a.
MonadBlockfrost m =>
(Project -> m a) -> m a
go (\Project
p -> Project -> PolicyId -> Paged -> SortOrder -> m [AssetInfo]
forall (m :: * -> *).
MonadBlockfrost m =>
Project -> PolicyId -> Paged -> SortOrder -> m [AssetInfo]
getAssetsByPolicy_ Project
p PolicyId
a Paged
pg SortOrder
s)

-- | List of asset minted under a specific policy
getAssetsByPolicy :: MonadBlockfrost m => PolicyId -> m [AssetInfo]
getAssetsByPolicy :: PolicyId -> m [AssetInfo]
getAssetsByPolicy PolicyId
a = PolicyId -> Paged -> SortOrder -> m [AssetInfo]
forall (m :: * -> *).
MonadBlockfrost m =>
PolicyId -> Paged -> SortOrder -> m [AssetInfo]
getAssetsByPolicy' PolicyId
a Paged
forall a. Default a => a
def SortOrder
forall a. Default a => a
def