From d1af60afb2687076ab55256204a6cad782ede510 Mon Sep 17 00:00:00 2001 From: Ron Rise Date: Wed, 25 Jun 2025 11:43:52 -0400 Subject: [PATCH] refactor: restructure EmailRequest and related types for improved clarity and maintainability --- client/create.go | 24 ------------------------ client/types.go | 28 ++++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/client/create.go b/client/create.go index c41b2dc..43322c0 100755 --- a/client/create.go +++ b/client/create.go @@ -7,30 +7,6 @@ import ( "time" ) -type EmailRequest struct { - Source string `json:"Source"` - Destination struct { - ToAddresses []string `json:"ToAddresses"` - CcAddresses []string `json:"CcAddresses"` - BccAddresses []string `json:"BccAddresses"` - } `json:"Destination"` - Message struct { - Body struct { - Html struct { - Data string `json:"Data"` - } `json:"Html,omitempty"` - Text struct { - Data string `json:"Data"` - } `json:"Text,omitempty"` - } `json:"Body"` - Subject struct { - Data string `json:"Data"` - } `json:"Subject"` - } `json:"Message"` - ScheduledTime time.Time `json:"ScheduledTime,omitempty"` - Catch bool `json:"Catch,omitempty"` -} - type EmailCreateResponse struct { Id string `json:"id"` CreatedAt time.Time `json:"created_at"` diff --git a/client/types.go b/client/types.go index 70e52c8..019e3a1 100755 --- a/client/types.go +++ b/client/types.go @@ -2,6 +2,34 @@ package client import "time" +type Body struct { + Html Data `json:"Html,omitempty"` + Text Data `json:"Text,omitempty"` +} + +type Data struct { + Data string `json:"Data"` +} + +type Addresses []string + +type Message struct { + Body Body `json:"Body"` + Subject Data `json:"Subject"` +} + +type EmailRequest struct { + Source string `json:"Source"` + Destination struct { + ToAddresses Addresses `json:"ToAddresses"` + CcAddresses Addresses `json:"CcAddresses"` + BccAddresses Addresses `json:"BccAddresses"` + } `json:"Destination"` + Message Message `json:"Message"` + ScheduledTime time.Time `json:"ScheduledTime,omitempty"` + Catch bool `json:"Catch,omitempty"` +} + type Email struct { Uuid string `json:"uuid"` IsSent uint8 `json:"is_sent"`