Project

General

Profile

Actions

Example maingo

package main

import (
	"fmt"
	"html/template"
	"os"
	"path/filepath"

	notification "github.com/finansiaportal/ico-api/test/services/notification"
)

func main() {
	data := notification.NotificationTemplateData{
		Lang:           "th",
		Subject:        "ยืนยันการจองซื้อ - Finansia Portal",
		HeaderTitle:    "FINANSIA PORTAL",
		GreetingPrefix: "เรียน",
		CustomerName:   "คุณสมมติ ทดสอบ",
		Contents: []template.HTML{
			"บริษัท Finansia Portal จำกัด มีความยินดีที่ได้รับคำสั่งจองซื้อจากท่าน",
			"โปรดตรวจสอบรายละเอียดการจองซื้อด้านล่าง และกดปุ่ม <strong>\"ยืนยัน\"</strong> เพื่อดำเนินการให้เสร็จสมบูรณ์",
			"หากท่านมีคำถามหรือข้อสงสัยใด ๆ กรุณาติดต่อฝ่ายบริการลูกค้าของเราได้ตลอดเวลา",
		},
		TableRows: []notification.NotificationTableRow{
			{Label: "ชื่อโครงการ:", Value: "TEST"},
			{Label: "จำนวนที่จองซื้อ:", Value: "1,000,000 หน่วย"},
			{Label: "ราคาต่อหน่วย:", Value: "1 THB"},
			{Label: "ยอดชำระสุทธิ:", Value: "1,000,000 THB"},
		},
		WarningTitle:   "คำเตือน:",
		WarningMessage: "รายการจองซื้อนี้จะหมดอายุโดยอัตโนมัติภายใน 24 ชั่วโมง",
		ButtonText:     "ยืนยันการจองซื้อ",
		ActionURL:      "#",
		Note:           "*หากท่านไม่ได้เป็นผู้ทำรายการ หรือพบข้อมูลไม่ถูกต้อง โปรดติดต่อเจ้าหน้าที่โดยด่วน",
		FooterCompany:  "บริษัท Finansia Portal จำกัด",
		FooterAddress:  "48/48 Tisco Tower, 20th Floor, North Sathorn Road, Silom Sub-district, Bang Rak District, Bangkok 10500",
		FooterContact:  "อีเมล: support@finansiaportal.com | โทร: 02 118 0346",
	}
	templatePath := filepath.Join("test", "templates", "enNotification.html")
	outputPath := filepath.Join("test", "test.html")

	html, err := data.RenderHTML(templatePath)
	if err != nil {
		fmt.Printf("render failed: %v\n", err)
		return
	}

	if err := os.WriteFile(outputPath, []byte(html), 0644); err != nil {
		fmt.Printf("write failed: %v\n", err)
		return
	}

	fmt.Printf("saved rendered html to %s\n", outputPath)
}

Updated by karnake ruengchaicharnkij 9 days ago · 1 revisions