-- | 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 :: Project -> AssetsAPI (AsClientT BlockfrostClient)
assetsClient :: Project -> AssetsAPI (AsClientT BlockfrostClient)
assetsClient = (((Paged
   -> SortOrder
   -> ExceptT BlockfrostError (ReaderT ClientConfig IO) [AssetInfo])
  :<|> ((AssetId
         -> ExceptT BlockfrostError (ReaderT ClientConfig IO) AssetDetails)
        :<|> (AssetId
              -> Paged
              -> SortOrder
              -> ExceptT
                   BlockfrostError (ReaderT ClientConfig IO) [AssetHistory])))
 :<|> ((AssetId
        -> Paged
        -> SortOrder
        -> ExceptT
             BlockfrostError (ReaderT ClientConfig IO) [AssetTransaction])
       :<|> ((AssetId
              -> Paged
              -> SortOrder
              -> ExceptT
                   BlockfrostError (ReaderT ClientConfig IO) [AssetAddress])
             :<|> (PolicyId
                   -> Paged
                   -> SortOrder
                   -> ExceptT
                        BlockfrostError (ReaderT ClientConfig IO) [AssetInfo]))))
-> AssetsAPI (AsClientT BlockfrostClient)
forall (routes :: * -> *) mode.
GenericServant routes mode =>
ToServant routes mode -> routes mode
fromServant ((((Paged
    -> SortOrder
    -> ExceptT BlockfrostError (ReaderT ClientConfig IO) [AssetInfo])
   :<|> ((AssetId
          -> ExceptT BlockfrostError (ReaderT ClientConfig IO) AssetDetails)
         :<|> (AssetId
               -> Paged
               -> SortOrder
               -> ExceptT
                    BlockfrostError (ReaderT ClientConfig IO) [AssetHistory])))
  :<|> ((AssetId
         -> Paged
         -> SortOrder
         -> ExceptT
              BlockfrostError (ReaderT ClientConfig IO) [AssetTransaction])
        :<|> ((AssetId
               -> Paged
               -> SortOrder
               -> ExceptT
                    BlockfrostError (ReaderT ClientConfig IO) [AssetAddress])
              :<|> (PolicyId
                    -> Paged
                    -> SortOrder
                    -> ExceptT
                         BlockfrostError (ReaderT ClientConfig IO) [AssetInfo]))))
 -> AssetsAPI (AsClientT BlockfrostClient))
-> (Project
    -> ((Paged
         -> SortOrder
         -> ExceptT BlockfrostError (ReaderT ClientConfig IO) [AssetInfo])
        :<|> ((AssetId
               -> ExceptT BlockfrostError (ReaderT ClientConfig IO) AssetDetails)
              :<|> (AssetId
                    -> Paged
                    -> SortOrder
                    -> ExceptT
                         BlockfrostError (ReaderT ClientConfig IO) [AssetHistory])))
       :<|> ((AssetId
              -> Paged
              -> SortOrder
              -> ExceptT
                   BlockfrostError (ReaderT ClientConfig IO) [AssetTransaction])
             :<|> ((AssetId
                    -> Paged
                    -> SortOrder
                    -> ExceptT
                         BlockfrostError (ReaderT ClientConfig IO) [AssetAddress])
                   :<|> (PolicyId
                         -> Paged
                         -> SortOrder
                         -> ExceptT
                              BlockfrostError (ReaderT ClientConfig IO) [AssetInfo]))))
-> Project
-> AssetsAPI (AsClientT BlockfrostClient)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CardanoAPI (AsClientT BlockfrostClient)
-> ((Paged
     -> SortOrder
     -> ExceptT BlockfrostError (ReaderT ClientConfig IO) [AssetInfo])
    :<|> ((AssetId
           -> ExceptT BlockfrostError (ReaderT ClientConfig IO) AssetDetails)
          :<|> (AssetId
                -> Paged
                -> SortOrder
                -> ExceptT
                     BlockfrostError (ReaderT ClientConfig IO) [AssetHistory])))
   :<|> ((AssetId
          -> Paged
          -> SortOrder
          -> ExceptT
               BlockfrostError (ReaderT ClientConfig IO) [AssetTransaction])
         :<|> ((AssetId
                -> Paged
                -> SortOrder
                -> ExceptT
                     BlockfrostError (ReaderT ClientConfig IO) [AssetAddress])
               :<|> (PolicyId
                     -> Paged
                     -> SortOrder
                     -> ExceptT BlockfrostError (ReaderT ClientConfig IO) [AssetInfo])))
forall route.
CardanoAPI route
-> route
   :- ("assets"
       :> (Tag "Cardano \187 Assets" :> ToServantApi AssetsAPI))
_assets (CardanoAPI (AsClientT BlockfrostClient)
 -> ((Paged
      -> SortOrder
      -> ExceptT BlockfrostError (ReaderT ClientConfig IO) [AssetInfo])
     :<|> ((AssetId
            -> ExceptT BlockfrostError (ReaderT ClientConfig IO) AssetDetails)
           :<|> (AssetId
                 -> Paged
                 -> SortOrder
                 -> ExceptT
                      BlockfrostError (ReaderT ClientConfig IO) [AssetHistory])))
    :<|> ((AssetId
           -> Paged
           -> SortOrder
           -> ExceptT
                BlockfrostError (ReaderT ClientConfig IO) [AssetTransaction])
          :<|> ((AssetId
                 -> Paged
                 -> SortOrder
                 -> ExceptT
                      BlockfrostError (ReaderT ClientConfig IO) [AssetAddress])
                :<|> (PolicyId
                      -> Paged
                      -> SortOrder
                      -> ExceptT
                           BlockfrostError (ReaderT ClientConfig IO) [AssetInfo]))))
-> (Project -> CardanoAPI (AsClientT BlockfrostClient))
-> Project
-> ((Paged
     -> SortOrder
     -> ExceptT BlockfrostError (ReaderT ClientConfig IO) [AssetInfo])
    :<|> ((AssetId
           -> ExceptT BlockfrostError (ReaderT ClientConfig IO) AssetDetails)
          :<|> (AssetId
                -> Paged
                -> SortOrder
                -> ExceptT
                     BlockfrostError (ReaderT ClientConfig IO) [AssetHistory])))
   :<|> ((AssetId
          -> Paged
          -> SortOrder
          -> ExceptT
               BlockfrostError (ReaderT ClientConfig IO) [AssetTransaction])
         :<|> ((AssetId
                -> Paged
                -> SortOrder
                -> ExceptT
                     BlockfrostError (ReaderT ClientConfig IO) [AssetAddress])
               :<|> (PolicyId
                     -> Paged
                     -> SortOrder
                     -> ExceptT BlockfrostError (ReaderT ClientConfig IO) [AssetInfo])))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Project -> CardanoAPI (AsClientT BlockfrostClient)
cardanoClient

getAssets_ :: Project -> Paged -> SortOrder -> BlockfrostClient [AssetInfo]
getAssets_ :: Project
-> Paged
-> SortOrder
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [AssetInfo]
getAssets_ = AssetsAPI (AsClientT BlockfrostClient)
-> Paged
-> SortOrder
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [AssetInfo]
forall route.
AssetsAPI route
-> route
   :- (Summary "Assets"
       :> (Description "List of assets."
           :> (Pagination :> (Sorting :> Get '[JSON] [AssetInfo]))))
_listAssets (AssetsAPI (AsClientT BlockfrostClient)
 -> Paged
 -> SortOrder
 -> ExceptT BlockfrostError (ReaderT ClientConfig IO) [AssetInfo])
-> (Project -> AssetsAPI (AsClientT BlockfrostClient))
-> Project
-> Paged
-> SortOrder
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [AssetInfo]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Project -> AssetsAPI (AsClientT BlockfrostClient)
assetsClient

-- | List all assets
-- Allows custom paging and ordering using @Paged@ and @SortOrder@.
getAssets' :: Paged -> SortOrder -> BlockfrostClient [AssetInfo]
getAssets' :: Paged
-> SortOrder
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [AssetInfo]
getAssets' Paged
pg SortOrder
s = (Project
 -> ExceptT BlockfrostError (ReaderT ClientConfig IO) [AssetInfo])
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [AssetInfo]
forall a. (Project -> BlockfrostClient a) -> BlockfrostClient a
go (\Project
p -> Project
-> Paged
-> SortOrder
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [AssetInfo]
getAssets_ Project
p Paged
pg SortOrder
s)

-- | List all assets
getAssets :: BlockfrostClient [AssetInfo]
getAssets :: ExceptT BlockfrostError (ReaderT ClientConfig IO) [AssetInfo]
getAssets = Paged
-> SortOrder
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [AssetInfo]
getAssets' Paged
forall a. Default a => a
def SortOrder
forall a. Default a => a
def

getAssetDetails_ :: Project -> AssetId -> BlockfrostClient AssetDetails
getAssetDetails_ :: Project
-> AssetId
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) AssetDetails
getAssetDetails_ = AssetsAPI (AsClientT BlockfrostClient)
-> AssetId
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) AssetDetails
forall route.
AssetsAPI route
-> route
   :- (Summary "Specific asset"
       :> (Description "Information about a specific asset."
           :> (Capture "asset" AssetId :> Get '[JSON] AssetDetails)))
_assetDetails (AssetsAPI (AsClientT BlockfrostClient)
 -> AssetId
 -> ExceptT BlockfrostError (ReaderT ClientConfig IO) AssetDetails)
-> (Project -> AssetsAPI (AsClientT BlockfrostClient))
-> Project
-> AssetId
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) AssetDetails
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Project -> AssetsAPI (AsClientT BlockfrostClient)
assetsClient

-- | Information about a specific asset
getAssetDetails :: AssetId -> BlockfrostClient AssetDetails
getAssetDetails :: AssetId
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) AssetDetails
getAssetDetails AssetId
a = (Project
 -> ExceptT BlockfrostError (ReaderT ClientConfig IO) AssetDetails)
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) AssetDetails
forall a. (Project -> BlockfrostClient a) -> BlockfrostClient a
go (Project
-> AssetId
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) AssetDetails
`getAssetDetails_` AssetId
a)

getAssetHistory_ :: Project -> AssetId -> Paged -> SortOrder -> BlockfrostClient [AssetHistory]
getAssetHistory_ :: Project
-> AssetId
-> Paged
-> SortOrder
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [AssetHistory]
getAssetHistory_ = AssetsAPI (AsClientT BlockfrostClient)
-> AssetId
-> Paged
-> SortOrder
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [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 BlockfrostClient)
 -> AssetId
 -> Paged
 -> SortOrder
 -> ExceptT
      BlockfrostError (ReaderT ClientConfig IO) [AssetHistory])
-> (Project -> AssetsAPI (AsClientT BlockfrostClient))
-> Project
-> AssetId
-> Paged
-> SortOrder
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [AssetHistory]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Project -> AssetsAPI (AsClientT BlockfrostClient)
assetsClient

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

-- | History of a specific asset
getAssetHistory :: AssetId -> BlockfrostClient [AssetHistory]
getAssetHistory :: AssetId
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [AssetHistory]
getAssetHistory AssetId
a = AssetId
-> Paged
-> SortOrder
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [AssetHistory]
getAssetHistory' AssetId
a Paged
forall a. Default a => a
def SortOrder
forall a. Default a => a
def

getAssetTransactions_ :: Project -> AssetId -> Paged -> SortOrder -> BlockfrostClient [AssetTransaction]
getAssetTransactions_ :: Project
-> AssetId
-> Paged
-> SortOrder
-> ExceptT
     BlockfrostError (ReaderT ClientConfig IO) [AssetTransaction]
getAssetTransactions_ = AssetsAPI (AsClientT BlockfrostClient)
-> AssetId
-> Paged
-> SortOrder
-> ExceptT
     BlockfrostError (ReaderT ClientConfig IO) [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 BlockfrostClient)
 -> AssetId
 -> Paged
 -> SortOrder
 -> ExceptT
      BlockfrostError (ReaderT ClientConfig IO) [AssetTransaction])
-> (Project -> AssetsAPI (AsClientT BlockfrostClient))
-> Project
-> AssetId
-> Paged
-> SortOrder
-> ExceptT
     BlockfrostError (ReaderT ClientConfig IO) [AssetTransaction]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Project -> AssetsAPI (AsClientT BlockfrostClient)
assetsClient

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

-- | List of a specific asset transactions
getAssetTransactions :: AssetId -> BlockfrostClient [AssetTransaction]
getAssetTransactions :: AssetId
-> ExceptT
     BlockfrostError (ReaderT ClientConfig IO) [AssetTransaction]
getAssetTransactions AssetId
a = AssetId
-> Paged
-> SortOrder
-> ExceptT
     BlockfrostError (ReaderT ClientConfig IO) [AssetTransaction]
getAssetTransactions' AssetId
a Paged
forall a. Default a => a
def SortOrder
forall a. Default a => a
def

getAssetAddresses_ :: Project -> AssetId -> Paged -> SortOrder -> BlockfrostClient [AssetAddress]
getAssetAddresses_ :: Project
-> AssetId
-> Paged
-> SortOrder
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [AssetAddress]
getAssetAddresses_ = AssetsAPI (AsClientT BlockfrostClient)
-> AssetId
-> Paged
-> SortOrder
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [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 BlockfrostClient)
 -> AssetId
 -> Paged
 -> SortOrder
 -> ExceptT
      BlockfrostError (ReaderT ClientConfig IO) [AssetAddress])
-> (Project -> AssetsAPI (AsClientT BlockfrostClient))
-> Project
-> AssetId
-> Paged
-> SortOrder
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [AssetAddress]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Project -> AssetsAPI (AsClientT BlockfrostClient)
assetsClient

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

-- | List of a addresses containing a specific asset
getAssetAddresses :: AssetId -> BlockfrostClient [AssetAddress]
getAssetAddresses :: AssetId
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [AssetAddress]
getAssetAddresses AssetId
a = AssetId
-> Paged
-> SortOrder
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [AssetAddress]
getAssetAddresses' AssetId
a Paged
forall a. Default a => a
def SortOrder
forall a. Default a => a
def

getAssetsByPolicy_ :: Project -> PolicyId -> Paged -> SortOrder -> BlockfrostClient [AssetInfo]
getAssetsByPolicy_ :: Project
-> PolicyId
-> Paged
-> SortOrder
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [AssetInfo]
getAssetsByPolicy_ = AssetsAPI (AsClientT BlockfrostClient)
-> PolicyId
-> Paged
-> SortOrder
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [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 BlockfrostClient)
 -> PolicyId
 -> Paged
 -> SortOrder
 -> ExceptT BlockfrostError (ReaderT ClientConfig IO) [AssetInfo])
-> (Project -> AssetsAPI (AsClientT BlockfrostClient))
-> Project
-> PolicyId
-> Paged
-> SortOrder
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [AssetInfo]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Project -> AssetsAPI (AsClientT BlockfrostClient)
assetsClient

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

-- | List of asset minted under a specific policy
getAssetsByPolicy :: PolicyId -> BlockfrostClient [AssetInfo]
getAssetsByPolicy :: PolicyId
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [AssetInfo]
getAssetsByPolicy PolicyId
a = PolicyId
-> Paged
-> SortOrder
-> ExceptT BlockfrostError (ReaderT ClientConfig IO) [AssetInfo]
getAssetsByPolicy' PolicyId
a Paged
forall a. Default a => a
def SortOrder
forall a. Default a => a
def