Commit from GitHub Actions (Publish APIs & Clients)

This commit is contained in:
asim
2021-10-25 10:42:12 +00:00
parent 55464e8104
commit 30673f9837
10 changed files with 101 additions and 8 deletions

View File

@@ -40,6 +40,7 @@ import (
"github.com/micro/services/clients/go/user"
"github.com/micro/services/clients/go/vehicle"
"github.com/micro/services/clients/go/weather"
"github.com/micro/services/clients/go/youtube"
)
func NewClient(token string) *Client {
@@ -85,6 +86,7 @@ func NewClient(token string) *Client {
UserService: user.NewUserService(token),
VehicleService: vehicle.NewVehicleService(token),
WeatherService: weather.NewWeatherService(token),
YoutubeService: youtube.NewYoutubeService(token),
}
}
@@ -130,4 +132,5 @@ type Client struct {
UserService *user.UserService
VehicleService *vehicle.VehicleService
WeatherService *weather.WeatherService
YoutubeService *youtube.YoutubeService
}

55
clients/go/youtube/youtube.go Executable file
View File

@@ -0,0 +1,55 @@
package youtube
import (
"github.com/m3o/m3o-go/client"
)
func NewYoutubeService(token string) *YoutubeService {
return &YoutubeService{
client: client.NewClient(&client.Options{
Token: token,
}),
}
}
type YoutubeService struct {
client *client.Client
}
// Search for videos on YouTube
func (t *YoutubeService) Search(request *SearchRequest) (*SearchResponse, error) {
rsp := &SearchResponse{}
return rsp, t.client.Call("youtube", "Search", request, rsp)
}
type SearchRequest struct {
// Query to search for
Query string `json:"query"`
}
type SearchResponse struct {
// List of results for the query
Results []SearchResult `json:"results"`
}
type SearchResult struct {
// if live broadcast then indicates activity.
// none, upcoming, live, completed
Broadcasting string `json:"broadcasting"`
// the channel id
ChannelId string `json:"channelId"`
// the channel title
ChannelTitle string `json:"channelTitle"`
// the result description
Description string `json:"description"`
// id of the result
Id string `json:"id"`
// kind of result; "video", "channel", "playlist"
Kind string `json:"kind"`
// published at time
PublishedAt string `json:"publishedAt"`
// title of the result
Title string `json:"title"`
// the associated url
Url string `json:"url"`
}

View File

@@ -52,3 +52,4 @@ url
user
vehicle
weather
youtube

View File

@@ -37,6 +37,7 @@ import * as url from "./url";
import * as user from "./user";
import * as vehicle from "./vehicle";
import * as weather from "./weather";
import * as youtube from "./youtube";
export class Client {
constructor(token: string) {
@@ -79,6 +80,7 @@ export class Client {
this.userService = new user.UserService(token);
this.vehicleService = new vehicle.VehicleService(token);
this.weatherService = new weather.WeatherService(token);
this.youtubeService = new youtube.YoutubeService(token);
}
addressService: address.AddressService;
@@ -120,4 +122,5 @@ export class Client {
userService: user.UserService;
vehicleService: vehicle.VehicleService;
weatherService: weather.WeatherService;
youtubeService: youtube.YoutubeService;
}

View File

@@ -58,7 +58,8 @@
"url",
"user",
"vehicle",
"weather"
"weather",
"youtube"
],
"license": "ISC",
"main": "index.js",
@@ -74,5 +75,5 @@
"prepare": "npm run build"
},
"types": "index.d.ts",
"version": "1.0.559"
"version": "1.0.560"
}

View File

@@ -12,10 +12,10 @@ func CreateArecord() {
dbService := db.NewDbService(os.Getenv("MICRO_API_TOKEN"))
rsp, err := dbService.Create(&db.CreateRequest{
Record: map[string]interface{}{
"id": "1",
"name": "Jane",
"age": 42,
"isActive": true,
"id": "1",
},
Table: "users",
})

View File

@@ -0,0 +1,6 @@
curl "https://api.m3o.com/v1/youtube/Search" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $MICRO_API_TOKEN" \
-d '{
"query": "donuts"
}'

View File

@@ -0,0 +1,17 @@
package example
import (
"fmt"
"os"
"github.com/micro/services/clients/go/youtube"
)
// Search for videos on YouTube
func SearchForVideos() {
youtubeService := youtube.NewYoutubeService(os.Getenv("MICRO_API_TOKEN"))
rsp, err := youtubeService.Search(&youtube.SearchRequest{
Query: "donuts",
})
fmt.Println(rsp, err)
}

View File

@@ -0,0 +1,12 @@
const { YoutubeService } = require("m3o/youtube");
// Search for videos on YouTube
async function searchForVideos() {
let youtubeService = new YoutubeService(process.env.MICRO_API_TOKEN);
let rsp = await youtubeService.search({
query: "donuts",
});
console.log(rsp);
}
searchForVideos();

5
go.mod
View File

@@ -18,8 +18,6 @@ require (
github.com/getkin/kin-openapi v0.26.0
github.com/gojuno/go.osrm v0.1.1-0.20200217151037-435fc3e1d3d4
github.com/golang/protobuf v1.5.2
github.com/golang/snappy v0.0.3 // indirect
github.com/google/go-cmp v0.5.6 // indirect
github.com/google/uuid v1.1.2
github.com/hablullah/go-prayer v1.0.0
github.com/hailocab/go-geoindex v0.0.0-20160127134810-64631bfe9711
@@ -51,12 +49,10 @@ require (
github.com/ttacon/builder v0.0.0-20170518171403-c099f663e1c2 // indirect
github.com/ttacon/libphonenumber v1.2.1 // indirect
go.mongodb.org/mongo-driver v1.7.2
go.opencensus.io v0.23.0 // indirect
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2
golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420
golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1
google.golang.org/api v0.59.0
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.27.1
googlemaps.github.io/maps v1.3.1
gopkg.in/yaml.v2 v2.3.0
@@ -65,4 +61,3 @@ require (
gorm.io/driver/postgres v1.0.8
gorm.io/gorm v1.21.10
)