package client import ( "context" "net/http" "strconv" ) func carePath(gardenID, speciesID int) string { return "v1/gardens/" + strconv.Itoa(gardenID) + "/species/" + strconv.Itoa(speciesID) + "/care-instructions" } // CareInstructions lists care guidance for a species visible in a garden. func (c *Client) CareInstructions(ctx context.Context, gardenID, speciesID int) ([]CareInstruction, *Response, error) { var out struct { Items []CareInstruction `json:"care_instructions"` } r, e := c.do(ctx, http.MethodGet, carePath(gardenID, speciesID), nil, &out) return out.Items, r, e } // CreateCareInstruction adds garden-specific care guidance to a species. func (c *Client) CreateCareInstruction(ctx context.Context, gardenID, speciesID int, input CareInstructionInput) (CareInstruction, *Response, error) { return c.writeCareInstruction(ctx, http.MethodPost, carePath(gardenID, speciesID), input) } // UpdateCareInstruction changes care guidance within its garden and species. func (c *Client) UpdateCareInstruction(ctx context.Context, gardenID, speciesID, id int, input CareInstructionInput) (CareInstruction, *Response, error) { return c.writeCareInstruction(ctx, http.MethodPatch, carePath(gardenID, speciesID)+"/"+strconv.Itoa(id), input) } // DeleteCareInstruction removes care guidance within its garden and species. func (c *Client) DeleteCareInstruction(ctx context.Context, gardenID, speciesID, id int) (*Response, error) { return c.do(ctx, http.MethodDelete, carePath(gardenID, speciesID)+"/"+strconv.Itoa(id), nil, nil) } func (c *Client) writeCareInstruction(ctx context.Context, method, path string, input CareInstructionInput) (CareInstruction, *Response, error) { var out struct { Item CareInstruction `json:"care_instruction"` } r, e := c.do(ctx, method, path, input, &out) return out.Item, r, e }