| 108 | } |
| 109 | |
| 110 | func (c *Client) post(endpoint string, payload any, requireAuth bool) (int, []byte, error) { |
| 111 | var ( |
| 112 | body io.Reader |
| 113 | contentType string |
| 114 | ) |
| 115 | if payload != nil { |
| 116 | bodyBytes, err := json.Marshal(payload) |
| 117 | if err != nil { |
| 118 | return 0, nil, fmt.Errorf("failed to marshal POST request body: %w", err) |
| 119 | } |
| 120 | body = bytes.NewReader(bodyBytes) |
| 121 | contentType = "application/json" |
| 122 | } |
| 123 | |
| 124 | return c.doRequest(http.MethodPost, endpoint, body, contentType, requireAuth) |
| 125 | } |
| 126 | |
| 127 | // FetchPricing calls POST /pricing with the given filters. |
| 128 | func (c *Client) FetchPricing(products, regions []string, attrs map[string]string, prices []string) (*PricingAPIResponse, error) { |