-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from a-company-jp/invoke-endpoint
Invoke Endpointの追加
- Loading branch information
Showing
5 changed files
with
49 additions
and
260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package handler | ||
|
||
import ( | ||
"cloud.google.com/go/firestore" | ||
"fmt" | ||
"github.com/gin-gonic/gin" | ||
"log/slog" | ||
"time" | ||
) | ||
|
||
type CallInvoke struct { | ||
fs *firestore.Client | ||
} | ||
|
||
func NewInvokeHandler( | ||
fs *firestore.Client, | ||
) *CallInvoke { | ||
return &CallInvoke{ | ||
fs: fs, | ||
} | ||
} | ||
|
||
func (h *CallInvoke) Handle(c *gin.Context) { | ||
// get time | ||
timeVal := fmt.Sprintf("%2d:%2d", time.Now().Hour(), 0) | ||
res := h.fs.Collection("users").Where("call_time", "==", timeVal).Documents(c) | ||
if res == nil { | ||
c.JSON(400, gin.H{"error": "no data"}) | ||
return | ||
} | ||
for { | ||
doc, err := res.Next() | ||
if err != nil { | ||
break | ||
} | ||
userdata := doc.Data() | ||
slog.Info("invoke call on user", slog.Any("data", userdata)) | ||
|
||
// vonage callを発火 | ||
} | ||
c.JSON(200, gin.H{ | ||
"message": "success", | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.