package main
import (
"bytes"
"fmt"
"io"
"net/http"
"os"
)
func main() {
url := "https://api.example.com/orders"
body := []byte(`{"customer_id": "string", "line_items": [{"sku": "string", "name": "string", "quantity": 1, "unit_price": {"currency": "USD", "amount": 1}, "total": {"currency": "USD", "amount": 1}}], "shipping_address": {"line1": "string", "line2": "string", "city": "string", "state": "string", "postal_code": "string", "country": "string"}, "billing_address": {"line1": "string", "line2": "string", "city": "string", "state": "string", "postal_code": "string", "country": "string"}}`)
req, err := http.NewRequest("POST", url, bytes.NewBuffer(body))
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer " + os.Getenv("API_KEY"))
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}