MCPcopy Index your code
hub / github.com/larksuite/cli / CallAPI

Method CallAPI

internal/client/client.go:330–340  ·  view source on GitHub ↗

CallAPI is a convenience wrapper: DoAPI + ParseJSONResponse. Use DoAPI directly when the response may not be JSON (e.g. file downloads). JSON parse failures are wrapped via WrapJSONResponseParseError so callers (notably the pagination loop and --page-all paths in cmd/api / cmd/service) see a typed

(ctx context.Context, request RawApiRequest)

Source from the content-addressed store, hash-verified

328// root handler as a plain-text "Error: ..." line and bypass the JSON stderr
329// envelope contract.
330func (c *APIClient) CallAPI(ctx context.Context, request RawApiRequest) (interface{}, error) {
331 resp, err := c.DoAPI(ctx, request)
332 if err != nil {
333 return nil, err
334 }
335 result, parseErr := ParseJSONResponse(resp)
336 if parseErr != nil {
337 return nil, WrapJSONResponseParseError(parseErr, resp.RawBody)
338 }
339 return result, nil
340}
341
342// paginateLoop runs the core pagination loop. For each successful page (code == 0),
343// it calls onResult if non-nil. It always accumulates and returns all raw page results.

Callers 1

paginateLoopMethod · 0.95

Calls 3

DoAPIMethod · 0.95
ParseJSONResponseFunction · 0.85

Tested by

no test coverage detected