mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-18 13:45:09 +00:00
Commit from GitHub Actions (Publish APIs & Clients)
This commit is contained in:
48
clients/go/google/google.go
Executable file
48
clients/go/google/google.go
Executable file
@@ -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"`
|
||||||
|
}
|
||||||
@@ -14,6 +14,7 @@ import (
|
|||||||
"github.com/micro/services/clients/go/forex"
|
"github.com/micro/services/clients/go/forex"
|
||||||
"github.com/micro/services/clients/go/function"
|
"github.com/micro/services/clients/go/function"
|
||||||
"github.com/micro/services/clients/go/geocoding"
|
"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/helloworld"
|
||||||
"github.com/micro/services/clients/go/holidays"
|
"github.com/micro/services/clients/go/holidays"
|
||||||
"github.com/micro/services/clients/go/id"
|
"github.com/micro/services/clients/go/id"
|
||||||
@@ -60,6 +61,7 @@ func NewClient(token string) *Client {
|
|||||||
ForexService: forex.NewForexService(token),
|
ForexService: forex.NewForexService(token),
|
||||||
FunctionService: function.NewFunctionService(token),
|
FunctionService: function.NewFunctionService(token),
|
||||||
GeocodingService: geocoding.NewGeocodingService(token),
|
GeocodingService: geocoding.NewGeocodingService(token),
|
||||||
|
GoogleService: google.NewGoogleService(token),
|
||||||
HelloworldService: helloworld.NewHelloworldService(token),
|
HelloworldService: helloworld.NewHelloworldService(token),
|
||||||
HolidaysService: holidays.NewHolidaysService(token),
|
HolidaysService: holidays.NewHolidaysService(token),
|
||||||
IdService: id.NewIdService(token),
|
IdService: id.NewIdService(token),
|
||||||
@@ -106,6 +108,7 @@ type Client struct {
|
|||||||
ForexService *forex.ForexService
|
ForexService *forex.ForexService
|
||||||
FunctionService *function.FunctionService
|
FunctionService *function.FunctionService
|
||||||
GeocodingService *geocoding.GeocodingService
|
GeocodingService *geocoding.GeocodingService
|
||||||
|
GoogleService *google.GoogleService
|
||||||
HelloworldService *helloworld.HelloworldService
|
HelloworldService *helloworld.HelloworldService
|
||||||
HolidaysService *holidays.HolidaysService
|
HolidaysService *holidays.HolidaysService
|
||||||
IdService *id.IdService
|
IdService *id.IdService
|
||||||
|
|||||||
1
clients/ts/.gitignore
vendored
1
clients/ts/.gitignore
vendored
@@ -24,6 +24,7 @@ forex
|
|||||||
function
|
function
|
||||||
geocoding
|
geocoding
|
||||||
gifs
|
gifs
|
||||||
|
google
|
||||||
helloworld
|
helloworld
|
||||||
holidays
|
holidays
|
||||||
id
|
id
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import * as file from "./file";
|
|||||||
import * as forex from "./forex";
|
import * as forex from "./forex";
|
||||||
import * as fx from "./function";
|
import * as fx from "./function";
|
||||||
import * as geocoding from "./geocoding";
|
import * as geocoding from "./geocoding";
|
||||||
|
import * as google from "./google";
|
||||||
import * as helloworld from "./helloworld";
|
import * as helloworld from "./helloworld";
|
||||||
import * as holidays from "./holidays";
|
import * as holidays from "./holidays";
|
||||||
import * as id from "./id";
|
import * as id from "./id";
|
||||||
@@ -54,6 +55,7 @@ export class Client {
|
|||||||
this.forexService = new forex.ForexService(token);
|
this.forexService = new forex.ForexService(token);
|
||||||
this.functionService = new fx.FunctionService(token);
|
this.functionService = new fx.FunctionService(token);
|
||||||
this.geocodingService = new geocoding.GeocodingService(token);
|
this.geocodingService = new geocoding.GeocodingService(token);
|
||||||
|
this.googleService = new google.GoogleService(token);
|
||||||
this.helloworldService = new helloworld.HelloworldService(token);
|
this.helloworldService = new helloworld.HelloworldService(token);
|
||||||
this.holidaysService = new holidays.HolidaysService(token);
|
this.holidaysService = new holidays.HolidaysService(token);
|
||||||
this.idService = new id.IdService(token);
|
this.idService = new id.IdService(token);
|
||||||
@@ -96,6 +98,7 @@ export class Client {
|
|||||||
forexService: forex.ForexService;
|
forexService: forex.ForexService;
|
||||||
functionService: fx.FunctionService;
|
functionService: fx.FunctionService;
|
||||||
geocodingService: geocoding.GeocodingService;
|
geocodingService: geocoding.GeocodingService;
|
||||||
|
googleService: google.GoogleService;
|
||||||
helloworldService: helloworld.HelloworldService;
|
helloworldService: helloworld.HelloworldService;
|
||||||
holidaysService: holidays.HolidaysService;
|
holidaysService: holidays.HolidaysService;
|
||||||
idService: id.IdService;
|
idService: id.IdService;
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
"function",
|
"function",
|
||||||
"geocoding",
|
"geocoding",
|
||||||
"gifs",
|
"gifs",
|
||||||
|
"google",
|
||||||
"helloworld",
|
"helloworld",
|
||||||
"holidays",
|
"holidays",
|
||||||
"id",
|
"id",
|
||||||
@@ -75,5 +76,5 @@
|
|||||||
"prepare": "npm run build"
|
"prepare": "npm run build"
|
||||||
},
|
},
|
||||||
"types": "index.d.ts",
|
"types": "index.d.ts",
|
||||||
"version": "1.0.560"
|
"version": "1.0.561"
|
||||||
}
|
}
|
||||||
@@ -12,8 +12,8 @@ func UpdateArecord() {
|
|||||||
dbService := db.NewDbService(os.Getenv("MICRO_API_TOKEN"))
|
dbService := db.NewDbService(os.Getenv("MICRO_API_TOKEN"))
|
||||||
rsp, err := dbService.Update(&db.UpdateRequest{
|
rsp, err := dbService.Update(&db.UpdateRequest{
|
||||||
Record: map[string]interface{}{
|
Record: map[string]interface{}{
|
||||||
"id": "1",
|
|
||||||
"age": 43,
|
"age": 43,
|
||||||
|
"id": "1",
|
||||||
},
|
},
|
||||||
Table: "users",
|
Table: "users",
|
||||||
})
|
})
|
||||||
|
|||||||
6
examples/google/search/curl/searchForVideos.sh
Executable file
6
examples/google/search/curl/searchForVideos.sh
Executable file
@@ -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"
|
||||||
|
}'
|
||||||
17
examples/google/search/go/searchForVideos.go
Executable file
17
examples/google/search/go/searchForVideos.go
Executable file
@@ -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)
|
||||||
|
}
|
||||||
12
examples/google/search/node/searchForVideos.js
Executable file
12
examples/google/search/node/searchForVideos.js
Executable file
@@ -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();
|
||||||
Reference in New Issue
Block a user