Commit from m3o/m3o action

This commit is contained in:
m3o-actions
2021-11-03 15:16:55 +00:00
parent a3f66cea0b
commit aecab5372c
22 changed files with 679 additions and 471 deletions

View File

@@ -4,12 +4,12 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Stream/api](ht
Endpoints:
## Publish
## SendMessage
Publish a message to the stream. Specify a topic to group messages for a specific topic.
SendMessage a message to the stream.
[https://m3o.com/stream/api#Publish](https://m3o.com/stream/api#Publish)
[https://m3o.com/stream/api#SendMessage](https://m3o.com/stream/api#SendMessage)
```go
package example
@@ -21,27 +21,23 @@ import(
"go.m3o.com/stream"
)
// Publish a message to the stream. Specify a topic to group messages for a specific topic.
func PublishAmessage() {
// SendMessage a message to the stream.
func SendAmessage() {
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
rsp, err := streamService.Publish(&stream.PublishRequest{
Message: map[string]interface{}{
"user": "john",
"id": "1",
"type": "signup",
},
Topic: "events",
rsp, err := streamService.SendMessage(&stream.SendMessageRequest{
Channel: "general",
Text: "Hey checkout this tweet https://twitter.com/m3oservices/status/1455291054295498752",
})
fmt.Println(rsp, err)
}
```
## Subscribe
## ListMessages
Subscribe to messages for a given topic.
List messages for a given channel
[https://m3o.com/stream/api#Subscribe](https://m3o.com/stream/api#Subscribe)
[https://m3o.com/stream/api#ListMessages](https://m3o.com/stream/api#ListMessages)
```go
package example
@@ -53,13 +49,39 @@ import(
"go.m3o.com/stream"
)
// Subscribe to messages for a given topic.
func SubscribeToAtopic() {
// List messages for a given channel
func ListMessages() {
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
rsp, err := streamService.Subscribe(&stream.SubscribeRequest{
Topic: "events",
rsp, err := streamService.ListMessages(&stream.ListMessagesRequest{
Channel: "general",
})
fmt.Println(rsp, err)
}
```
## ListChannels
List all the active channels
[https://m3o.com/stream/api#ListChannels](https://m3o.com/stream/api#ListChannels)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/stream"
)
// List all the active channels
func ListChannels() {
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
rsp, err := streamService.ListChannels(&stream.ListChannelsRequest{
})
fmt.Println(rsp, err)
}
```

View File

@@ -0,0 +1,15 @@
package example
import (
"fmt"
"os"
"go.m3o.com/stream"
)
// List all the active channels
func ListChannels() {
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
rsp, err := streamService.ListChannels(&stream.ListChannelsRequest{})
fmt.Println(rsp, err)
}

View File

@@ -0,0 +1,17 @@
package example
import (
"fmt"
"os"
"go.m3o.com/stream"
)
// List messages for a given channel
func ListMessages() {
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
rsp, err := streamService.ListMessages(&stream.ListMessagesRequest{
Channel: "general",
})
fmt.Println(rsp, err)
}

View File

@@ -0,0 +1,18 @@
package example
import (
"fmt"
"os"
"go.m3o.com/stream"
)
// SendMessage a message to the stream.
func SendAmessage() {
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
rsp, err := streamService.SendMessage(&stream.SendMessageRequest{
Channel: "general",
Text: "Hey checkout this tweet https://twitter.com/m3oservices/status/1455291054295498752",
})
fmt.Println(rsp, err)
}