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

     1  package algod
     2  
     3  import (
     4  	"context"
     5  	"encoding/base64"
     6  	"fmt"
     7  
     8  	"github.com/algorand/go-algorand-sdk/client/v2/common"
     9  	"github.com/algorand/go-algorand-sdk/client/v2/common/models"
    10  )
    11  
    12  // GetApplicationBoxByNameParams contains all of the query parameters for url serialization.
    13  type GetApplicationBoxByNameParams struct {
    14  
    15  	// Name a box name, in the goal app call arg form 'encoding:value'. For ints, use
    16  	// the form 'int:1234'. For raw bytes, use the form 'b64:A=='. For printable
    17  	// strings, use the form 'str:hello'. For addresses, use the form 'addr:XYZ...'.
    18  	Name string `url:"name,omitempty"`
    19  }
    20  
    21  // GetApplicationBoxByName given an application ID and box name, it returns the box
    22  // name and value (each base64 encoded). Box names must be in the goal app call arg
    23  // encoding form 'encoding:value'. For ints, use the form 'int:1234'. For raw
    24  // bytes, use the form 'b64:A=='. For printable strings, use the form 'str:hello'.
    25  // For addresses, use the form 'addr:XYZ...'.
    26  type GetApplicationBoxByName struct {
    27  	c *Client
    28  
    29  	applicationId uint64
    30  
    31  	p GetApplicationBoxByNameParams
    32  }
    33  
    34  // name a box name, in the goal app call arg form 'encoding:value'. For ints, use
    35  // the form 'int:1234'. For raw bytes, use the form 'b64:A=='. For printable
    36  // strings, use the form 'str:hello'. For addresses, use the form 'addr:XYZ...'.
    37  func (s *GetApplicationBoxByName) name(name []byte) *GetApplicationBoxByName {
    38  	s.p.Name = "b64:" + base64.StdEncoding.EncodeToString(name)
    39  
    40  	return s
    41  }
    42  
    43  // Do performs the HTTP request
    44  func (s *GetApplicationBoxByName) Do(ctx context.Context, headers ...*common.Header) (response models.Box, err error) {
    45  	err = s.c.get(ctx, &response, fmt.Sprintf("/v2/applications/%s/box", common.EscapeParams(s.applicationId)...), s.p, headers)
    46  	return
    47  }