@@ -77,17 +77,20 @@ type ReturnData struct {
7777}
7878
7979type QuoteData struct {
80- ID string `json:"id"`
81- Name string `json:"name"`
82- Quote string `json:"quote"`
83- Currency string `json:"currency"`
84- Total any `json:"total"`
85- TotalDisplay string `json:"totalDisplay"`
86- Subtotal string `json:"subtotalDisplay"`
87- Customer Customer `json:"customer"`
88- Recipient Customer `json:"recipient"`
89- ExpiresAt string `json:"expirationDateValue"`
90- Status string `json:"status"`
80+ Quote string `json:"quote"`
81+ QuoteName string `json:"quoteName"`
82+ QuoteStatus string `json:"quoteStatus"`
83+ QuoteCurrency string `json:"quoteCurrency"`
84+ Total string `json:"total"`
85+ TotalDisplay string `json:"totalDisplay"`
86+ Subtotal string `json:"subtotal"`
87+ SubtotalDisplay string `json:"subtotalDisplay"`
88+ Recipient Customer `json:"recipient"`
89+ QuoteUrl string `json:"quoteUrl"`
90+ Creator string `json:"creator"`
91+ UpdatedBy string `json:"updatedBy"`
92+ Reason string `json:"Reason"`
93+ Items []Item `json:"items"`
9194}
9295
9396type SlackMessage struct {
@@ -414,48 +417,33 @@ func formatReturnMessage(data ReturnData, live bool) SlackMessage {
414417func formatQuoteMessage (data QuoteData , live bool , title string ) SlackMessage {
415418 env := envLabel (live )
416419
417- // Use recipient if customer is empty
418- customer := data .Customer
419- if customer .Email == "" {
420- customer = data .Recipient
421- }
422-
423- // Use quote ID if name is empty
424- quoteName := data .Name
425- if quoteName == "" {
426- quoteName = data .Quote
427- }
428- if quoteName == "" {
429- quoteName = data .ID
430- }
431-
432- // Use subtotal if total display is empty
433- total := data .TotalDisplay
434- if total == "" {
435- total = data .Subtotal
436- }
437-
438- text := fmt .Sprintf (":memo: [%s] %s\n \n Quote: %s\n Total: %s" ,
420+ text := fmt .Sprintf (":memo: [%s] %s\n \n Quote: %s (%s)\n Total: %s\n Status: %s" ,
439421 env ,
440422 title ,
441- quoteName ,
442- total ,
423+ data .QuoteName ,
424+ data .Quote ,
425+ data .TotalDisplay ,
426+ data .QuoteStatus ,
443427 )
444428
445- // Add customer info if available
446- if customer .Email != "" {
447- text += fmt .Sprintf ("\n Customer : %s %s (%s)" , customer . First , customer . Last , customer .Email )
429+ // Add recipient info
430+ if data . Recipient .Email != "" {
431+ text += fmt .Sprintf ("\n Recipient : %s %s (%s)" , data . Recipient . First , data . Recipient . Last , data . Recipient .Email )
448432 }
449- if customer .Company != "" {
450- text += fmt .Sprintf ("\n Company: %s" , customer .Company )
433+ if data . Recipient .Company != "" {
434+ text += fmt .Sprintf ("\n Company: %s" , data . Recipient .Company )
451435 }
452436
453- if data .Status != "" {
454- text += fmt .Sprintf ("\n Status: %s" , data .Status )
437+ // Add items
438+ if len (data .Items ) > 0 {
439+ text += "\n \n Items:"
440+ for _ , item := range data .Items {
441+ text += fmt .Sprintf ("\n • %s (x%v) - %s" , item .Display , item .Quantity , item .Subtotal )
442+ }
455443 }
456444
457- if data .ExpiresAt != "" {
458- text += fmt .Sprintf ("\n Expires : %s" , data .ExpiresAt )
445+ if data .Reason != "" {
446+ text += fmt .Sprintf ("\n \n Reason : %s" , data .Reason )
459447 }
460448
461449 return SlackMessage {Text : text }
0 commit comments