Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions message/location.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package message

// Location represents a WhatsApp location message.
// See: https://developers.facebook.com/documentation/business-messaging/whatsapp/messages/location-messages/
type Location struct {
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
Name *string `json:"name,omitempty"`
Address *string `json:"address,omitempty"`
}

// NewLocationOpts for creating a new location message.
type NewLocationOpts struct {
Latitude float64
Longitude float64
Name *string
Address *string
}

// NewLocation creates a new WhatsApp location message.
func NewLocation(to string, opts NewLocationOpts) Envelope {
return Envelope{
MessagingProduct: "whatsapp",
RecipientType: "individual",
To: to,
Type: "location",
Location: &Location{
Latitude: opts.Latitude,
Longitude: opts.Longitude,
Name: opts.Name,
Address: opts.Address,
},
}
}
1 change: 1 addition & 0 deletions message/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type Envelope struct {
Interactive *Interactive `json:"interactive,omitempty"`
Document *Document `json:"document,omitempty"`
Sticker *Sticker `json:"sticker,omitempty"`
Location *Location `json:"location,omitempty"`
Status string `json:"status,omitempty"`
TypingIndicator *TypingIndicator `json:"typing_indicator,omitempty"`
MessageID string `json:"message_id,omitempty"`
Expand Down
8 changes: 8 additions & 0 deletions webhook/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type Message struct {
Context *Context `json:"context"`
Text Text `json:"text"`
Interactive Interactive `json:"interactive"`
Location Location `json:"location"`
}

type Text struct {
Expand All @@ -56,6 +57,13 @@ type Interactive struct {
ButtonReply *ButtonReply `json:"button_reply,omitempty"`
}

type Location struct {
Address string `json:"address"`
Latitude string `json:"latitude"`
Longitude string `json:"longitude"`
Name string `json:"name"`
}

type NfmReply struct {
Name string `json:"name"`
ResponseJson string `json:"response_json"`
Expand Down
Loading