Commit from GitHub Actions (Generate Clients & Examples)

This commit is contained in:
asim
2021-11-03 14:46:11 +00:00
parent 8827af19f5
commit 4234070dd0
12 changed files with 162 additions and 25 deletions

View File

@@ -0,0 +1,4 @@
curl "https://api.m3o.com/v1/stream/ListChannels" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $MICRO_API_TOKEN" \
-d '{}'

View File

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

View File

@@ -0,0 +1,10 @@
const { StreamService } = require("m3o/stream");
// List all the active channels
async function listChannels() {
let streamService = new StreamService(process.env.MICRO_API_TOKEN);
let rsp = await streamService.listChannels({});
console.log(rsp);
}
listChannels();

View File

@@ -0,0 +1,6 @@
curl "https://api.m3o.com/v1/stream/ListMessages" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $MICRO_API_TOKEN" \
-d '{
"channel": "general"
}'

View File

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

View File

@@ -0,0 +1,12 @@
const { StreamService } = require("m3o/stream");
// List messages for a given channel
async function listMessages() {
let streamService = new StreamService(process.env.MICRO_API_TOKEN);
let rsp = await streamService.listMessages({
channel: "general",
});
console.log(rsp);
}
listMessages();

View File

@@ -0,0 +1,7 @@
curl "https://api.m3o.com/v1/stream/SendMessage" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $MICRO_API_TOKEN" \
-d '{
"channel": "general",
"text": "Hey checkout this tweet https://twitter.com/m3oservices/status/1455291054295498752"
}'

View File

@@ -0,0 +1,18 @@
package example
import (
"fmt"
"os"
"github.com/micro/services/clients/go/stream"
)
// SendMessage a message to the stream.
func SendAmessage() {
streamService := stream.NewStreamService(os.Getenv("MICRO_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)
}

View File

@@ -0,0 +1,13 @@
const { StreamService } = require("m3o/stream");
// SendMessage a message to the stream.
async function sendAmessage() {
let streamService = new StreamService(process.env.MICRO_API_TOKEN);
let rsp = await streamService.sendMessage({
channel: "general",
text: "Hey checkout this tweet https://twitter.com/m3oservices/status/1455291054295498752",
});
console.log(rsp);
}
sendAmessage();