mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-19 14:05:23 +00:00
Commit from GitHub Actions (Generate Clients & Examples)
This commit is contained in:
@@ -34,6 +34,7 @@ import (
|
||||
"github.com/micro/services/clients/go/rss"
|
||||
"github.com/micro/services/clients/go/sentiment"
|
||||
"github.com/micro/services/clients/go/sms"
|
||||
"github.com/micro/services/clients/go/spam"
|
||||
"github.com/micro/services/clients/go/stock"
|
||||
"github.com/micro/services/clients/go/stream"
|
||||
"github.com/micro/services/clients/go/sunnah"
|
||||
@@ -84,6 +85,7 @@ func NewClient(token string) *Client {
|
||||
RssService: rss.NewRssService(token),
|
||||
SentimentService: sentiment.NewSentimentService(token),
|
||||
SmsService: sms.NewSmsService(token),
|
||||
SpamService: spam.NewSpamService(token),
|
||||
StockService: stock.NewStockService(token),
|
||||
StreamService: stream.NewStreamService(token),
|
||||
SunnahService: sunnah.NewSunnahService(token),
|
||||
@@ -134,6 +136,7 @@ type Client struct {
|
||||
RssService *rss.RssService
|
||||
SentimentService *sentiment.SentimentService
|
||||
SmsService *sms.SmsService
|
||||
SpamService *spam.SpamService
|
||||
StockService *stock.StockService
|
||||
StreamService *stream.StreamService
|
||||
SunnahService *sunnah.SunnahService
|
||||
|
||||
43
clients/go/spam/spam.go
Executable file
43
clients/go/spam/spam.go
Executable file
@@ -0,0 +1,43 @@
|
||||
package spam
|
||||
|
||||
import (
|
||||
"github.com/micro/micro-go/client"
|
||||
)
|
||||
|
||||
func NewSpamService(token string) *SpamService {
|
||||
return &SpamService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type SpamService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Check whether an email is likely to be spam based on its attributes
|
||||
func (t *SpamService) Classify(request *ClassifyRequest) (*ClassifyResponse, error) {
|
||||
rsp := &ClassifyResponse{}
|
||||
return rsp, t.client.Call("spam", "Classify", request, rsp)
|
||||
}
|
||||
|
||||
type ClassifyRequest struct {
|
||||
// The body of the email
|
||||
EmailBody string `json:"emailBody"`
|
||||
// The email address it has been sent from
|
||||
From string `json:"from"`
|
||||
// The subject of the email
|
||||
Subject string `json:"subject"`
|
||||
// The email address it is being sent to
|
||||
To string `json:"to"`
|
||||
}
|
||||
|
||||
type ClassifyResponse struct {
|
||||
// The rules that have contributed to this score
|
||||
Details []string `json:"details"`
|
||||
// Is it spam? Returns true if its score is > 5
|
||||
IsSpam bool `json:"isSpam"`
|
||||
// The score evaluated for this email. A higher number means it is more likely to be spam
|
||||
Score float64 `json:"score"`
|
||||
}
|
||||
Reference in New Issue
Block a user