package channel

import (
	"time"

	"github.com/gochat/gochat/internal/model"
)

// ChannelTwilioSMS represents a Twilio SMS/WhatsApp channel configuration.
// Reference: Chatwoot Channel::TwilioSms + P2B M2 spec
type ChannelTwilioSMS struct {
	ID              uint      `gorm:"primaryKey" json:"id"`
	InboxID         uint      `gorm:"uniqueIndex;not null" json:"inbox_id"`
	PhoneNumber     string    `gorm:"size:50;not null;index" json:"phone_number"`
	AccountSID      string    `gorm:"size:255;not null" json:"account_sid"`
	AuthToken       string    `gorm:"size:255;not null" json:"-"`
	APIKey          string    `gorm:"size:255" json:"api_key"`
	APISecret       string    `gorm:"size:255" json:"-"`
	MessagingServiceSID string `gorm:"size:255" json:"messaging_service_sid"`
	Medium          string    `gorm:"size:50;default:'sms'" json:"medium"` // sms/whatsapp
	CreatedAt       time.Time `gorm:"autoCreateTime" json:"created_at"`
	UpdatedAt       time.Time `gorm:"autoUpdateTime" json:"updated_at"`

	Inbox model.Inbox `gorm:"foreignKey:InboxID" json:"inbox,omitempty"`
}

func (ChannelTwilioSMS) TableName() string { return "channel_twilio_sms" }
func (c ChannelTwilioSMS) GetInboxID() uint                    { return c.InboxID }
func (c ChannelTwilioSMS) GetChannelType() model.InboxChannelType { return model.InboxChannelTypeTwilioSms }