github.com/algorand/go-algorand-sdk@v1.24.0/client/v2/indexer/indexer.go (about)

     1  package indexer
     2  
     3  import (
     4  	"context"
     5  
     6  	"github.com/algorand/go-algorand-sdk/client/v2/common"
     7  )
     8  
     9  const authHeader = "X-Indexer-API-Token"
    10  
    11  type Client common.Client
    12  
    13  // get performs a GET request to the specific path against the server, assumes JSON response
    14  func (c *Client) get(ctx context.Context, response interface{}, path string, body interface{}, headers []*common.Header) error {
    15  	return (*common.Client)(c).Get(ctx, response, path, body, headers)
    16  }
    17  
    18  // getMsgpack performs a GET request to the specific path against the server, assumes msgpack response
    19  func (c *Client) getMsgpack(ctx context.Context, response interface{}, path string, body interface{}, headers []*common.Header) error {
    20  	return (*common.Client)(c).GetRawMsgpack(ctx, response, path, body, headers)
    21  }
    22  
    23  // getMsgpack performs a GET request to the specific path against the server, assumes msgpack response
    24  func (c *Client) getRaw(ctx context.Context, path string, body interface{}, headers []*common.Header) ([]byte, error) {
    25  	return (*common.Client)(c).GetRaw(ctx, path, body, headers)
    26  }
    27  
    28  // post sends a POST request to the given path with the given request object.
    29  // No query parameters will be sent if request is nil.
    30  // response must be a pointer to an object as post writes the response there.
    31  func (c *Client) post(ctx context.Context, response interface{}, path string, params interface{}, headers []*common.Header, body interface{}) error {
    32  	return (*common.Client)(c).Post(ctx, response, path, params, headers, body)
    33  }
    34  
    35  // MakeClient is the factory for constructing a ClientV2 for a given endpoint.
    36  func MakeClient(address string, apiToken string) (c *Client, err error) {
    37  	commonClient, err := common.MakeClient(address, authHeader, apiToken)
    38  	c = (*Client)(commonClient)
    39  	return
    40  }
    41  
    42  // MakeClientWithHeaders is the factory for constructing a ClientV2 for a
    43  // given endpoint with custom headers.
    44  func MakeClientWithHeaders(address string, apiToken string, headers []*common.Header) (c *Client, err error) {
    45  	commonClientWithHeaders, err := common.MakeClientWithHeaders(address, authHeader, apiToken, headers)
    46  	c = (*Client)(commonClientWithHeaders)
    47  	return
    48  }
    49  
    50  func (c *Client) HealthCheck() *HealthCheck {
    51  	return &HealthCheck{c: c}
    52  }
    53  
    54  func (c *Client) SearchAccounts() *SearchAccounts {
    55  	return &SearchAccounts{c: c}
    56  }
    57  
    58  func (c *Client) LookupAccountByID(accountId string) *LookupAccountByID {
    59  	return &LookupAccountByID{c: c, accountId: accountId}
    60  }
    61  
    62  func (c *Client) LookupAccountAssets(accountId string) *LookupAccountAssets {
    63  	return &LookupAccountAssets{c: c, accountId: accountId}
    64  }
    65  
    66  func (c *Client) LookupAccountCreatedAssets(accountId string) *LookupAccountCreatedAssets {
    67  	return &LookupAccountCreatedAssets{c: c, accountId: accountId}
    68  }
    69  
    70  func (c *Client) LookupAccountAppLocalStates(accountId string) *LookupAccountAppLocalStates {
    71  	return &LookupAccountAppLocalStates{c: c, accountId: accountId}
    72  }
    73  
    74  func (c *Client) LookupAccountCreatedApplications(accountId string) *LookupAccountCreatedApplications {
    75  	return &LookupAccountCreatedApplications{c: c, accountId: accountId}
    76  }
    77  
    78  func (c *Client) LookupAccountTransactions(accountId string) *LookupAccountTransactions {
    79  	return &LookupAccountTransactions{c: c, accountId: accountId}
    80  }
    81  
    82  func (c *Client) SearchForApplications() *SearchForApplications {
    83  	return &SearchForApplications{c: c}
    84  }
    85  
    86  func (c *Client) LookupApplicationByID(applicationId uint64) *LookupApplicationByID {
    87  	return &LookupApplicationByID{c: c, applicationId: applicationId}
    88  }
    89  
    90  func (c *Client) SearchForApplicationBoxes(applicationId uint64) *SearchForApplicationBoxes {
    91  	return &SearchForApplicationBoxes{c: c, applicationId: applicationId}
    92  }
    93  
    94  func (c *Client) LookupApplicationBoxByIDAndName(applicationId uint64, name []byte) *LookupApplicationBoxByIDAndName {
    95  	return (&LookupApplicationBoxByIDAndName{c: c, applicationId: applicationId}).name(name)
    96  }
    97  
    98  func (c *Client) LookupApplicationLogsByID(applicationId uint64) *LookupApplicationLogsByID {
    99  	return &LookupApplicationLogsByID{c: c, applicationId: applicationId}
   100  }
   101  
   102  func (c *Client) SearchForAssets() *SearchForAssets {
   103  	return &SearchForAssets{c: c}
   104  }
   105  
   106  func (c *Client) LookupAssetByID(assetId uint64) *LookupAssetByID {
   107  	return &LookupAssetByID{c: c, assetId: assetId}
   108  }
   109  
   110  func (c *Client) LookupAssetBalances(assetId uint64) *LookupAssetBalances {
   111  	return &LookupAssetBalances{c: c, assetId: assetId}
   112  }
   113  
   114  func (c *Client) LookupAssetTransactions(assetId uint64) *LookupAssetTransactions {
   115  	return &LookupAssetTransactions{c: c, assetId: assetId}
   116  }
   117  
   118  func (c *Client) LookupBlock(roundNumber uint64) *LookupBlock {
   119  	return &LookupBlock{c: c, roundNumber: roundNumber}
   120  }
   121  
   122  func (c *Client) LookupTransaction(txid string) *LookupTransaction {
   123  	return &LookupTransaction{c: c, txid: txid}
   124  }
   125  
   126  func (c *Client) SearchForTransactions() *SearchForTransactions {
   127  	return &SearchForTransactions{c: c}
   128  }