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)
| 328 | // root handler as a plain-text "Error: ..." line and bypass the JSON stderr |
| 329 | // envelope contract. |
| 330 | func (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. |
no test coverage detected