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

     1  package indexer
     2  
     3  import (
     4  	"context"
     5  	"fmt"
     6  
     7  	"github.com/algorand/go-algorand-sdk/client/v2/common"
     8  	"github.com/algorand/go-algorand-sdk/client/v2/common/models"
     9  )
    10  
    11  // LookupAccountByIDParams contains all of the query parameters for url serialization.
    12  type LookupAccountByIDParams struct {
    13  
    14  	// Exclude exclude additional items such as asset holdings, application local data
    15  	// stored for this account, asset parameters created by this account, and
    16  	// application parameters created by this account.
    17  	Exclude []string `url:"exclude,omitempty,comma"`
    18  
    19  	// IncludeAll include all items including closed accounts, deleted applications,
    20  	// destroyed assets, opted-out asset holdings, and closed-out application
    21  	// localstates.
    22  	IncludeAll bool `url:"include-all,omitempty"`
    23  
    24  	// Round include results for the specified round.
    25  	Round uint64 `url:"round,omitempty"`
    26  }
    27  
    28  // LookupAccountByID lookup account information.
    29  type LookupAccountByID struct {
    30  	c *Client
    31  
    32  	accountId string
    33  
    34  	p LookupAccountByIDParams
    35  }
    36  
    37  // Exclude exclude additional items such as asset holdings, application local data
    38  // stored for this account, asset parameters created by this account, and
    39  // application parameters created by this account.
    40  func (s *LookupAccountByID) Exclude(Exclude []string) *LookupAccountByID {
    41  	s.p.Exclude = Exclude
    42  
    43  	return s
    44  }
    45  
    46  // IncludeAll include all items including closed accounts, deleted applications,
    47  // destroyed assets, opted-out asset holdings, and closed-out application
    48  // localstates.
    49  func (s *LookupAccountByID) IncludeAll(IncludeAll bool) *LookupAccountByID {
    50  	s.p.IncludeAll = IncludeAll
    51  
    52  	return s
    53  }
    54  
    55  // Round include results for the specified round.
    56  func (s *LookupAccountByID) Round(Round uint64) *LookupAccountByID {
    57  	s.p.Round = Round
    58  
    59  	return s
    60  }
    61  
    62  // Do performs the HTTP request
    63  func (s *LookupAccountByID) Do(ctx context.Context, headers ...*common.Header) (validRound uint64, result models.Account, err error) {
    64  	response := models.AccountResponse{}
    65  	err = s.c.get(ctx, &response, fmt.Sprintf("/v2/accounts/%s", s.accountId), s.p, headers)
    66  	validRound = response.CurrentRound
    67  	result = response.Account
    68  	return
    69  }