Skip to content

Commit

Permalink
feat(SPV-737): rename TItem to TResp
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-4chain committed May 29, 2024
1 parent 27e6222 commit d34c503
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions search.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
type SearchRequester func(ctx context.Context, method string, path string, rawJSON []byte, xPriv *bip32.ExtendedKey, sign bool, responseJSON interface{}) ResponseError

// Search prepares and sends a search request to the server.
func Search[TFilter any, TItem any](
func Search[TFilter any, TResp any](
ctx context.Context,
method string,
path string,
Expand All @@ -21,24 +21,24 @@ func Search[TFilter any, TItem any](
metadata map[string]any,
queryParams *filter.QueryParams,
requester SearchRequester,
) (TItem, ResponseError) {
) (TResp, ResponseError) {
jsonStr, err := json.Marshal(filter.SearchModel[TFilter]{
ConditionsModel: filter.ConditionsModel[TFilter]{
Conditions: f,
Metadata: toMapPtr(metadata),
},
QueryParams: queryParams,
})
var items TItem // before initialization, this var is empty slice or nil so it can be returned in case of error
var resp TResp // before initialization, this var is empty slice or nil so it can be returned in case of error
if err != nil {
return items, WrapError(err)
return resp, WrapError(err)
}

if err := requester(ctx, method, path, jsonStr, xPriv, true, &items); err != nil {
return items, err
if err := requester(ctx, method, path, jsonStr, xPriv, true, &resp); err != nil {
return resp, err
}

return items, nil
return resp, nil
}

// Count prepares and sends a count request to the server.
Expand Down

0 comments on commit d34c503

Please sign in to comment.