-- | 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 :: forall (m :: * -> *).
MonadBlockfrost m =>
Project -> AssetsAPI (AsClientT m)
assetsClient = forall (routes :: * -> *) mode.
GenericServant routes mode =>
ToServant routes mode -> routes mode
fromServant forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall route.
CardanoAPI route
-> route
   :- ("assets"
       :> (Tag "Cardano \187 Assets" :> ToServantApi AssetsAPI))
_assets forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
MonadBlockfrost m =>
Project -> CardanoAPI (AsClientT m)
cardanoClient

getAssets_ :: MonadBlockfrost m => Project -> Paged -> SortOrder -> m [AssetInfo]
getAssets_ :: forall (m :: * -> *).
MonadBlockfrost m =>
Project -> Paged -> SortOrder -> m [AssetInfo]
getAssets_ = forall route.
AssetsAPI route
-> route
   :- (Summary "Assets"
       :> (Description "List of assets."
           :> (Pagination :> (Sorting :> Get '[JSON] [AssetInfo]))))
_listAssets forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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' :: forall (m :: * -> *).
MonadBlockfrost m =>
Paged -> SortOrder -> m [AssetInfo]
getAssets' Paged
pg SortOrder
s = forall (m :: * -> *) a.
MonadBlockfrost m =>
(Project -> m a) -> m a
go (\Project
p -> forall (m :: * -> *).
MonadBlockfrost m =>
Project -> Paged -> SortOrder -> m [AssetInfo]
getAssets_ Project
p Paged
pg SortOrder
s)

-- | List all assets
--
-- Queries 100 entries. To query all entries use 'Blockfrost.Client.Core.allPages'
-- with principled variant of this function (suffixed with @'@)
-- that accepts 'Paged' argument.
getAssets :: MonadBlockfrost m => m [AssetInfo]
getAssets :: forall (m :: * -> *). MonadBlockfrost m => m [AssetInfo]
getAssets = forall (m :: * -> *).
MonadBlockfrost m =>
Paged -> SortOrder -> m [AssetInfo]
getAssets' forall a. Default a => a
def forall a. Default a => a
def

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

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

getAssetHistory_ :: MonadBlockfrost m => Project -> AssetId -> Paged -> SortOrder -> m [AssetHistory]
getAssetHistory_ :: forall (m :: * -> *).
MonadBlockfrost m =>
Project -> AssetId -> Paged -> SortOrder -> m [AssetHistory]
getAssetHistory_ = forall route.
AssetsAPI route
-> route
   :- (Summary "Asset history"
       :> (Description "History of a specific asset."
           :> (Capture "asset" AssetId
               :> ("history"
                   :> (Pagination :> (Sorting :> Get '[JSON] [AssetHistory]))))))
_assetHistory forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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' :: forall (m :: * -> *).
MonadBlockfrost m =>
AssetId -> Paged -> SortOrder -> m [AssetHistory]
getAssetHistory' AssetId
a Paged
pg SortOrder
s = forall (m :: * -> *) a.
MonadBlockfrost m =>
(Project -> m a) -> m a
go (\Project
p -> forall (m :: * -> *).
MonadBlockfrost m =>
Project -> AssetId -> Paged -> SortOrder -> m [AssetHistory]
getAssetHistory_ Project
p AssetId
a Paged
pg SortOrder
s)

-- | History of a specific asset
--
-- Queries 100 entries. To query all entries use 'Blockfrost.Client.Core.allPages'
-- with principled variant of this function (suffixed with @'@)
-- that accepts 'Paged' argument.
getAssetHistory :: MonadBlockfrost m => AssetId -> m [AssetHistory]
getAssetHistory :: forall (m :: * -> *).
MonadBlockfrost m =>
AssetId -> m [AssetHistory]
getAssetHistory AssetId
a = forall (m :: * -> *).
MonadBlockfrost m =>
AssetId -> Paged -> SortOrder -> m [AssetHistory]
getAssetHistory' AssetId
a forall a. Default a => a
def forall a. Default a => a
def

getAssetTransactions_ :: MonadBlockfrost m => Project -> AssetId -> Paged -> SortOrder -> m [AssetTransaction]
getAssetTransactions_ :: forall (m :: * -> *).
MonadBlockfrost m =>
Project -> AssetId -> Paged -> SortOrder -> m [AssetTransaction]
getAssetTransactions_ = 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 forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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' :: forall (m :: * -> *).
MonadBlockfrost m =>
AssetId -> Paged -> SortOrder -> m [AssetTransaction]
getAssetTransactions' AssetId
a Paged
pg SortOrder
s = forall (m :: * -> *) a.
MonadBlockfrost m =>
(Project -> m a) -> m a
go (\Project
p -> 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
--
-- Queries 100 entries. To query all entries use 'Blockfrost.Client.Core.allPages'
-- with principled variant of this function (suffixed with @'@)
-- that accepts 'Paged' argument.
getAssetTransactions :: MonadBlockfrost m => AssetId -> m [AssetTransaction]
getAssetTransactions :: forall (m :: * -> *).
MonadBlockfrost m =>
AssetId -> m [AssetTransaction]
getAssetTransactions AssetId
a = forall (m :: * -> *).
MonadBlockfrost m =>
AssetId -> Paged -> SortOrder -> m [AssetTransaction]
getAssetTransactions' AssetId
a forall a. Default a => a
def forall a. Default a => a
def

getAssetAddresses_ :: MonadBlockfrost m => Project -> AssetId -> Paged -> SortOrder -> m [AssetAddress]
getAssetAddresses_ :: forall (m :: * -> *).
MonadBlockfrost m =>
Project -> AssetId -> Paged -> SortOrder -> m [AssetAddress]
getAssetAddresses_ = 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 forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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' :: forall (m :: * -> *).
MonadBlockfrost m =>
AssetId -> Paged -> SortOrder -> m [AssetAddress]
getAssetAddresses' AssetId
a Paged
pg SortOrder
s = forall (m :: * -> *) a.
MonadBlockfrost m =>
(Project -> m a) -> m a
go (\Project
p -> 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
--
-- Queries 100 entries. To query all entries use 'Blockfrost.Client.Core.allPages'
-- with principled variant of this function (suffixed with @'@)
-- that accepts 'Paged' argument.
getAssetAddresses :: MonadBlockfrost m => AssetId -> m [AssetAddress]
getAssetAddresses :: forall (m :: * -> *).
MonadBlockfrost m =>
AssetId -> m [AssetAddress]
getAssetAddresses AssetId
a = forall (m :: * -> *).
MonadBlockfrost m =>
AssetId -> Paged -> SortOrder -> m [AssetAddress]
getAssetAddresses' AssetId
a forall a. Default a => a
def forall a. Default a => a
def

getAssetsByPolicy_ :: MonadBlockfrost m => Project -> PolicyId -> Paged -> SortOrder -> m [AssetInfo]
getAssetsByPolicy_ :: forall (m :: * -> *).
MonadBlockfrost m =>
Project -> PolicyId -> Paged -> SortOrder -> m [AssetInfo]
getAssetsByPolicy_ = 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 forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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' :: forall (m :: * -> *).
MonadBlockfrost m =>
PolicyId -> Paged -> SortOrder -> m [AssetInfo]
getAssetsByPolicy' PolicyId
a Paged
pg SortOrder
s = forall (m :: * -> *) a.
MonadBlockfrost m =>
(Project -> m a) -> m a
go (\Project
p -> 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
--
-- Queries 100 entries. To query all entries use 'Blockfrost.Client.Core.allPages'
-- with principled variant of this function (suffixed with @'@)
-- that accepts 'Paged' argument.
getAssetsByPolicy :: MonadBlockfrost m => PolicyId -> m [AssetInfo]
getAssetsByPolicy :: forall (m :: * -> *).
MonadBlockfrost m =>
PolicyId -> m [AssetInfo]
getAssetsByPolicy PolicyId
a = forall (m :: * -> *).
MonadBlockfrost m =>
PolicyId -> Paged -> SortOrder -> m [AssetInfo]
getAssetsByPolicy' PolicyId
a forall a. Default a => a
def forall a. Default a => a
def