From 30673f98377a04c728b38406e72f1abfbbc2c0c2 Mon Sep 17 00:00:00 2001 From: asim Date: Mon, 25 Oct 2021 10:42:12 +0000 Subject: [PATCH] Commit from GitHub Actions (Publish APIs & Clients) --- clients/go/m3o.go | 3 + clients/go/youtube/youtube.go | 55 +++++++++++++++++++ clients/ts/.gitignore | 1 + clients/ts/index.ts | 3 + clients/ts/package.json | 5 +- examples/db/create/go/createARecord.go | 2 +- .../youtube/search/curl/searchForVideos.sh | 6 ++ examples/youtube/search/go/searchForVideos.go | 17 ++++++ .../youtube/search/node/searchForVideos.js | 12 ++++ go.mod | 5 -- 10 files changed, 101 insertions(+), 8 deletions(-) create mode 100755 clients/go/youtube/youtube.go create mode 100755 examples/youtube/search/curl/searchForVideos.sh create mode 100755 examples/youtube/search/go/searchForVideos.go create mode 100755 examples/youtube/search/node/searchForVideos.js diff --git a/clients/go/m3o.go b/clients/go/m3o.go index 422499d..faa618d 100755 --- a/clients/go/m3o.go +++ b/clients/go/m3o.go @@ -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 } diff --git a/clients/go/youtube/youtube.go b/clients/go/youtube/youtube.go new file mode 100755 index 0000000..bda38af --- /dev/null +++ b/clients/go/youtube/youtube.go @@ -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"` +} diff --git a/clients/ts/.gitignore b/clients/ts/.gitignore index ebae490..89abeec 100644 --- a/clients/ts/.gitignore +++ b/clients/ts/.gitignore @@ -52,3 +52,4 @@ url user vehicle weather +youtube diff --git a/clients/ts/index.ts b/clients/ts/index.ts index 11543a8..3a6faa7 100755 --- a/clients/ts/index.ts +++ b/clients/ts/index.ts @@ -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; } diff --git a/clients/ts/package.json b/clients/ts/package.json index 4f27fb0..a54f203 100644 --- a/clients/ts/package.json +++ b/clients/ts/package.json @@ -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" } \ No newline at end of file diff --git a/examples/db/create/go/createARecord.go b/examples/db/create/go/createARecord.go index 003184c..283dd5d 100755 --- a/examples/db/create/go/createARecord.go +++ b/examples/db/create/go/createARecord.go @@ -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", }) diff --git a/examples/youtube/search/curl/searchForVideos.sh b/examples/youtube/search/curl/searchForVideos.sh new file mode 100755 index 0000000..afe742c --- /dev/null +++ b/examples/youtube/search/curl/searchForVideos.sh @@ -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" +}' \ No newline at end of file diff --git a/examples/youtube/search/go/searchForVideos.go b/examples/youtube/search/go/searchForVideos.go new file mode 100755 index 0000000..a4cfe0c --- /dev/null +++ b/examples/youtube/search/go/searchForVideos.go @@ -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) +} diff --git a/examples/youtube/search/node/searchForVideos.js b/examples/youtube/search/node/searchForVideos.js new file mode 100755 index 0000000..c508ebf --- /dev/null +++ b/examples/youtube/search/node/searchForVideos.js @@ -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(); diff --git a/go.mod b/go.mod index 6383175..eea7d83 100644 --- a/go.mod +++ b/go.mod @@ -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 ) -