From 3c70d23a1d66613297598d85bd3cc0e9b5a5e212 Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Mon, 1 Nov 2021 11:00:21 +0000 Subject: [PATCH] m3o client changed --- go.mod | 2 +- go.sum | 5 +- services/address/address.go | 2 +- services/answer/answer.go | 2 +- services/cache/cache.go | 2 +- services/crypto/crypto.go | 2 +- services/currency/currency.go | 2 +- services/db/db.go | 18 +++- services/email/email.go | 2 +- services/emoji/emoji.go | 2 +- services/evchargers/evchargers.go | 2 +- services/file/file.go | 2 +- services/forex/forex.go | 2 +- services/function/function.go | 151 ++++++++++++++++++++++++++++++ services/geocoding/geocoding.go | 2 +- services/gifs/gifs.go | 4 +- services/google/google.go | 48 ++++++++++ services/helloworld/helloworld.go | 2 +- services/holidays/holidays.go | 2 +- services/id/id.go | 2 +- services/image/image.go | 5 +- services/ip/ip.go | 2 +- services/location/location.go | 2 +- services/notes/notes.go | 2 +- services/otp/otp.go | 2 +- services/postcode/postcode.go | 2 +- services/prayer/prayer.go | 2 +- services/qr/qr.go | 2 +- services/quran/quran.go | 2 +- services/routing/routing.go | 2 +- services/rss/rss.go | 2 +- services/sentiment/sentiment.go | 2 +- services/sms/sms.go | 2 +- services/stock/stock.go | 2 +- services/stream/stream.go | 2 +- services/sunnah/sunnah.go | 2 +- services/thumbnail/thumbnail.go | 2 +- services/time/time.go | 2 +- services/twitter/twitter.go | 2 +- services/url/url.go | 2 +- services/user/user.go | 10 +- services/vehicle/vehicle.go | 2 +- services/weather/weather.go | 2 +- services/youtube/youtube.go | 55 +++++++++++ 44 files changed, 318 insertions(+), 50 deletions(-) create mode 100755 services/function/function.go create mode 100755 services/google/google.go create mode 100755 services/youtube/youtube.go diff --git a/go.mod b/go.mod index 7186cc71..7168b277 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,6 @@ require ( github.com/google/uuid v1.2.0 github.com/gorilla/handlers v1.5.1 github.com/imdario/mergo v0.3.12 - github.com/m3o/m3o-go/client v0.0.0-20210421144725-8bfd7992ada3 github.com/miekg/dns v1.1.43 github.com/nxadm/tail v1.4.8 github.com/opentracing/opentracing-go v1.2.0 @@ -30,6 +29,7 @@ require ( github.com/uber/jaeger-client-go v2.29.1+incompatible github.com/uber/jaeger-lib v2.4.1+incompatible github.com/urfave/cli/v2 v2.3.0 + go.m3o.com v0.1.0 golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a golang.org/x/net v0.0.0-20210510120150-4163338589ed golang.org/x/sync v0.0.0-20210220032951-036812b2e83c diff --git a/go.sum b/go.sum index 4eed948c..4b489843 100644 --- a/go.sum +++ b/go.sum @@ -260,7 +260,6 @@ github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= -github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= @@ -343,8 +342,6 @@ github.com/liquidweb/go-lwApi v0.0.0-20190605172801-52a4864d2738/go.mod h1:0sYF9 github.com/liquidweb/go-lwApi v0.0.5/go.mod h1:0sYF9rMXb0vlG+4SzdiGMXHheCZxjguMq+Zb4S2BfBs= github.com/liquidweb/liquidweb-cli v0.6.9/go.mod h1:cE1uvQ+x24NGUL75D0QagOFCG8Wdvmwu8aL9TLmA/eQ= github.com/liquidweb/liquidweb-go v1.6.3/go.mod h1:SuXXp+thr28LnjEw18AYtWwIbWMHSUiajPQs8T9c/Rc= -github.com/m3o/m3o-go/client v0.0.0-20210421144725-8bfd7992ada3 h1:RVt7rqWl4al36BH9OY9k7IXnnooOP0Feanu1bed6X2s= -github.com/m3o/m3o-go/client v0.0.0-20210421144725-8bfd7992ada3/go.mod h1:vmeaYrKYpgVNhny/l7iH8mXS88S7ijUiYni3gZUrCq0= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.4/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= github.com/matryer/is v1.2.0 h1:92UTHpy8CDwaJ08GqLDzhhuixiBUUD1p3AU6PHddz4A= @@ -542,6 +539,8 @@ github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.m3o.com v0.1.0 h1:vYYcMtUzkkl8/zQcLIZFakBvNO/wSrMcNHRySAmEh9E= +go.m3o.com v0.1.0/go.mod h1:p8FdLqZH3R9a0y04qiMNT+clw69d3SxyQPFzCNbDRtk= go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= diff --git a/services/address/address.go b/services/address/address.go index e7753151..40e4b018 100755 --- a/services/address/address.go +++ b/services/address/address.go @@ -1,7 +1,7 @@ package address import ( - "github.com/m3o/m3o-go/client" + "go.m3o.com/client" ) func NewAddressService(token string) *AddressService { diff --git a/services/answer/answer.go b/services/answer/answer.go index 881e67fd..9c7a53c6 100755 --- a/services/answer/answer.go +++ b/services/answer/answer.go @@ -1,7 +1,7 @@ package answer import ( - "github.com/m3o/m3o-go/client" + "go.m3o.com/client" ) func NewAnswerService(token string) *AnswerService { diff --git a/services/cache/cache.go b/services/cache/cache.go index ebbc9b1e..130c6974 100755 --- a/services/cache/cache.go +++ b/services/cache/cache.go @@ -1,7 +1,7 @@ package cache import ( - "github.com/m3o/m3o-go/client" + "go.m3o.com/client" ) func NewCacheService(token string) *CacheService { diff --git a/services/crypto/crypto.go b/services/crypto/crypto.go index ea856439..cc82cea9 100755 --- a/services/crypto/crypto.go +++ b/services/crypto/crypto.go @@ -1,7 +1,7 @@ package crypto import ( - "github.com/m3o/m3o-go/client" + "go.m3o.com/client" ) func NewCryptoService(token string) *CryptoService { diff --git a/services/currency/currency.go b/services/currency/currency.go index c3410b01..db4fea50 100755 --- a/services/currency/currency.go +++ b/services/currency/currency.go @@ -1,7 +1,7 @@ package currency import ( - "github.com/m3o/m3o-go/client" + "go.m3o.com/client" ) func NewCurrencyService(token string) *CurrencyService { diff --git a/services/db/db.go b/services/db/db.go index 1cea4963..7c6d9d73 100755 --- a/services/db/db.go +++ b/services/db/db.go @@ -1,7 +1,7 @@ package db import ( - "github.com/m3o/m3o-go/client" + "go.m3o.com/client" ) func NewDbService(token string) *DbService { @@ -16,6 +16,12 @@ type DbService struct { client *client.Client } +// Count records in a table +func (t *DbService) Count(request *CountRequest) (*CountResponse, error) { + rsp := &CountResponse{} + return rsp, t.client.Call("db", "Count", request, rsp) +} + // Create a record in the database. Optionally include an "id" field otherwise it's set automatically. func (t *DbService) Create(request *CreateRequest) (*CreateResponse, error) { rsp := &CreateResponse{} @@ -46,6 +52,16 @@ func (t *DbService) Update(request *UpdateRequest) (*UpdateResponse, error) { return rsp, t.client.Call("db", "Update", request, rsp) } +type CountRequest struct { + // specify the table name + Table string `json:"table"` +} + +type CountResponse struct { + // the number of records in the table + Count int32 `json:"count"` +} + type CreateRequest struct { // JSON encoded record or records (can be array or object) Record map[string]interface{} `json:"record"` diff --git a/services/email/email.go b/services/email/email.go index 8cc63d3c..ee60657b 100755 --- a/services/email/email.go +++ b/services/email/email.go @@ -1,7 +1,7 @@ package email import ( - "github.com/m3o/m3o-go/client" + "go.m3o.com/client" ) func NewEmailService(token string) *EmailService { diff --git a/services/emoji/emoji.go b/services/emoji/emoji.go index 783c4059..78d64c0d 100755 --- a/services/emoji/emoji.go +++ b/services/emoji/emoji.go @@ -1,7 +1,7 @@ package emoji import ( - "github.com/m3o/m3o-go/client" + "go.m3o.com/client" ) func NewEmojiService(token string) *EmojiService { diff --git a/services/evchargers/evchargers.go b/services/evchargers/evchargers.go index b24c707d..dbe4d1ca 100755 --- a/services/evchargers/evchargers.go +++ b/services/evchargers/evchargers.go @@ -1,7 +1,7 @@ package evchargers import ( - "github.com/m3o/m3o-go/client" + "go.m3o.com/client" ) func NewEvchargersService(token string) *EvchargersService { diff --git a/services/file/file.go b/services/file/file.go index dbf8cafe..c0da688d 100755 --- a/services/file/file.go +++ b/services/file/file.go @@ -1,7 +1,7 @@ package file import ( - "github.com/m3o/m3o-go/client" + "go.m3o.com/client" ) func NewFileService(token string) *FileService { diff --git a/services/forex/forex.go b/services/forex/forex.go index d4f2fe56..8fcb80ec 100755 --- a/services/forex/forex.go +++ b/services/forex/forex.go @@ -1,7 +1,7 @@ package forex import ( - "github.com/m3o/m3o-go/client" + "go.m3o.com/client" ) func NewForexService(token string) *ForexService { diff --git a/services/function/function.go b/services/function/function.go new file mode 100755 index 00000000..502e64f3 --- /dev/null +++ b/services/function/function.go @@ -0,0 +1,151 @@ +package function + +import ( + "go.m3o.com/client" +) + +func NewFunctionService(token string) *FunctionService { + return &FunctionService{ + client: client.NewClient(&client.Options{ + Token: token, + }), + } +} + +type FunctionService struct { + client *client.Client +} + +// Call a function by name +func (t *FunctionService) Call(request *CallRequest) (*CallResponse, error) { + rsp := &CallResponse{} + return rsp, t.client.Call("function", "Call", request, rsp) +} + +// Delete a function by name +func (t *FunctionService) Delete(request *DeleteRequest) (*DeleteResponse, error) { + rsp := &DeleteResponse{} + return rsp, t.client.Call("function", "Delete", request, rsp) +} + +// Deploy a group of functions +func (t *FunctionService) Deploy(request *DeployRequest) (*DeployResponse, error) { + rsp := &DeployResponse{} + return rsp, t.client.Call("function", "Deploy", request, rsp) +} + +// Get the info for a deployed function +func (t *FunctionService) Describe(request *DescribeRequest) (*DescribeResponse, error) { + rsp := &DescribeResponse{} + return rsp, t.client.Call("function", "Describe", request, rsp) +} + +// List all the deployed functions +func (t *FunctionService) List(request *ListRequest) (*ListResponse, error) { + rsp := &ListResponse{} + return rsp, t.client.Call("function", "List", request, rsp) +} + +type CallRequest struct { + // Name of the function + Name string `json:"name"` + // Request body that will be passed to the function + Request map[string]interface{} `json:"request"` +} + +type CallResponse struct { + // Response body that the function returned + Response map[string]interface{} `json:"response"` +} + +type DeleteRequest struct { + // The name of the function + Name string `json:"name"` + // Optional project name + Project string `json:"project"` +} + +type DeleteResponse struct { +} + +type DeployRequest struct { + // entry point, ie. handler name in the source code + // if not provided, defaults to the name parameter + Entrypoint string `json:"entrypoint"` + // environment variables to pass in at runtime + EnvVars map[string]string `json:"envVars"` + // function name + Name string `json:"name"` + // project is used for namespacing your functions + // optional. defaults to "default". + Project string `json:"project"` + // github url to repo + Repo string `json:"repo"` + // runtime/language of the function + // eg: php74, + // nodejs6, nodejs8, nodejs10, nodejs12, nodejs14, nodejs16 + // dotnet3 + // java11 + // ruby26, ruby27 + // go111, go113, go116 + // python37, python38, python39 + Runtime string `json:"runtime"` + // optional subfolder path + Subfolder string `json:"subfolder"` +} + +type DeployResponse struct { +} + +type DescribeRequest struct { + // The name of the function + Name string `json:"name"` + // Optional project name + Project string `json:"project"` +} + +type DescribeResponse struct { + // The function requested + Function *Func `json:"function"` + // The timeout for requests to the function + Timeout string `json:"timeout"` + // The time at which the function was updated + UpdatedAt string `json:"updatedAt"` +} + +type Func struct { + // name of handler in source code + Entrypoint string `json:"entrypoint"` + // function name + // limitation: must be unique across projects + Name string `json:"name"` + // project of function, optional + // defaults to literal "default" + // used to namespace functions + Project string `json:"project"` + // git repo address + Repo string `json:"repo"` + // runtime/language of the function + // eg: php74, + // nodejs6, nodejs8, nodejs10, nodejs12, nodejs14, nodejs16 + // dotnet3 + // java11 + // ruby26, ruby27 + // go111, go113, go116 + // python37, python38, python39 + Runtime string `json:"runtime"` + // eg. ACTIVE, DEPLOY_IN_PROGRESS, OFFLINE etc + Status string `json:"status"` + // subfolder path to entrypoint + Subfolder string `json:"subfolder"` +} + +type ListRequest struct { + // optional project name + Project string `json:"project"` +} + +type ListResponse struct { + // List of functions deployed + Functions []Func `json:"functions"` +} diff --git a/services/geocoding/geocoding.go b/services/geocoding/geocoding.go index d569b7fe..a01a1731 100755 --- a/services/geocoding/geocoding.go +++ b/services/geocoding/geocoding.go @@ -1,7 +1,7 @@ package geocoding import ( - "github.com/m3o/m3o-go/client" + "go.m3o.com/client" ) func NewGeocodingService(token string) *GeocodingService { diff --git a/services/gifs/gifs.go b/services/gifs/gifs.go index 897082d9..c7614460 100755 --- a/services/gifs/gifs.go +++ b/services/gifs/gifs.go @@ -1,7 +1,7 @@ package gifs import ( - "github.com/m3o/m3o-go/client" + "go.m3o.com/client" ) func NewGifsService(token string) *GifsService { @@ -16,7 +16,7 @@ type GifsService struct { client *client.Client } -// Search for a gif +// Search for a GIF func (t *GifsService) Search(request *SearchRequest) (*SearchResponse, error) { rsp := &SearchResponse{} return rsp, t.client.Call("gifs", "Search", request, rsp) diff --git a/services/google/google.go b/services/google/google.go new file mode 100755 index 00000000..985462fb --- /dev/null +++ b/services/google/google.go @@ -0,0 +1,48 @@ +package google + +import ( + "go.m3o.com/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/services/helloworld/helloworld.go b/services/helloworld/helloworld.go index 075fd713..e7bcf388 100755 --- a/services/helloworld/helloworld.go +++ b/services/helloworld/helloworld.go @@ -1,7 +1,7 @@ package helloworld import ( - "github.com/m3o/m3o-go/client" + "go.m3o.com/client" ) func NewHelloworldService(token string) *HelloworldService { diff --git a/services/holidays/holidays.go b/services/holidays/holidays.go index db338a7d..71b1058d 100755 --- a/services/holidays/holidays.go +++ b/services/holidays/holidays.go @@ -1,7 +1,7 @@ package holidays import ( - "github.com/m3o/m3o-go/client" + "go.m3o.com/client" ) func NewHolidaysService(token string) *HolidaysService { diff --git a/services/id/id.go b/services/id/id.go index f3d5638a..d26ea72f 100755 --- a/services/id/id.go +++ b/services/id/id.go @@ -1,7 +1,7 @@ package id import ( - "github.com/m3o/m3o-go/client" + "go.m3o.com/client" ) func NewIdService(token string) *IdService { diff --git a/services/image/image.go b/services/image/image.go index e3236147..70800b18 100755 --- a/services/image/image.go +++ b/services/image/image.go @@ -1,7 +1,7 @@ package image import ( - "github.com/m3o/m3o-go/client" + "go.m3o.com/client" ) func NewImageService(token string) *ImageService { @@ -40,7 +40,6 @@ func (t *ImageService) Upload(request *UploadRequest) (*UploadResponse, error) { type ConvertRequest struct { // base64 encoded image to resize, - // ie. "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" Base64 string `json:"base64"` // output name of the image including extension, ie. "cat.png" Name string `json:"name"` @@ -79,7 +78,6 @@ type Rectangle struct { type ResizeRequest struct { // base64 encoded image to resize, - // ie. "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" Base64 string `json:"base64"` // optional crop options // if provided, after resize, the image @@ -102,7 +100,6 @@ type ResizeResponse struct { type UploadRequest struct { // Base64 encoded image to upload, - // ie. "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" Base64 string `json:"base64"` // Output name of the image including extension, ie. "cat.png" Name string `json:"name"` diff --git a/services/ip/ip.go b/services/ip/ip.go index 3d81955a..8213744f 100755 --- a/services/ip/ip.go +++ b/services/ip/ip.go @@ -1,7 +1,7 @@ package ip import ( - "github.com/m3o/m3o-go/client" + "go.m3o.com/client" ) func NewIpService(token string) *IpService { diff --git a/services/location/location.go b/services/location/location.go index 1acca4db..2817790c 100755 --- a/services/location/location.go +++ b/services/location/location.go @@ -1,7 +1,7 @@ package location import ( - "github.com/m3o/m3o-go/client" + "go.m3o.com/client" ) func NewLocationService(token string) *LocationService { diff --git a/services/notes/notes.go b/services/notes/notes.go index 4c29b8b2..a1df0053 100755 --- a/services/notes/notes.go +++ b/services/notes/notes.go @@ -1,7 +1,7 @@ package notes import ( - "github.com/m3o/m3o-go/client" + "go.m3o.com/client" ) func NewNotesService(token string) *NotesService { diff --git a/services/otp/otp.go b/services/otp/otp.go index 5cc952f7..109b3796 100755 --- a/services/otp/otp.go +++ b/services/otp/otp.go @@ -1,7 +1,7 @@ package otp import ( - "github.com/m3o/m3o-go/client" + "go.m3o.com/client" ) func NewOtpService(token string) *OtpService { diff --git a/services/postcode/postcode.go b/services/postcode/postcode.go index 818f64be..4419b850 100755 --- a/services/postcode/postcode.go +++ b/services/postcode/postcode.go @@ -1,7 +1,7 @@ package postcode import ( - "github.com/m3o/m3o-go/client" + "go.m3o.com/client" ) func NewPostcodeService(token string) *PostcodeService { diff --git a/services/prayer/prayer.go b/services/prayer/prayer.go index cfafcc70..9a3eba61 100755 --- a/services/prayer/prayer.go +++ b/services/prayer/prayer.go @@ -1,7 +1,7 @@ package prayer import ( - "github.com/m3o/m3o-go/client" + "go.m3o.com/client" ) func NewPrayerService(token string) *PrayerService { diff --git a/services/qr/qr.go b/services/qr/qr.go index b0e4a34a..17db08b9 100755 --- a/services/qr/qr.go +++ b/services/qr/qr.go @@ -1,7 +1,7 @@ package qr import ( - "github.com/m3o/m3o-go/client" + "go.m3o.com/client" ) func NewQrService(token string) *QrService { diff --git a/services/quran/quran.go b/services/quran/quran.go index 3fc090d6..cac59279 100755 --- a/services/quran/quran.go +++ b/services/quran/quran.go @@ -1,7 +1,7 @@ package quran import ( - "github.com/m3o/m3o-go/client" + "go.m3o.com/client" ) func NewQuranService(token string) *QuranService { diff --git a/services/routing/routing.go b/services/routing/routing.go index 4ac2d5be..43471ff3 100755 --- a/services/routing/routing.go +++ b/services/routing/routing.go @@ -1,7 +1,7 @@ package routing import ( - "github.com/m3o/m3o-go/client" + "go.m3o.com/client" ) func NewRoutingService(token string) *RoutingService { diff --git a/services/rss/rss.go b/services/rss/rss.go index 9348dc69..1e3f0b42 100755 --- a/services/rss/rss.go +++ b/services/rss/rss.go @@ -1,7 +1,7 @@ package rss import ( - "github.com/m3o/m3o-go/client" + "go.m3o.com/client" ) func NewRssService(token string) *RssService { diff --git a/services/sentiment/sentiment.go b/services/sentiment/sentiment.go index f53278f7..c7ed2e38 100755 --- a/services/sentiment/sentiment.go +++ b/services/sentiment/sentiment.go @@ -1,7 +1,7 @@ package sentiment import ( - "github.com/m3o/m3o-go/client" + "go.m3o.com/client" ) func NewSentimentService(token string) *SentimentService { diff --git a/services/sms/sms.go b/services/sms/sms.go index 8ae4f5f3..c947bd4b 100755 --- a/services/sms/sms.go +++ b/services/sms/sms.go @@ -1,7 +1,7 @@ package sms import ( - "github.com/m3o/m3o-go/client" + "go.m3o.com/client" ) func NewSmsService(token string) *SmsService { diff --git a/services/stock/stock.go b/services/stock/stock.go index 002ddf52..4bb6fa88 100755 --- a/services/stock/stock.go +++ b/services/stock/stock.go @@ -1,7 +1,7 @@ package stock import ( - "github.com/m3o/m3o-go/client" + "go.m3o.com/client" ) func NewStockService(token string) *StockService { diff --git a/services/stream/stream.go b/services/stream/stream.go index 6467965d..0e3d4411 100755 --- a/services/stream/stream.go +++ b/services/stream/stream.go @@ -1,7 +1,7 @@ package stream import ( - "github.com/m3o/m3o-go/client" + "go.m3o.com/client" ) func NewStreamService(token string) *StreamService { diff --git a/services/sunnah/sunnah.go b/services/sunnah/sunnah.go index 4375cfcb..a7276b03 100755 --- a/services/sunnah/sunnah.go +++ b/services/sunnah/sunnah.go @@ -1,7 +1,7 @@ package sunnah import ( - "github.com/m3o/m3o-go/client" + "go.m3o.com/client" ) func NewSunnahService(token string) *SunnahService { diff --git a/services/thumbnail/thumbnail.go b/services/thumbnail/thumbnail.go index cb331474..968aa87e 100755 --- a/services/thumbnail/thumbnail.go +++ b/services/thumbnail/thumbnail.go @@ -1,7 +1,7 @@ package thumbnail import ( - "github.com/m3o/m3o-go/client" + "go.m3o.com/client" ) func NewThumbnailService(token string) *ThumbnailService { diff --git a/services/time/time.go b/services/time/time.go index aa61e650..db652c33 100755 --- a/services/time/time.go +++ b/services/time/time.go @@ -1,7 +1,7 @@ package time import ( - "github.com/m3o/m3o-go/client" + "go.m3o.com/client" ) func NewTimeService(token string) *TimeService { diff --git a/services/twitter/twitter.go b/services/twitter/twitter.go index a855bfe9..1a94e3db 100755 --- a/services/twitter/twitter.go +++ b/services/twitter/twitter.go @@ -1,7 +1,7 @@ package twitter import ( - "github.com/m3o/m3o-go/client" + "go.m3o.com/client" ) func NewTwitterService(token string) *TwitterService { diff --git a/services/url/url.go b/services/url/url.go index cb3b79a9..12bb1783 100755 --- a/services/url/url.go +++ b/services/url/url.go @@ -1,7 +1,7 @@ package url import ( - "github.com/m3o/m3o-go/client" + "go.m3o.com/client" ) func NewUrlService(token string) *UrlService { diff --git a/services/user/user.go b/services/user/user.go index 8387486d..6a4ce491 100755 --- a/services/user/user.go +++ b/services/user/user.go @@ -1,7 +1,7 @@ package user import ( - "github.com/m3o/m3o-go/client" + "go.m3o.com/client" ) func NewUserService(token string) *UserService { @@ -95,9 +95,11 @@ type Account struct { // unix timestamp Updated int64 `json:"updated,string"` // alphanumeric username - Username string `json:"username"` - VerificationDate int64 `json:"verificationDate,string"` - Verified bool `json:"verified"` + Username string `json:"username"` + // date of verification + VerificationDate int64 `json:"verificationDate,string"` + // if the account is verified + Verified bool `json:"verified"` } type CreateRequest struct { diff --git a/services/vehicle/vehicle.go b/services/vehicle/vehicle.go index a82da4cc..6e05260b 100755 --- a/services/vehicle/vehicle.go +++ b/services/vehicle/vehicle.go @@ -1,7 +1,7 @@ package vehicle import ( - "github.com/m3o/m3o-go/client" + "go.m3o.com/client" ) func NewVehicleService(token string) *VehicleService { diff --git a/services/weather/weather.go b/services/weather/weather.go index 578297a6..17049939 100755 --- a/services/weather/weather.go +++ b/services/weather/weather.go @@ -1,7 +1,7 @@ package weather import ( - "github.com/m3o/m3o-go/client" + "go.m3o.com/client" ) func NewWeatherService(token string) *WeatherService { diff --git a/services/youtube/youtube.go b/services/youtube/youtube.go new file mode 100755 index 00000000..b2cec9ab --- /dev/null +++ b/services/youtube/youtube.go @@ -0,0 +1,55 @@ +package youtube + +import ( + "go.m3o.com/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"` +}