From c6debbaf8ab23f55baed933ae0f5477e2cecd72a Mon Sep 17 00:00:00 2001 From: asim Date: Mon, 25 Oct 2021 11:21:28 +0000 Subject: [PATCH] Commit from GitHub Actions (Publish APIs & Clients) --- clients/go/google/google.go | 48 +++++++++++++++++++ clients/go/m3o.go | 3 ++ clients/ts/.gitignore | 1 + clients/ts/index.ts | 3 ++ clients/ts/package.json | 3 +- examples/db/update/go/updateARecord.go | 2 +- .../google/search/curl/searchForVideos.sh | 6 +++ examples/google/search/go/searchForVideos.go | 17 +++++++ .../google/search/node/searchForVideos.js | 12 +++++ 9 files changed, 93 insertions(+), 2 deletions(-) create mode 100755 clients/go/google/google.go create mode 100755 examples/google/search/curl/searchForVideos.sh create mode 100755 examples/google/search/go/searchForVideos.go create mode 100755 examples/google/search/node/searchForVideos.js diff --git a/clients/go/google/google.go b/clients/go/google/google.go new file mode 100755 index 0000000..6c05839 --- /dev/null +++ b/clients/go/google/google.go @@ -0,0 +1,48 @@ +package google + +import ( + "github.com/m3o/m3o-go/client" +) + +func NewGoogleService(token string) *GoogleService { + return &GoogleService{ + client: client.NewClient(&client.Options{ + Token: token, + }), + } +} + +type GoogleService struct { + client *client.Client +} + +// Search for videos on Google +func (t *GoogleService) Search(request *SearchRequest) (*SearchResponse, error) { + rsp := &SearchResponse{} + return rsp, t.client.Call("google", "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 { + // abridged version of this search result’s URL, e.g. www.exampe.com + DisplayUrl string `json:"displayUrl"` + // id of the result + Id string `json:"id"` + // kind of result; "search" + Kind string `json:"kind"` + // the result snippet + Snippet string `json:"snippet"` + // title of the result + Title string `json:"title"` + // the full url for the result + Url string `json:"url"` +} diff --git a/clients/go/m3o.go b/clients/go/m3o.go index faa618d..074a11d 100755 --- a/clients/go/m3o.go +++ b/clients/go/m3o.go @@ -14,6 +14,7 @@ import ( "github.com/micro/services/clients/go/forex" "github.com/micro/services/clients/go/function" "github.com/micro/services/clients/go/geocoding" + "github.com/micro/services/clients/go/google" "github.com/micro/services/clients/go/helloworld" "github.com/micro/services/clients/go/holidays" "github.com/micro/services/clients/go/id" @@ -60,6 +61,7 @@ func NewClient(token string) *Client { ForexService: forex.NewForexService(token), FunctionService: function.NewFunctionService(token), GeocodingService: geocoding.NewGeocodingService(token), + GoogleService: google.NewGoogleService(token), HelloworldService: helloworld.NewHelloworldService(token), HolidaysService: holidays.NewHolidaysService(token), IdService: id.NewIdService(token), @@ -106,6 +108,7 @@ type Client struct { ForexService *forex.ForexService FunctionService *function.FunctionService GeocodingService *geocoding.GeocodingService + GoogleService *google.GoogleService HelloworldService *helloworld.HelloworldService HolidaysService *holidays.HolidaysService IdService *id.IdService diff --git a/clients/ts/.gitignore b/clients/ts/.gitignore index 89abeec..9369303 100644 --- a/clients/ts/.gitignore +++ b/clients/ts/.gitignore @@ -24,6 +24,7 @@ forex function geocoding gifs +google helloworld holidays id diff --git a/clients/ts/index.ts b/clients/ts/index.ts index 3a6faa7..2c776ad 100755 --- a/clients/ts/index.ts +++ b/clients/ts/index.ts @@ -11,6 +11,7 @@ import * as file from "./file"; import * as forex from "./forex"; import * as fx from "./function"; import * as geocoding from "./geocoding"; +import * as google from "./google"; import * as helloworld from "./helloworld"; import * as holidays from "./holidays"; import * as id from "./id"; @@ -54,6 +55,7 @@ export class Client { this.forexService = new forex.ForexService(token); this.functionService = new fx.FunctionService(token); this.geocodingService = new geocoding.GeocodingService(token); + this.googleService = new google.GoogleService(token); this.helloworldService = new helloworld.HelloworldService(token); this.holidaysService = new holidays.HolidaysService(token); this.idService = new id.IdService(token); @@ -96,6 +98,7 @@ export class Client { forexService: forex.ForexService; functionService: fx.FunctionService; geocodingService: geocoding.GeocodingService; + googleService: google.GoogleService; helloworldService: helloworld.HelloworldService; holidaysService: holidays.HolidaysService; idService: id.IdService; diff --git a/clients/ts/package.json b/clients/ts/package.json index a54f203..df91551 100644 --- a/clients/ts/package.json +++ b/clients/ts/package.json @@ -31,6 +31,7 @@ "function", "geocoding", "gifs", + "google", "helloworld", "holidays", "id", @@ -75,5 +76,5 @@ "prepare": "npm run build" }, "types": "index.d.ts", - "version": "1.0.560" + "version": "1.0.561" } \ No newline at end of file diff --git a/examples/db/update/go/updateARecord.go b/examples/db/update/go/updateARecord.go index 4517043..1fb0e47 100755 --- a/examples/db/update/go/updateARecord.go +++ b/examples/db/update/go/updateARecord.go @@ -12,8 +12,8 @@ func UpdateArecord() { dbService := db.NewDbService(os.Getenv("MICRO_API_TOKEN")) rsp, err := dbService.Update(&db.UpdateRequest{ Record: map[string]interface{}{ - "id": "1", "age": 43, + "id": "1", }, Table: "users", }) diff --git a/examples/google/search/curl/searchForVideos.sh b/examples/google/search/curl/searchForVideos.sh new file mode 100755 index 0000000..1ab0545 --- /dev/null +++ b/examples/google/search/curl/searchForVideos.sh @@ -0,0 +1,6 @@ +curl "https://api.m3o.com/v1/google/Search" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "query": "how to make donuts" +}' \ No newline at end of file diff --git a/examples/google/search/go/searchForVideos.go b/examples/google/search/go/searchForVideos.go new file mode 100755 index 0000000..aef228a --- /dev/null +++ b/examples/google/search/go/searchForVideos.go @@ -0,0 +1,17 @@ +package example + +import ( + "fmt" + "os" + + "github.com/micro/services/clients/go/google" +) + +// Search for videos on Google +func SearchForVideos() { + googleService := google.NewGoogleService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := googleService.Search(&google.SearchRequest{ + Query: "how to make donuts", + }) + fmt.Println(rsp, err) +} diff --git a/examples/google/search/node/searchForVideos.js b/examples/google/search/node/searchForVideos.js new file mode 100755 index 0000000..61df983 --- /dev/null +++ b/examples/google/search/node/searchForVideos.js @@ -0,0 +1,12 @@ +const { GoogleService } = require("m3o/google"); + +// Search for videos on Google +async function searchForVideos() { + let googleService = new GoogleService(process.env.MICRO_API_TOKEN); + let rsp = await googleService.search({ + query: "how to make donuts", + }); + console.log(rsp); +} + +searchForVideos();