mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-20 22:45:09 +00:00
Commit from GitHub Actions (Generate Clients & Examples)
This commit is contained in:
53
clients/go/event/event.go
Executable file
53
clients/go/event/event.go
Executable file
@@ -0,0 +1,53 @@
|
||||
package event
|
||||
|
||||
import (
|
||||
"github.com/m3o/m3o-go/client"
|
||||
)
|
||||
|
||||
func NewEventService(token string) *EventService {
|
||||
return &EventService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type EventService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Publish a message to the event. Specify a topic to group messages for a specific topic.
|
||||
func (t *EventService) Publish(request *PublishRequest) (*PublishResponse, error) {
|
||||
rsp := &PublishResponse{}
|
||||
return rsp, t.client.Call("event", "Publish", request, rsp)
|
||||
}
|
||||
|
||||
// Subscribe to messages for a given topic.
|
||||
func (t *EventService) Subscribe(request *SubscribeRequest) (*SubscribeResponse, error) {
|
||||
rsp := &SubscribeResponse{}
|
||||
return rsp, t.client.Call("event", "Subscribe", request, rsp)
|
||||
}
|
||||
|
||||
type PublishRequest struct {
|
||||
// The json message to publish
|
||||
Message map[string]interface{} `json:"message"`
|
||||
// The topic to publish to
|
||||
Topic string `json:"topic"`
|
||||
}
|
||||
|
||||
type PublishResponse struct {
|
||||
}
|
||||
|
||||
type SubscribeRequest struct {
|
||||
// Optional group for the subscription
|
||||
Group string `json:"group"`
|
||||
// The topic to subscribe to
|
||||
Topic string `json:"topic"`
|
||||
}
|
||||
|
||||
type SubscribeResponse struct {
|
||||
// The next json message on the topic
|
||||
Message map[string]interface{} `json:"message"`
|
||||
// The topic subscribed to
|
||||
Topic string `json:"topic"`
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/micro/services/clients/go/email"
|
||||
"github.com/micro/services/clients/go/emoji"
|
||||
"github.com/micro/services/clients/go/evchargers"
|
||||
"github.com/micro/services/clients/go/event"
|
||||
"github.com/micro/services/clients/go/file"
|
||||
"github.com/micro/services/clients/go/forex"
|
||||
"github.com/micro/services/clients/go/function"
|
||||
@@ -58,6 +59,7 @@ func NewClient(token string) *Client {
|
||||
EmailService: email.NewEmailService(token),
|
||||
EmojiService: emoji.NewEmojiService(token),
|
||||
EvchargersService: evchargers.NewEvchargersService(token),
|
||||
EventService: event.NewEventService(token),
|
||||
FileService: file.NewFileService(token),
|
||||
ForexService: forex.NewForexService(token),
|
||||
FunctionService: function.NewFunctionService(token),
|
||||
@@ -106,6 +108,7 @@ type Client struct {
|
||||
EmailService *email.EmailService
|
||||
EmojiService *emoji.EmojiService
|
||||
EvchargersService *evchargers.EvchargersService
|
||||
EventService *event.EventService
|
||||
FileService *file.FileService
|
||||
ForexService *forex.ForexService
|
||||
FunctionService *function.FunctionService
|
||||
|
||||
@@ -28,7 +28,7 @@ func (t *NotesService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
||||
return rsp, t.client.Call("notes", "Delete", request, rsp)
|
||||
}
|
||||
|
||||
// Specify the note to events
|
||||
// Subscribe to notes events
|
||||
func (t *NotesService) Events(request *EventsRequest) (*EventsResponse, error) {
|
||||
rsp := &EventsResponse{}
|
||||
return rsp, t.client.Call("notes", "Events", request, rsp)
|
||||
|
||||
Reference in New Issue
Block a user