|
| 1 | +package slack |
| 2 | + |
| 3 | +import ( |
| 4 | + "fmt" |
| 5 | + |
| 6 | + "github.com/tomba-io/go/tomba/models" |
| 7 | +) |
| 8 | + |
| 9 | +// FinderResponse |
| 10 | +func FinderResponse(data models.Finder) Model { |
| 11 | + email := data.Data.Email |
| 12 | + fields := make([]Text, 0, 5) |
| 13 | + |
| 14 | + fields = append(fields, Text{ |
| 15 | + Type: "mrkdwn", |
| 16 | + Text: fmt.Sprintf("\n\n*Name*\n\n %s \n\n", data.Data.FullName), |
| 17 | + }, Text{ |
| 18 | + Type: "mrkdwn", |
| 19 | + Text: fmt.Sprintf("\n\n*Email*\n\n %s \n\n", email), |
| 20 | + }) |
| 21 | + |
| 22 | + if data.Data.Position != "" { |
| 23 | + fields = append(fields, Text{ |
| 24 | + Type: "mrkdwn", |
| 25 | + Text: fmt.Sprintf("\n\n*Bio*\n\n %s at %s \n\n", data.Data.Position, data.Data.Company), |
| 26 | + }) |
| 27 | + } |
| 28 | + |
| 29 | + if data.Data.Country != "" { |
| 30 | + fields = append(fields, Text{ |
| 31 | + Type: "mrkdwn", |
| 32 | + Text: fmt.Sprintf("\n\n*Location*\n\n %s \n\n", data.Data.Country), |
| 33 | + }) |
| 34 | + } |
| 35 | + |
| 36 | + if data.Data.Linkedin != "" { |
| 37 | + fields = append(fields, Text{ |
| 38 | + Type: "mrkdwn", |
| 39 | + Text: fmt.Sprintf("\n\n*Linkedin*\n\n %s \n\n", data.Data.Linkedin), |
| 40 | + }) |
| 41 | + } |
| 42 | + |
| 43 | + if data.Data.Twitter != nil { |
| 44 | + fields = append(fields, Text{ |
| 45 | + Type: "mrkdwn", |
| 46 | + Text: fmt.Sprintf("\n\n*Twitter*\n\n %s \n\n", data.Data.Twitter), |
| 47 | + }) |
| 48 | + } |
| 49 | + |
| 50 | + sources := "" |
| 51 | + if len(data.Data.Sources) > 0 { |
| 52 | + for i := 0; i < len(data.Data.Sources); i++ { |
| 53 | + sources += data.Data.Sources[i].URI + "\n" |
| 54 | + } |
| 55 | + } |
| 56 | + |
| 57 | + return Model{ |
| 58 | + Attachments: []Attachment{ |
| 59 | + { |
| 60 | + Color: "#3f77e8", |
| 61 | + Blocks: []Block{ |
| 62 | + { |
| 63 | + Type: "section", |
| 64 | + Text: Text{ |
| 65 | + Type: "mrkdwn", |
| 66 | + Text: fmt.Sprintf("Email *%s* \n\n<https://app.tomba.io/|Tomba web app>\n\n", email), |
| 67 | + }, |
| 68 | + Fields: fields, |
| 69 | + }, |
| 70 | + { |
| 71 | + Type: "divider", |
| 72 | + }, |
| 73 | + { |
| 74 | + Type: "section", |
| 75 | + Text: Text{ |
| 76 | + Type: "mrkdwn", |
| 77 | + Text: fmt.Sprintf("We found `%d` sources for *%s* on the web.\n %s", len(data.Data.Sources), email, sources), |
| 78 | + }, |
| 79 | + }, |
| 80 | + { |
| 81 | + Type: "divider", |
| 82 | + }, |
| 83 | + }, |
| 84 | + }, |
| 85 | + }, |
| 86 | + } |
| 87 | +} |
| 88 | + |
| 89 | +// SearchResponse |
| 90 | +func SearchResponse(data models.Search) []Model { |
| 91 | + |
| 92 | + attachment := make([]Attachment, 0, 5) |
| 93 | + emails := data.Data.Emails |
| 94 | + for i := 0; i < len(emails); i++ { |
| 95 | + attachment = append(attachment, Attachment{ |
| 96 | + Color: "", |
| 97 | + Blocks: []Block{}, |
| 98 | + }) |
| 99 | + } |
| 100 | + |
| 101 | + return []Model{ |
| 102 | + { |
| 103 | + Attachments: []Attachment{}, |
| 104 | + }, |
| 105 | + } |
| 106 | +} |
| 107 | + |
| 108 | +// VerifyResponse |
| 109 | +func VerifyResponse(data models.Verifier) Model { |
| 110 | + return Model{} |
| 111 | +} |
0 commit comments