Skip to content

Commit

Permalink
Merge pull request #22 from kkdai/change_phone
Browse files Browse the repository at this point in the history
refactor: modify 'Phone' field in specific functions and struct
  • Loading branch information
kkdai authored Jan 30, 2024
2 parents 3ed37dc + 301b23e commit eea95d4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
12 changes: 6 additions & 6 deletions bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

// Const variables of Prompts.
const ImagePrompt = "這是一張名片,你是一個名片秘書。請將以下資訊整理成 json 給我。如果看不出來的,幫我填寫 N/A, 只好 json 就好: Name, Title, Address, Email, Phone Number, Company"
const ImagePrompt = "這是一張名片,你是一個名片秘書。請將以下資訊整理成 json 給我。如果看不出來的,幫我填寫 N/A, 只好 json 就好: Name, Title, Address, Email, Phone, Company"

// replyText: Reply text message to LINE server.
func replyText(replyToken, text string) error {
Expand Down Expand Up @@ -61,11 +61,11 @@ func callbackHandler(w http.ResponseWriter, r *http.Request) {
if message.Text == "test" {
cards := []Person{
{
Name: "test",
Title: "test",
Address: "test",
Email: "test",
PhoneNumber: "test",
Name: "test",
Title: "test",
Address: "test",
Email: "test",
Phone: "test",
},
}
if err := SendFlexMsg(e.ReplyToken, cards, "test card"); err != nil {
Expand Down
6 changes: 3 additions & 3 deletions flex.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func getSingleCard(card Person) messaging_api.FlexBubble {
Text: card.Email,
},
&messaging_api.FlexText{
Text: card.PhoneNumber,
Text: card.Phone,
},
},
},
Expand Down Expand Up @@ -191,9 +191,9 @@ func getNewSingleCard(card Person) messaging_api.FlexBubble {
&messaging_api.FlexText{
Align: "end",
Margin: "xxl",
Text: card.PhoneNumber,
Text: card.Phone,
Action: &messaging_api.UriAction{
Uri: "tel:" + card.PhoneNumber,
Uri: "tel:" + card.Phone,
},
},
&messaging_api.FlexText{
Expand Down
20 changes: 10 additions & 10 deletions notion.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import (

// Person 定義了 JSON 資料的結構體
type Person struct {
Name string `json:"name"`
Title string `json:"title"`
Address string `json:"address"`
Email string `json:"email"`
PhoneNumber string `json:"phone_number"`
Company string `json:"company"`
Name string `json:"name"`
Title string `json:"title"`
Address string `json:"address"`
Email string `json:"email"`
Phone string `json:"phone"`
Company string `json:"company"`
}

// DatabaseEntry 定義了 Notion 資料庫條目的結構體。
Expand Down Expand Up @@ -139,11 +139,11 @@ func (n *NotionDB) AddPageToDatabase(person Person) error {
},
},
},
"Phone Number": notionapi.RichTextProperty{
"Phone": notionapi.RichTextProperty{
RichText: []notionapi.RichText{
{
PlainText: person.PhoneNumber,
Text: &notionapi.Text{Content: person.PhoneNumber},
PlainText: person.Phone,
Text: &notionapi.Text{Content: person.Phone},
},
},
},
Expand Down Expand Up @@ -184,7 +184,7 @@ func (n *NotionDB) createEntryFromPage(page *notionapi.Page) Person {
entry.Title = n.getPropertyValue(page, "Title")
entry.Address = n.getPropertyValue(page, "Address")
entry.Email = n.getPropertyValue(page, "Email")
entry.PhoneNumber = n.getPropertyValue(page, "Phone Number")
entry.Phone = n.getPropertyValue(page, "Phone Number")
entry.Company = n.getPropertyValue(page, "Company")

return entry
Expand Down
2 changes: 1 addition & 1 deletion notion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestAddNotionDB(t *testing.T) {
UID: "uid",
}

err := db.AddPageToDatabase(Person{Name: "test", Title: "test", Address: "test", Email: "test", PhoneNumber: "test", Company: "test"})
err := db.AddPageToDatabase(Person{Name: "test", Title: "test", Address: "test", Email: "test", Phone: "test", Company: "test"})
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit eea95d4

Please sign in to comment.