package businessapi

import (
	"context"
	"net/url"
)

// GetBusinessProfile retrieves the business profile for this phone number.
func (c *Client) GetBusinessProfile(ctx context.Context) (*BusinessProfile, error) {
	params := url.Values{
		"fields": {"about,address,description,email,websites,vertical,profile_picture_url"},
	}

	var resp BusinessProfile
	if err := c.graphAPIGet(ctx, c.config.PhoneNumberID+"/whatsapp_business_profile", params, &resp); err != nil {
		return nil, err
	}
	return &resp, nil
}

// UpdateBusinessProfile updates one or more business profile fields.
// Only include fields you want to change — omitted fields are left untouched.
func (c *Client) UpdateBusinessProfile(ctx context.Context, profile BusinessProfileUpdate) error {
	profile.MessagingProduct = "whatsapp"

	var resp map[string]any
	return c.graphAPIPost(ctx, c.config.PhoneNumberID+"/whatsapp_business_profile", profile, &resp)
}
