2 Commits
v0.2.0 ... ci

Author SHA1 Message Date
Janos Dobronszki
18df6dada9 F 2021-11-03 10:17:51 +00:00
Janos Dobronszki
b0f9eae01a F 2021-11-03 09:31:38 +00:00
258 changed files with 837 additions and 4811 deletions

View File

@@ -22,10 +22,5 @@ jobs:
env: env:
M3O_API_TOKEN: ${{ secrets.M3O_API_TOKEN }} M3O_API_TOKEN: ${{ secrets.M3O_API_TOKEN }}
run: | run: |
# stream is temporarily excluded as it hangs forever because test does not close connection cd examples/helloworld/call/callTheHelloworldService
# @TODO remove "idempotent: true" from stream example go run main.go
O=$(find . -name ".run" | grep -v stream | xargs -n1 dirname | xargs -n1 go run)
echo $O
if grep -q Detail "$O"; then
exit 1
fi

View File

@@ -18,10 +18,8 @@ type AddressService struct {
// Lookup a list of UK addresses by postcode // Lookup a list of UK addresses by postcode
func (t *AddressService) LookupPostcode(request *LookupPostcodeRequest) (*LookupPostcodeResponse, error) { func (t *AddressService) LookupPostcode(request *LookupPostcodeRequest) (*LookupPostcodeResponse, error) {
rsp := &LookupPostcodeResponse{} rsp := &LookupPostcodeResponse{}
return rsp, t.client.Call("address", "LookupPostcode", request, rsp) return rsp, t.client.Call("address", "LookupPostcode", request, rsp)
} }
type LookupPostcodeRequest struct { type LookupPostcodeRequest struct {

View File

@@ -18,10 +18,8 @@ type AnswerService struct {
// Ask a question and receive an instant answer // Ask a question and receive an instant answer
func (t *AnswerService) Question(request *QuestionRequest) (*QuestionResponse, error) { func (t *AnswerService) Question(request *QuestionRequest) (*QuestionResponse, error) {
rsp := &QuestionResponse{} rsp := &QuestionResponse{}
return rsp, t.client.Call("answer", "Question", request, rsp) return rsp, t.client.Call("answer", "Question", request, rsp)
} }
type QuestionRequest struct { type QuestionRequest struct {

18
cache/cache.go vendored
View File

@@ -16,44 +16,34 @@ type CacheService struct {
client *client.Client client *client.Client
} }
// Decrement a value (if it's a number). If key not found it is equivalent to set. // Decrement a value (if it's a number)
func (t *CacheService) Decrement(request *DecrementRequest) (*DecrementResponse, error) { func (t *CacheService) Decrement(request *DecrementRequest) (*DecrementResponse, error) {
rsp := &DecrementResponse{} rsp := &DecrementResponse{}
return rsp, t.client.Call("cache", "Decrement", request, rsp) return rsp, t.client.Call("cache", "Decrement", request, rsp)
} }
// Delete a value from the cache. If key not found a success response is returned. // Delete a value from the cache
func (t *CacheService) Delete(request *DeleteRequest) (*DeleteResponse, error) { func (t *CacheService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
rsp := &DeleteResponse{} rsp := &DeleteResponse{}
return rsp, t.client.Call("cache", "Delete", request, rsp) return rsp, t.client.Call("cache", "Delete", request, rsp)
} }
// Get an item from the cache by key. If key is not found, an empty response is returned. // Get an item from the cache by key
func (t *CacheService) Get(request *GetRequest) (*GetResponse, error) { func (t *CacheService) Get(request *GetRequest) (*GetResponse, error) {
rsp := &GetResponse{} rsp := &GetResponse{}
return rsp, t.client.Call("cache", "Get", request, rsp) return rsp, t.client.Call("cache", "Get", request, rsp)
} }
// Increment a value (if it's a number). If key not found it is equivalent to set. // Increment a value (if it's a number)
func (t *CacheService) Increment(request *IncrementRequest) (*IncrementResponse, error) { func (t *CacheService) Increment(request *IncrementRequest) (*IncrementResponse, error) {
rsp := &IncrementResponse{} rsp := &IncrementResponse{}
return rsp, t.client.Call("cache", "Increment", request, rsp) return rsp, t.client.Call("cache", "Increment", request, rsp)
} }
// Set an item in the cache. Overwrites any existing value already set. // Set an item in the cache. Overwrites any existing value already set.
func (t *CacheService) Set(request *SetRequest) (*SetResponse, error) { func (t *CacheService) Set(request *SetRequest) (*SetResponse, error) {
rsp := &SetResponse{} rsp := &SetResponse{}
return rsp, t.client.Call("cache", "Set", request, rsp) return rsp, t.client.Call("cache", "Set", request, rsp)
} }
type DecrementRequest struct { type DecrementRequest struct {

View File

@@ -6,10 +6,6 @@ import (
) )
func TestBasicCall(t *testing.T) { func TestBasicCall(t *testing.T) {
if v := os.Getenv("IN_TRAVIS"); v == "yes" {
return
}
response := map[string]interface{}{} response := map[string]interface{}{}
if err := NewClient(&Options{ if err := NewClient(&Options{
Token: os.Getenv("TOKEN"), Token: os.Getenv("TOKEN"),

View File

@@ -18,34 +18,26 @@ type CryptoService struct {
// Returns the history for the previous close // Returns the history for the previous close
func (t *CryptoService) History(request *HistoryRequest) (*HistoryResponse, error) { func (t *CryptoService) History(request *HistoryRequest) (*HistoryResponse, error) {
rsp := &HistoryResponse{} rsp := &HistoryResponse{}
return rsp, t.client.Call("crypto", "History", request, rsp) return rsp, t.client.Call("crypto", "History", request, rsp)
} }
// Get news related to a currency // Get news related to a currency
func (t *CryptoService) News(request *NewsRequest) (*NewsResponse, error) { func (t *CryptoService) News(request *NewsRequest) (*NewsResponse, error) {
rsp := &NewsResponse{} rsp := &NewsResponse{}
return rsp, t.client.Call("crypto", "News", request, rsp) return rsp, t.client.Call("crypto", "News", request, rsp)
} }
// Get the last price for a given crypto ticker // Get the last price for a given crypto ticker
func (t *CryptoService) Price(request *PriceRequest) (*PriceResponse, error) { func (t *CryptoService) Price(request *PriceRequest) (*PriceResponse, error) {
rsp := &PriceResponse{} rsp := &PriceResponse{}
return rsp, t.client.Call("crypto", "Price", request, rsp) return rsp, t.client.Call("crypto", "Price", request, rsp)
} }
// Get the last quote for a given crypto ticker // Get the last quote for a given crypto ticker
func (t *CryptoService) Quote(request *QuoteRequest) (*QuoteResponse, error) { func (t *CryptoService) Quote(request *QuoteRequest) (*QuoteResponse, error) {
rsp := &QuoteResponse{} rsp := &QuoteResponse{}
return rsp, t.client.Call("crypto", "Quote", request, rsp) return rsp, t.client.Call("crypto", "Quote", request, rsp)
} }
type Article struct { type Article struct {

View File

@@ -18,34 +18,26 @@ type CurrencyService struct {
// Codes returns the supported currency codes for the API // Codes returns the supported currency codes for the API
func (t *CurrencyService) Codes(request *CodesRequest) (*CodesResponse, error) { func (t *CurrencyService) Codes(request *CodesRequest) (*CodesResponse, error) {
rsp := &CodesResponse{} rsp := &CodesResponse{}
return rsp, t.client.Call("currency", "Codes", request, rsp) return rsp, t.client.Call("currency", "Codes", request, rsp)
} }
// Convert returns the currency conversion rate between two pairs e.g USD/GBP // Convert returns the currency conversion rate between two pairs e.g USD/GBP
func (t *CurrencyService) Convert(request *ConvertRequest) (*ConvertResponse, error) { func (t *CurrencyService) Convert(request *ConvertRequest) (*ConvertResponse, error) {
rsp := &ConvertResponse{} rsp := &ConvertResponse{}
return rsp, t.client.Call("currency", "Convert", request, rsp) return rsp, t.client.Call("currency", "Convert", request, rsp)
} }
// Returns the historic rates for a currency on a given date // Returns the historic rates for a currency on a given date
func (t *CurrencyService) History(request *HistoryRequest) (*HistoryResponse, error) { func (t *CurrencyService) History(request *HistoryRequest) (*HistoryResponse, error) {
rsp := &HistoryResponse{} rsp := &HistoryResponse{}
return rsp, t.client.Call("currency", "History", request, rsp) return rsp, t.client.Call("currency", "History", request, rsp)
} }
// Rates returns the currency rates for a given code e.g USD // Rates returns the currency rates for a given code e.g USD
func (t *CurrencyService) Rates(request *RatesRequest) (*RatesResponse, error) { func (t *CurrencyService) Rates(request *RatesRequest) (*RatesResponse, error) {
rsp := &RatesResponse{} rsp := &RatesResponse{}
return rsp, t.client.Call("currency", "Rates", request, rsp) return rsp, t.client.Call("currency", "Rates", request, rsp)
} }
type Code struct { type Code struct {

View File

@@ -18,74 +18,38 @@ type DbService struct {
// Count records in a table // Count records in a table
func (t *DbService) Count(request *CountRequest) (*CountResponse, error) { func (t *DbService) Count(request *CountRequest) (*CountResponse, error) {
rsp := &CountResponse{} rsp := &CountResponse{}
return rsp, t.client.Call("db", "Count", request, rsp) 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. // Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
func (t *DbService) Create(request *CreateRequest) (*CreateResponse, error) { func (t *DbService) Create(request *CreateRequest) (*CreateResponse, error) {
rsp := &CreateResponse{} rsp := &CreateResponse{}
return rsp, t.client.Call("db", "Create", request, rsp) return rsp, t.client.Call("db", "Create", request, rsp)
} }
// Delete a record in the database by id. // Delete a record in the database by id.
func (t *DbService) Delete(request *DeleteRequest) (*DeleteResponse, error) { func (t *DbService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
rsp := &DeleteResponse{} rsp := &DeleteResponse{}
return rsp, t.client.Call("db", "Delete", request, rsp) return rsp, t.client.Call("db", "Delete", request, rsp)
}
// Drop a table in the DB
func (t *DbService) DropTable(request *DropTableRequest) (*DropTableResponse, error) {
rsp := &DropTableResponse{}
return rsp, t.client.Call("db", "DropTable", request, rsp)
}
// List tables in the DB
func (t *DbService) ListTables(request *ListTablesRequest) (*ListTablesResponse, error) {
rsp := &ListTablesResponse{}
return rsp, t.client.Call("db", "ListTables", request, rsp)
} }
// Read data from a table. Lookup can be by ID or via querying any field in the record. // Read data from a table. Lookup can be by ID or via querying any field in the record.
func (t *DbService) Read(request *ReadRequest) (*ReadResponse, error) { func (t *DbService) Read(request *ReadRequest) (*ReadResponse, error) {
rsp := &ReadResponse{} rsp := &ReadResponse{}
return rsp, t.client.Call("db", "Read", request, rsp) return rsp, t.client.Call("db", "Read", request, rsp)
}
// Rename a table
func (t *DbService) RenameTable(request *RenameTableRequest) (*RenameTableResponse, error) {
rsp := &RenameTableResponse{}
return rsp, t.client.Call("db", "RenameTable", request, rsp)
} }
// Truncate the records in a table // Truncate the records in a table
func (t *DbService) Truncate(request *TruncateRequest) (*TruncateResponse, error) { func (t *DbService) Truncate(request *TruncateRequest) (*TruncateResponse, error) {
rsp := &TruncateResponse{} rsp := &TruncateResponse{}
return rsp, t.client.Call("db", "Truncate", request, rsp) return rsp, t.client.Call("db", "Truncate", request, rsp)
} }
// Update a record in the database. Include an "id" in the record to update. // Update a record in the database. Include an "id" in the record to update.
func (t *DbService) Update(request *UpdateRequest) (*UpdateResponse, error) { func (t *DbService) Update(request *UpdateRequest) (*UpdateResponse, error) {
rsp := &UpdateResponse{} rsp := &UpdateResponse{}
return rsp, t.client.Call("db", "Update", request, rsp) return rsp, t.client.Call("db", "Update", request, rsp)
} }
type CountRequest struct { type CountRequest struct {
@@ -120,21 +84,6 @@ type DeleteRequest struct {
type DeleteResponse struct { type DeleteResponse struct {
} }
type DropTableRequest struct {
Table string `json:"table"`
}
type DropTableResponse struct {
}
type ListTablesRequest struct {
}
type ListTablesResponse struct {
// list of tables
Tables []string `json:"tables"`
}
type ReadRequest struct { type ReadRequest struct {
// Read by id. Equivalent to 'id == "your-id"' // Read by id. Equivalent to 'id == "your-id"'
Id string `json:"id"` Id string `json:"id"`
@@ -161,21 +110,14 @@ type ReadResponse struct {
Records []map[string]interface{} `json:"records"` Records []map[string]interface{} `json:"records"`
} }
type RenameTableRequest struct {
// current table name
From string `json:"from"`
// new table name
To string `json:"to"`
}
type RenameTableResponse struct {
}
type TruncateRequest struct { type TruncateRequest struct {
// Optional table name. Defaults to 'default'
Table string `json:"table"` Table string `json:"table"`
} }
type TruncateResponse struct { type TruncateResponse struct {
// The table truncated
Table string `json:"table"`
} }
type UpdateRequest struct { type UpdateRequest struct {

View File

@@ -18,10 +18,8 @@ type EmailService struct {
// Send an email by passing in from, to, subject, and a text or html body // Send an email by passing in from, to, subject, and a text or html body
func (t *EmailService) Send(request *SendRequest) (*SendResponse, error) { func (t *EmailService) Send(request *SendRequest) (*SendResponse, error) {
rsp := &SendResponse{} rsp := &SendResponse{}
return rsp, t.client.Call("email", "Send", request, rsp) return rsp, t.client.Call("email", "Send", request, rsp)
} }
type SendRequest struct { type SendRequest struct {

View File

@@ -18,35 +18,27 @@ type EmojiService struct {
// Find an emoji by its alias e.g :beer: // Find an emoji by its alias e.g :beer:
func (t *EmojiService) Find(request *FindRequest) (*FindResponse, error) { func (t *EmojiService) Find(request *FindRequest) (*FindResponse, error) {
rsp := &FindResponse{} rsp := &FindResponse{}
return rsp, t.client.Call("emoji", "Find", request, rsp) return rsp, t.client.Call("emoji", "Find", request, rsp)
} }
// Get the flag for a country. Requires country code e.g GB for great britain // Get the flag for a country. Requires country code e.g GB for great britain
func (t *EmojiService) Flag(request *FlagRequest) (*FlagResponse, error) { func (t *EmojiService) Flag(request *FlagRequest) (*FlagResponse, error) {
rsp := &FlagResponse{} rsp := &FlagResponse{}
return rsp, t.client.Call("emoji", "Flag", request, rsp) return rsp, t.client.Call("emoji", "Flag", request, rsp)
} }
// Print text and renders the emojis with aliases e.g // Print text and renders the emojis with aliases e.g
// let's grab a :beer: becomes let's grab a 🍺 // let's grab a :beer: becomes let's grab a 🍺
func (t *EmojiService) Print(request *PrintRequest) (*PrintResponse, error) { func (t *EmojiService) Print(request *PrintRequest) (*PrintResponse, error) {
rsp := &PrintResponse{} rsp := &PrintResponse{}
return rsp, t.client.Call("emoji", "Print", request, rsp) return rsp, t.client.Call("emoji", "Print", request, rsp)
} }
// Send an emoji to anyone via SMS. Messages are sent in the form '<message> Sent from <from>' // Send an emoji to anyone via SMS. Messages are sent in the form '<message> Sent from <from>'
func (t *EmojiService) Send(request *SendRequest) (*SendResponse, error) { func (t *EmojiService) Send(request *SendRequest) (*SendResponse, error) {
rsp := &SendResponse{} rsp := &SendResponse{}
return rsp, t.client.Call("emoji", "Send", request, rsp) return rsp, t.client.Call("emoji", "Send", request, rsp)
} }
type FindRequest struct { type FindRequest struct {

View File

@@ -18,18 +18,14 @@ type EvchargersService struct {
// Retrieve reference data as used by this API and in conjunction with the Search endpoint // Retrieve reference data as used by this API and in conjunction with the Search endpoint
func (t *EvchargersService) ReferenceData(request *ReferenceDataRequest) (*ReferenceDataResponse, error) { func (t *EvchargersService) ReferenceData(request *ReferenceDataRequest) (*ReferenceDataResponse, error) {
rsp := &ReferenceDataResponse{} rsp := &ReferenceDataResponse{}
return rsp, t.client.Call("evchargers", "ReferenceData", request, rsp) return rsp, t.client.Call("evchargers", "ReferenceData", request, rsp)
} }
// Search by giving a coordinate and a max distance, or bounding box and optional filters // Search by giving a coordinate and a max distance, or bounding box and optional filters
func (t *EvchargersService) Search(request *SearchRequest) (*SearchResponse, error) { func (t *EvchargersService) Search(request *SearchRequest) (*SearchResponse, error) {
rsp := &SearchResponse{} rsp := &SearchResponse{}
return rsp, t.client.Call("evchargers", "Search", request, rsp) return rsp, t.client.Call("evchargers", "Search", request, rsp)
} }
type Address struct { type Address struct {

View File

@@ -16,73 +16,16 @@ type EventService struct {
client *client.Client client *client.Client
} }
// Consume events from a given topic. // Publish a message to the event stream.
func (t *EventService) Consume(request *ConsumeRequest) (*ConsumeResponseStream, error) {
stream, err := t.client.Stream("event", "Consume", request)
if err != nil {
return nil, err
}
return &ConsumeResponseStream{
stream: stream,
}, nil
}
type ConsumeResponseStream struct {
stream *client.Stream
}
func (t *ConsumeResponseStream) Recv() (*ConsumeResponse, error) {
var rsp ConsumeResponse
if err := t.stream.Recv(&rsp); err != nil {
return nil, err
}
return &rsp, nil
}
// Publish a event to the event stream.
func (t *EventService) Publish(request *PublishRequest) (*PublishResponse, error) { func (t *EventService) Publish(request *PublishRequest) (*PublishResponse, error) {
rsp := &PublishResponse{} rsp := &PublishResponse{}
return rsp, t.client.Call("event", "Publish", request, rsp) return rsp, t.client.Call("event", "Publish", request, rsp)
} }
// Read stored events // Subscribe to messages for a given topic.
func (t *EventService) Read(request *ReadRequest) (*ReadResponse, error) { func (t *EventService) Subscribe(request *SubscribeRequest) (*SubscribeResponse, error) {
rsp := &SubscribeResponse{}
rsp := &ReadResponse{} return rsp, t.client.Call("event", "Subscribe", request, rsp)
return rsp, t.client.Call("event", "Read", request, rsp)
}
type ConsumeRequest struct {
// Optional group for the subscription
Group string `json:"group"`
// Optional offset to read from e.g "2006-01-02T15:04:05.999Z07:00"
Offset string `json:"offset"`
// The topic to subscribe to
Topic string `json:"topic"`
}
type ConsumeResponse struct {
// Unique message id
Id string `json:"id"`
// The next json message on the topic
Message map[string]interface{} `json:"message"`
// Timestamp of publishing
Timestamp string `json:"timestamp"`
// The topic subscribed to
Topic string `json:"topic"`
}
type Ev struct {
// event id
Id string `json:"id"`
// event message
Message map[string]interface{} `json:"message"`
// event timestamp
Timestamp string `json:"timestamp"`
} }
type PublishRequest struct { type PublishRequest struct {
@@ -95,16 +38,16 @@ type PublishRequest struct {
type PublishResponse struct { type PublishResponse struct {
} }
type ReadRequest struct { type SubscribeRequest struct {
// number of events to read; default 25 // Optional group for the subscription
Limit int32 `json:"limit"` Group string `json:"group"`
// offset for the events; default 0 // The topic to subscribe to
Offset int32 `json:"offset"`
// topic to read from
Topic string `json:"topic"` Topic string `json:"topic"`
} }
type ReadResponse struct { type SubscribeResponse struct {
// the events // The next json message on the topic
Events []Ev `json:"events"` Message map[string]interface{} `json:"message"`
// The topic subscribed to
Topic string `json:"topic"`
} }

View File

@@ -29,6 +29,5 @@ func LookupPostcode() {
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
} }
``` ```

View File

@@ -1,18 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/address"
)
// Lookup a list of UK addresses by postcode
func main() {
addressService := address.NewAddressService(os.Getenv("M3O_API_TOKEN"))
rsp, err := addressService.LookupPostcode(&address.LookupPostcodeRequest{
Postcode: "SW1A 2AA",
})
fmt.Println(rsp, err)
}

View File

@@ -29,6 +29,5 @@ func AskAquestion() {
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
} }
``` ```

View File

@@ -1,18 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/answer"
)
// Ask a question and receive an instant answer
func main() {
answerService := answer.NewAnswerService(os.Getenv("M3O_API_TOKEN"))
rsp, err := answerService.Question(&answer.QuestionRequest{
Query: "microsoft",
})
fmt.Println(rsp, err)
}

View File

@@ -4,6 +4,62 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Cache/api](htt
Endpoints: Endpoints:
## Increment
Increment a value (if it's a number)
[https://m3o.com/cache/api#Increment](https://m3o.com/cache/api#Increment)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/cache"
)
// Increment a value (if it's a number)
func IncrementAvalue() {
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cacheService.Increment(&cache.IncrementRequest{
Key: "counter",
Value: 2,
})
fmt.Println(rsp, err)
}
```
## Decrement
Decrement a value (if it's a number)
[https://m3o.com/cache/api#Decrement](https://m3o.com/cache/api#Decrement)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/cache"
)
// Decrement a value (if it's a number)
func DecrementAvalue() {
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cacheService.Decrement(&cache.DecrementRequest{
Key: "counter",
Value: 2,
})
fmt.Println(rsp, err)
}
```
## Set ## Set
Set an item in the cache. Overwrites any existing value already set. Set an item in the cache. Overwrites any existing value already set.
@@ -30,12 +86,11 @@ Value: "bar",
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
} }
``` ```
## Get ## Get
Get an item from the cache by key. If key is not found, an empty response is returned. Get an item from the cache by key
[https://m3o.com/cache/api#Get](https://m3o.com/cache/api#Get) [https://m3o.com/cache/api#Get](https://m3o.com/cache/api#Get)
@@ -50,7 +105,7 @@ import(
"go.m3o.com/cache" "go.m3o.com/cache"
) )
// Get an item from the cache by key. If key is not found, an empty response is returned. // Get an item from the cache by key
func GetAvalue() { func GetAvalue() {
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cacheService.Get(&cache.GetRequest{ rsp, err := cacheService.Get(&cache.GetRequest{
@@ -58,12 +113,11 @@ func GetAvalue() {
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
} }
``` ```
## Delete ## Delete
Delete a value from the cache. If key not found a success response is returned. Delete a value from the cache
[https://m3o.com/cache/api#Delete](https://m3o.com/cache/api#Delete) [https://m3o.com/cache/api#Delete](https://m3o.com/cache/api#Delete)
@@ -78,7 +132,7 @@ import(
"go.m3o.com/cache" "go.m3o.com/cache"
) )
// Delete a value from the cache. If key not found a success response is returned. // Delete a value from the cache
func DeleteAvalue() { func DeleteAvalue() {
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cacheService.Delete(&cache.DeleteRequest{ rsp, err := cacheService.Delete(&cache.DeleteRequest{
@@ -86,64 +140,5 @@ func DeleteAvalue() {
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
}
```
## Increment
Increment a value (if it's a number). If key not found it is equivalent to set.
[https://m3o.com/cache/api#Increment](https://m3o.com/cache/api#Increment)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/cache"
)
// Increment a value (if it's a number). If key not found it is equivalent to set.
func IncrementAvalue() {
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cacheService.Increment(&cache.IncrementRequest{
Key: "counter",
Value: 2,
})
fmt.Println(rsp, err)
}
```
## Decrement
Decrement a value (if it's a number). If key not found it is equivalent to set.
[https://m3o.com/cache/api#Decrement](https://m3o.com/cache/api#Decrement)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/cache"
)
// Decrement a value (if it's a number). If key not found it is equivalent to set.
func DecrementAvalue() {
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cacheService.Decrement(&cache.DecrementRequest{
Key: "counter",
Value: 2,
})
fmt.Println(rsp, err)
} }
``` ```

View File

@@ -7,7 +7,7 @@ import (
"go.m3o.com/cache" "go.m3o.com/cache"
) )
// Decrement a value (if it's a number). If key not found it is equivalent to set. // Decrement a value (if it's a number)
func DecrementAvalue() { func DecrementAvalue() {
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cacheService.Decrement(&cache.DecrementRequest{ rsp, err := cacheService.Decrement(&cache.DecrementRequest{

View File

@@ -1,19 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/cache"
)
// Decrement a value (if it's a number). If key not found it is equivalent to set.
func main() {
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cacheService.Decrement(&cache.DecrementRequest{
Key: "counter",
Value: 2,
})
fmt.Println(rsp, err)
}

View File

@@ -7,7 +7,7 @@ import (
"go.m3o.com/cache" "go.m3o.com/cache"
) )
// Delete a value from the cache. If key not found a success response is returned. // Delete a value from the cache
func DeleteAvalue() { func DeleteAvalue() {
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cacheService.Delete(&cache.DeleteRequest{ rsp, err := cacheService.Delete(&cache.DeleteRequest{

View File

@@ -1,18 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/cache"
)
// Delete a value from the cache. If key not found a success response is returned.
func main() {
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cacheService.Delete(&cache.DeleteRequest{
Key: "foo",
})
fmt.Println(rsp, err)
}

View File

@@ -7,7 +7,7 @@ import (
"go.m3o.com/cache" "go.m3o.com/cache"
) )
// Get an item from the cache by key. If key is not found, an empty response is returned. // Get an item from the cache by key
func GetAvalue() { func GetAvalue() {
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cacheService.Get(&cache.GetRequest{ rsp, err := cacheService.Get(&cache.GetRequest{

View File

@@ -1,18 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/cache"
)
// Get an item from the cache by key. If key is not found, an empty response is returned.
func main() {
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cacheService.Get(&cache.GetRequest{
Key: "foo",
})
fmt.Println(rsp, err)
}

View File

@@ -7,7 +7,7 @@ import (
"go.m3o.com/cache" "go.m3o.com/cache"
) )
// Increment a value (if it's a number). If key not found it is equivalent to set. // Increment a value (if it's a number)
func IncrementAvalue() { func IncrementAvalue() {
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN")) cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cacheService.Increment(&cache.IncrementRequest{ rsp, err := cacheService.Increment(&cache.IncrementRequest{

View File

@@ -1,19 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/cache"
)
// Increment a value (if it's a number). If key not found it is equivalent to set.
func main() {
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cacheService.Increment(&cache.IncrementRequest{
Key: "counter",
Value: 2,
})
fmt.Println(rsp, err)
}

View File

View File

@@ -1,19 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/cache"
)
// Set an item in the cache. Overwrites any existing value already set.
func main() {
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cacheService.Set(&cache.SetRequest{
Key: "foo",
Value: "bar",
})
fmt.Println(rsp, err)
}

View File

@@ -4,62 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Crypto/api](ht
Endpoints: Endpoints:
## Quote
Get the last quote for a given crypto ticker
[https://m3o.com/crypto/api#Quote](https://m3o.com/crypto/api#Quote)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/crypto"
)
// Get the last quote for a given crypto ticker
func GetAcryptocurrencyQuote() {
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cryptoService.Quote(&crypto.QuoteRequest{
Symbol: "BTCUSD",
})
fmt.Println(rsp, err)
}
```
## History
Returns the history for the previous close
[https://m3o.com/crypto/api#History](https://m3o.com/crypto/api#History)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/crypto"
)
// Returns the history for the previous close
func GetPreviousClose() {
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cryptoService.History(&crypto.HistoryRequest{
Symbol: "BTCUSD",
})
fmt.Println(rsp, err)
}
```
## News ## News
Get news related to a currency Get news related to a currency
@@ -85,7 +29,6 @@ func GetCryptocurrencyNews() {
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
} }
``` ```
## Price ## Price
@@ -113,6 +56,59 @@ func GetCryptocurrencyPrice() {
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
}
```
## Quote
Get the last quote for a given crypto ticker
[https://m3o.com/crypto/api#Quote](https://m3o.com/crypto/api#Quote)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/crypto"
)
// Get the last quote for a given crypto ticker
func GetAcryptocurrencyQuote() {
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cryptoService.Quote(&crypto.QuoteRequest{
Symbol: "BTCUSD",
})
fmt.Println(rsp, err)
}
```
## History
Returns the history for the previous close
[https://m3o.com/crypto/api#History](https://m3o.com/crypto/api#History)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/crypto"
)
// Returns the history for the previous close
func GetPreviousClose() {
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cryptoService.History(&crypto.HistoryRequest{
Symbol: "BTCUSD",
})
fmt.Println(rsp, err)
} }
``` ```

View File

@@ -1,18 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/crypto"
)
// Returns the history for the previous close
func main() {
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cryptoService.History(&crypto.HistoryRequest{
Symbol: "BTCUSD",
})
fmt.Println(rsp, err)
}

View File

@@ -1,18 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/crypto"
)
// Get news related to a currency
func main() {
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cryptoService.News(&crypto.NewsRequest{
Symbol: "BTCUSD",
})
fmt.Println(rsp, err)
}

View File

@@ -1,18 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/crypto"
)
// Get the last price for a given crypto ticker
func main() {
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cryptoService.Price(&crypto.PriceRequest{
Symbol: "BTCUSD",
})
fmt.Println(rsp, err)
}

View File

@@ -1,18 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/crypto"
)
// Get the last quote for a given crypto ticker
func main() {
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cryptoService.Quote(&crypto.QuoteRequest{
Symbol: "BTCUSD",
})
fmt.Println(rsp, err)
}

View File

@@ -4,61 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Currency/api](
Endpoints: Endpoints:
## Codes
Codes returns the supported currency codes for the API
[https://m3o.com/currency/api#Codes](https://m3o.com/currency/api#Codes)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/currency"
)
// Codes returns the supported currency codes for the API
func GetSupportedCodes() {
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
rsp, err := currencyService.Codes(&currency.CodesRequest{
})
fmt.Println(rsp, err)
}
```
## Rates
Rates returns the currency rates for a given code e.g USD
[https://m3o.com/currency/api#Rates](https://m3o.com/currency/api#Rates)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/currency"
)
// Rates returns the currency rates for a given code e.g USD
func GetRatesForUsd() {
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
rsp, err := currencyService.Rates(&currency.RatesRequest{
Code: "USD",
})
fmt.Println(rsp, err)
}
```
## Convert ## Convert
Convert returns the currency conversion rate between two pairs e.g USD/GBP Convert returns the currency conversion rate between two pairs e.g USD/GBP
@@ -85,7 +30,6 @@ To: "GBP",
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
} }
``` ```
## Convert ## Convert
@@ -115,7 +59,6 @@ To: "GBP",
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
} }
``` ```
## History ## History
@@ -144,6 +87,58 @@ Date: "2021-05-30",
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
}
```
## Codes
Codes returns the supported currency codes for the API
[https://m3o.com/currency/api#Codes](https://m3o.com/currency/api#Codes)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/currency"
)
// Codes returns the supported currency codes for the API
func GetSupportedCodes() {
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
rsp, err := currencyService.Codes(&currency.CodesRequest{
})
fmt.Println(rsp, err)
}
```
## Rates
Rates returns the currency rates for a given code e.g USD
[https://m3o.com/currency/api#Rates](https://m3o.com/currency/api#Rates)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/currency"
)
// Rates returns the currency rates for a given code e.g USD
func GetRatesForUsd() {
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
rsp, err := currencyService.Rates(&currency.RatesRequest{
Code: "USD",
})
fmt.Println(rsp, err)
} }
``` ```

View File

@@ -1,16 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/currency"
)
// Codes returns the supported currency codes for the API
func main() {
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
rsp, err := currencyService.Codes(&currency.CodesRequest{})
fmt.Println(rsp, err)
}

View File

@@ -1,20 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/currency"
)
// Convert returns the currency conversion rate between two pairs e.g USD/GBP
func main() {
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
rsp, err := currencyService.Convert(&currency.ConvertRequest{
Amount: 10,
From: "USD",
To: "GBP",
})
fmt.Println(rsp, err)
}

View File

@@ -1,19 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/currency"
)
// Convert returns the currency conversion rate between two pairs e.g USD/GBP
func main() {
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
rsp, err := currencyService.Convert(&currency.ConvertRequest{
From: "USD",
To: "GBP",
})
fmt.Println(rsp, err)
}

View File

@@ -1,19 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/currency"
)
// Returns the historic rates for a currency on a given date
func main() {
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
rsp, err := currencyService.History(&currency.HistoryRequest{
Code: "USD",
Date: "2021-05-30",
})
fmt.Println(rsp, err)
}

View File

@@ -1,18 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/currency"
)
// Rates returns the currency rates for a given code e.g USD
func main() {
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
rsp, err := currencyService.Rates(&currency.RatesRequest{
Code: "USD",
})
fmt.Println(rsp, err)
}

View File

@@ -4,12 +4,12 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Db/api](https:
Endpoints: Endpoints:
## ListTables ## Truncate
List tables in the DB Truncate the records in a table
[https://m3o.com/db/api#ListTables](https://m3o.com/db/api#ListTables) [https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate)
```go ```go
package example package example
@@ -21,22 +21,22 @@ import(
"go.m3o.com/db" "go.m3o.com/db"
) )
// List tables in the DB // Truncate the records in a table
func ListTables() { func TruncateTable() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.ListTables(&db.ListTablesRequest{ rsp, err := dbService.Truncate(&db.TruncateRequest{
Table: "users",
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
} }
``` ```
## RenameTable ## Count
Rename a table Count records in a table
[https://m3o.com/db/api#RenameTable](https://m3o.com/db/api#RenameTable) [https://m3o.com/db/api#Count](https://m3o.com/db/api#Count)
```go ```go
package example package example
@@ -48,16 +48,47 @@ import(
"go.m3o.com/db" "go.m3o.com/db"
) )
// Rename a table // Count records in a table
func RenameTable() { func CountEntriesInAtable() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.RenameTable(&db.RenameTableRequest{ rsp, err := dbService.Count(&db.CountRequest{
From: "events", Table: "users",
To: "events_backup",
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
}
```
## Create
Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
func CreateArecord() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Create(&db.CreateRequest{
Record: map[string]interface{}{
"name": "Jane",
"age": 42,
"isActive": true,
"id": "1",
},
Table: "users",
})
fmt.Println(rsp, err)
} }
``` ```
## Update ## Update
@@ -89,7 +120,6 @@ Table: "users",
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
} }
``` ```
## Read ## Read
@@ -118,97 +148,6 @@ Table: "users",
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
}
```
## DropTable
Drop a table in the DB
[https://m3o.com/db/api#DropTable](https://m3o.com/db/api#DropTable)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Drop a table in the DB
func DropTable() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.DropTable(&db.DropTableRequest{
Table: "users",
})
fmt.Println(rsp, err)
}
```
## Count
Count records in a table
[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Count records in a table
func CountEntriesInAtable() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Count(&db.CountRequest{
Table: "users",
})
fmt.Println(rsp, err)
}
```
## Create
Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
func CreateArecord() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Create(&db.CreateRequest{
Record: map[string]interface{}{
"id": "1",
"name": "Jane",
"age": 42,
"isActive": true,
},
Table: "users",
})
fmt.Println(rsp, err)
} }
``` ```
## Delete ## Delete
@@ -237,34 +176,5 @@ Table: "users",
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
}
```
## Truncate
Truncate the records in a table
[https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Truncate the records in a table
func TruncateTable() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Truncate(&db.TruncateRequest{
Table: "users",
})
fmt.Println(rsp, err)
} }
``` ```

View File

@@ -1,18 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/db"
)
// Count records in a table
func main() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Count(&db.CountRequest{
Table: "users",
})
fmt.Println(rsp, err)
}

View File

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

View File

@@ -1,24 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/db"
)
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
func main() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Create(&db.CreateRequest{
Record: map[string]interface{}{
"id": "1",
"name": "Jane",
"age": 42,
"isActive": true,
},
Table: "users",
})
fmt.Println(rsp, err)
}

View File

@@ -1,19 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/db"
)
// Delete a record in the database by id.
func main() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Delete(&db.DeleteRequest{
Id: "1",
Table: "users",
})
fmt.Println(rsp, err)
}

View File

@@ -1,18 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/db"
)
// Drop a table in the DB
func main() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.DropTable(&db.DropTableRequest{
Table: "users",
})
fmt.Println(rsp, err)
}

View File

@@ -1,16 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/db"
)
// List tables in the DB
func main() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.ListTables(&db.ListTablesRequest{})
fmt.Println(rsp, err)
}

View File

@@ -1,19 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/db"
)
// Read data from a table. Lookup can be by ID or via querying any field in the record.
func main() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Read(&db.ReadRequest{
Query: "age == 43",
Table: "users",
})
fmt.Println(rsp, err)
}

View File

@@ -1,19 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/db"
)
// Rename a table
func main() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.RenameTable(&db.RenameTableRequest{
From: "events",
To: "events_backup",
})
fmt.Println(rsp, err)
}

View File

@@ -1,18 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/db"
)
// Truncate the records in a table
func main() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Truncate(&db.TruncateRequest{
Table: "users",
})
fmt.Println(rsp, err)
}

View File

@@ -12,8 +12,8 @@ func UpdateArecord() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) dbService := db.NewDbService(os.Getenv("M3O_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",
}) })

View File

@@ -1,22 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/db"
)
// Update a record in the database. Include an "id" in the record to update.
func main() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Update(&db.UpdateRequest{
Record: map[string]interface{}{
"id": "1",
"age": 43,
},
Table: "users",
})
fmt.Println(rsp, err)
}

View File

@@ -33,6 +33,5 @@ Please verify your email by clicking this link: $micro_verification_link`,
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
} }
``` ```

View File

@@ -1,22 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/email"
)
// Send an email by passing in from, to, subject, and a text or html body
func main() {
emailService := email.NewEmailService(os.Getenv("M3O_API_TOKEN"))
rsp, err := emailService.Send(&email.SendRequest{
From: "Awesome Dot Com",
Subject: "Email verification",
TextBody: `Hi there,
Please verify your email by clicking this link: $micro_verification_link`,
})
fmt.Println(rsp, err)
}

View File

@@ -4,36 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Emoji/api](htt
Endpoints: Endpoints:
## Send
Send an emoji to anyone via SMS. Messages are sent in the form '<message> Sent from <from>'
[https://m3o.com/emoji/api#Send](https://m3o.com/emoji/api#Send)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/emoji"
)
// Send an emoji to anyone via SMS. Messages are sent in the form '<message> Sent from <from>'
func SendAtextContainingAnEmojiToAnyoneViaSms() {
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
rsp, err := emojiService.Send(&emoji.SendRequest{
From: "Alice",
Message: "let's grab a :beer:",
To: "+44782669123",
})
fmt.Println(rsp, err)
}
```
## Find ## Find
Find an emoji by its alias e.g :beer: Find an emoji by its alias e.g :beer:
@@ -59,7 +29,6 @@ func FindEmoji() {
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
} }
``` ```
## Flag ## Flag
@@ -86,7 +55,6 @@ func GetFlagByCountryCode() {
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
} }
``` ```
## Print ## Print
@@ -116,6 +84,34 @@ func PrintTextIncludingEmoji() {
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
}
```
## Send
Send an emoji to anyone via SMS. Messages are sent in the form '<message> Sent from <from>'
[https://m3o.com/emoji/api#Send](https://m3o.com/emoji/api#Send)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/emoji"
)
// Send an emoji to anyone via SMS. Messages are sent in the form '<message> Sent from <from>'
func SendAtextContainingAnEmojiToAnyoneViaSms() {
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
rsp, err := emojiService.Send(&emoji.SendRequest{
From: "Alice",
Message: "let's grab a :beer:",
To: "+44782669123",
})
fmt.Println(rsp, err)
} }
``` ```

View File

@@ -1,18 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/emoji"
)
// Find an emoji by its alias e.g :beer:
func main() {
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
rsp, err := emojiService.Find(&emoji.FindRequest{
Alias: ":beer:",
})
fmt.Println(rsp, err)
}

View File

@@ -1,16 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/emoji"
)
// Get the flag for a country. Requires country code e.g GB for great britain
func main() {
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
rsp, err := emojiService.Flag(&emoji.FlagRequest{})
fmt.Println(rsp, err)
}

View File

@@ -1,19 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/emoji"
)
// Print text and renders the emojis with aliases e.g
// let's grab a :beer: becomes let's grab a 🍺
func main() {
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
rsp, err := emojiService.Print(&emoji.PrintRequest{
Text: "let's grab a :beer:",
})
fmt.Println(rsp, err)
}

View File

@@ -1,20 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/emoji"
)
// Send an emoji to anyone via SMS. Messages are sent in the form '<message> Sent from <from>'
func main() {
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
rsp, err := emojiService.Send(&emoji.SendRequest{
From: "Alice",
Message: "let's grab a :beer:",
To: "+44782669123",
})
fmt.Println(rsp, err)
}

View File

@@ -33,7 +33,6 @@ Location: &evchargers.Coordinates{
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
} }
``` ```
## Search ## Search
@@ -62,7 +61,6 @@ func SearchByBoundingBox() {
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
} }
``` ```
## Search ## Search
@@ -95,7 +93,6 @@ Location: &evchargers.Coordinates{
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
} }
``` ```
## ReferenceData ## ReferenceData
@@ -122,6 +119,5 @@ func GetReferenceData() {
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
} }
``` ```

View File

@@ -1,16 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/evchargers"
)
// Retrieve reference data as used by this API and in conjunction with the Search endpoint
func main() {
evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN"))
rsp, err := evchargersService.ReferenceData(&evchargers.ReferenceDataRequest{})
fmt.Println(rsp, err)
}

View File

@@ -1,18 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/evchargers"
)
// Search by giving a coordinate and a max distance, or bounding box and optional filters
func main() {
evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN"))
rsp, err := evchargersService.Search(&evchargers.SearchRequest{
Box: &evchargers.BoundingBox{},
})
fmt.Println(rsp, err)
}

View File

@@ -1,22 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/evchargers"
)
// Search by giving a coordinate and a max distance, or bounding box and optional filters
func main() {
evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN"))
rsp, err := evchargersService.Search(&evchargers.SearchRequest{
Distance: 2000,
Location: &evchargers.Coordinates{
Latitude: 51.53336351319885,
Longitude: -0.0252,
},
})
fmt.Println(rsp, err)
}

View File

@@ -1,23 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/evchargers"
)
// Search by giving a coordinate and a max distance, or bounding box and optional filters
func main() {
evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN"))
rsp, err := evchargersService.Search(&evchargers.SearchRequest{
Distance: 2000,
Levels: []string{"3"},
Location: &evchargers.Coordinates{
Latitude: 51.53336351319885,
Longitude: -0.0252,
},
})
fmt.Println(rsp, err)
}

View File

@@ -6,7 +6,7 @@ Endpoints:
## Publish ## Publish
Publish a event to the event stream. Publish a message to the event stream.
[https://m3o.com/event/api#Publish](https://m3o.com/event/api#Publish) [https://m3o.com/event/api#Publish](https://m3o.com/event/api#Publish)
@@ -21,28 +21,27 @@ import(
"go.m3o.com/event" "go.m3o.com/event"
) )
// Publish a event to the event stream. // Publish a message to the event stream.
func PublishAnEvent() { func PublishAmessage() {
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN")) eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
rsp, err := eventService.Publish(&event.PublishRequest{ rsp, err := eventService.Publish(&event.PublishRequest{
Message: map[string]interface{}{ Message: map[string]interface{}{
"user": "john",
"id": "1", "id": "1",
"type": "signup", "type": "signup",
"user": "john",
}, },
Topic: "user", Topic: "user",
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
} }
``` ```
## Consume ## Subscribe
Consume events from a given topic. Subscribe to messages for a given topic.
[https://m3o.com/event/api#Consume](https://m3o.com/event/api#Consume) [https://m3o.com/event/api#Subscribe](https://m3o.com/event/api#Subscribe)
```go ```go
package example package example
@@ -54,55 +53,13 @@ import(
"go.m3o.com/event" "go.m3o.com/event"
) )
// Consume events from a given topic. // Subscribe to messages for a given topic.
func ConsumeFromAtopic() { func SubscribeToAtopic() {
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN")) eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
rsp, err := eventService.Subscribe(&event.SubscribeRequest{
stream, err := eventService.Consume(&event.ConsumeRequest{
Topic: "user",
})
if err != nil {
fmt.Println(err)
return
}
for {
rsp, err := stream.Recv()
if err != nil {
fmt.Println(err)
return
}
fmt.Println(rsp)
}
}
```
## Read
Read stored events
[https://m3o.com/event/api#Read](https://m3o.com/event/api#Read)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/event"
)
// Read stored events
func ReadEventsOnAtopic() {
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
rsp, err := eventService.Read(&event.ReadRequest{
Topic: "user", Topic: "user",
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
} }
``` ```

View File

@@ -1,31 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/event"
)
// Consume events from a given topic.
func main() {
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
stream, err := eventService.Consume(&event.ConsumeRequest{
Topic: "user",
})
if err != nil {
fmt.Println(err)
return
}
for {
rsp, err := stream.Recv()
if err != nil {
fmt.Println(err)
return
}
fmt.Println(rsp)
}
}

View File

@@ -12,9 +12,9 @@ func PublishAmessage() {
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN")) eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
rsp, err := eventService.Publish(&event.PublishRequest{ rsp, err := eventService.Publish(&event.PublishRequest{
Message: map[string]interface{}{ Message: map[string]interface{}{
"user": "john",
"id": "1", "id": "1",
"type": "signup", "type": "signup",
"user": "john",
}, },
Topic: "user", Topic: "user",
}) })

View File

@@ -1,22 +0,0 @@
package example
import (
"fmt"
"os"
"go.m3o.com/event"
)
// Publish a event to the event stream.
func PublishAnEvent() {
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
rsp, err := eventService.Publish(&event.PublishRequest{
Message: map[string]interface{}{
"id": "1",
"type": "signup",
"user": "john",
},
Topic: "user",
})
fmt.Println(rsp, err)
}

View File

@@ -1,23 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/event"
)
// Publish a event to the event stream.
func main() {
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
rsp, err := eventService.Publish(&event.PublishRequest{
Message: map[string]interface{}{
"user": "john",
"id": "1",
"type": "signup",
},
Topic: "user",
})
fmt.Println(rsp, err)
}

View File

@@ -1,17 +0,0 @@
package example
import (
"fmt"
"os"
"go.m3o.com/event"
)
// Read stored events
func ReadEventsOnAtopic() {
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
rsp, err := eventService.Read(&event.ReadRequest{
Topic: "user",
})
fmt.Println(rsp, err)
}

View File

@@ -1,18 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/event"
)
// Read stored events
func main() {
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
rsp, err := eventService.Read(&event.ReadRequest{
Topic: "user",
})
fmt.Println(rsp, err)
}

View File

@@ -7,10 +7,10 @@ import (
"go.m3o.com/event" "go.m3o.com/event"
) )
// Consume events from a given topic. // Subscribe to messages for a given topic.
func ConsumeFromAtopic() { func SubscribeToAtopic() {
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN")) eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
rsp, err := eventService.Consume(&event.ConsumeRequest{ rsp, err := eventService.Subscribe(&event.SubscribeRequest{
Topic: "user", Topic: "user",
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)

View File

@@ -33,7 +33,6 @@ func SaveFile() {
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
} }
``` ```
## List ## List
@@ -61,7 +60,6 @@ func ListFiles() {
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
} }
``` ```
## Delete ## Delete
@@ -90,7 +88,6 @@ Project: "examples",
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
} }
``` ```
## Read ## Read
@@ -119,6 +116,5 @@ Project: "examples",
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
} }
``` ```

View File

@@ -1,19 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/file"
)
// Delete a file by project name/path
func main() {
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
rsp, err := fileService.Delete(&file.DeleteRequest{
Path: "/document/text-files/file.txt",
Project: "examples",
})
fmt.Println(rsp, err)
}

View File

@@ -1,18 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/file"
)
// List files by their project and optionally a path.
func main() {
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
rsp, err := fileService.List(&file.ListRequest{
Project: "examples",
})
fmt.Println(rsp, err)
}

View File

@@ -1,19 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/file"
)
// Read a file by path
func main() {
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
rsp, err := fileService.Read(&file.ReadRequest{
Path: "/document/text-files/file.txt",
Project: "examples",
})
fmt.Println(rsp, err)
}

View File

@@ -1,22 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/file"
)
// Save a file
func main() {
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
rsp, err := fileService.Save(&file.SaveRequest{
File: &file.Record{
Content: "file content example",
Path: "/document/text-files/file.txt",
Project: "examples",
},
})
fmt.Println(rsp, err)
}

View File

@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Forex/api](htt
Endpoints: Endpoints:
## Price
Get the latest price for a given forex ticker
[https://m3o.com/forex/api#Price](https://m3o.com/forex/api#Price)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/forex"
)
// Get the latest price for a given forex ticker
func GetAnFxPrice() {
forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN"))
rsp, err := forexService.Price(&forex.PriceRequest{
Symbol: "GBPUSD",
})
fmt.Println(rsp, err)
}
```
## Quote ## Quote
Get the latest quote for the forex Get the latest quote for the forex
@@ -57,7 +29,6 @@ func GetAfxQuote() {
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
} }
``` ```
## History ## History
@@ -85,6 +56,32 @@ func GetPreviousClose() {
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
}
```
## Price
Get the latest price for a given forex ticker
[https://m3o.com/forex/api#Price](https://m3o.com/forex/api#Price)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/forex"
)
// Get the latest price for a given forex ticker
func GetAnFxPrice() {
forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN"))
rsp, err := forexService.Price(&forex.PriceRequest{
Symbol: "GBPUSD",
})
fmt.Println(rsp, err)
} }
``` ```

View File

@@ -1,18 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/forex"
)
// Returns the data for the previous close
func main() {
forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN"))
rsp, err := forexService.History(&forex.HistoryRequest{
Symbol: "GBPUSD",
})
fmt.Println(rsp, err)
}

View File

@@ -1,18 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/forex"
)
// Get the latest price for a given forex ticker
func main() {
forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN"))
rsp, err := forexService.Price(&forex.PriceRequest{
Symbol: "GBPUSD",
})
fmt.Println(rsp, err)
}

View File

@@ -1,18 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/forex"
)
// Get the latest quote for the forex
func main() {
forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN"))
rsp, err := forexService.Quote(&forex.QuoteRequest{
Symbol: "GBPUSD",
})
fmt.Println(rsp, err)
}

View File

@@ -4,35 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Function/api](
Endpoints: Endpoints:
## Describe
Get the info for a deployed function
[https://m3o.com/function/api#Describe](https://m3o.com/function/api#Describe)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Get the info for a deployed function
func DescribeFunctionStatus() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Describe(&function.DescribeRequest{
Name: "my-first-func",
Project: "tests",
})
fmt.Println(rsp, err)
}
```
## Deploy ## Deploy
Deploy a group of functions Deploy a group of functions
@@ -62,7 +33,6 @@ Runtime: "nodejs14",
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
} }
``` ```
## Call ## Call
@@ -92,7 +62,6 @@ Request: map[string]interface{}{
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
} }
``` ```
## List ## List
@@ -119,7 +88,6 @@ func ListFunctions() {
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
} }
``` ```
## Delete ## Delete
@@ -148,6 +116,33 @@ Project: "tests",
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
}
```
## Describe
Get the info for a deployed function
[https://m3o.com/function/api#Describe](https://m3o.com/function/api#Describe)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Get the info for a deployed function
func DescribeFunctionStatus() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Describe(&function.DescribeRequest{
Name: "my-first-func",
Project: "tests",
})
fmt.Println(rsp, err)
} }
``` ```

View File

@@ -1,19 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/function"
)
// Call a function by name
func main() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Call(&function.CallRequest{
Name: "my-first-func",
Request: map[string]interface{}{},
})
fmt.Println(rsp, err)
}

View File

@@ -1,19 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/function"
)
// Delete a function by name
func main() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Delete(&function.DeleteRequest{
Name: "my-first-func",
Project: "tests",
})
fmt.Println(rsp, err)
}

View File

@@ -1,22 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/function"
)
// Deploy a group of functions
func main() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Deploy(&function.DeployRequest{
Entrypoint: "helloworld",
Name: "my-first-func",
Project: "tests",
Repo: "github.com/m3o/nodejs-function-example",
Runtime: "nodejs14",
})
fmt.Println(rsp, err)
}

View File

@@ -1,19 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/function"
)
// Get the info for a deployed function
func main() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Describe(&function.DescribeRequest{
Name: "my-first-func",
Project: "tests",
})
fmt.Println(rsp, err)
}

View File

@@ -1,16 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/function"
)
// List all the deployed functions
func main() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.List(&function.ListRequest{})
fmt.Println(rsp, err)
}

View File

@@ -32,7 +32,6 @@ Postcode: "wc2b",
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
} }
``` ```
## Reverse ## Reverse
@@ -61,6 +60,5 @@ Longitude: -0.1216235,
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
} }
``` ```

View File

@@ -1,21 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/geocoding"
)
// Lookup returns a geocoded address including normalized address and gps coordinates. All fields are optional, provide more to get more accurate results
func main() {
geocodingService := geocoding.NewGeocodingService(os.Getenv("M3O_API_TOKEN"))
rsp, err := geocodingService.Lookup(&geocoding.LookupRequest{
Address: "10 russell st",
City: "london",
Country: "uk",
Postcode: "wc2b",
})
fmt.Println(rsp, err)
}

View File

@@ -1,19 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/geocoding"
)
// Reverse lookup an address from gps coordinates
func main() {
geocodingService := geocoding.NewGeocodingService(os.Getenv("M3O_API_TOKEN"))
rsp, err := geocodingService.Reverse(&geocoding.ReverseRequest{
Latitude: 51.5123064,
Longitude: -0.1216235,
})
fmt.Println(rsp, err)
}

View File

@@ -30,6 +30,5 @@ Query: "dogs",
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
} }
``` ```

View File

@@ -1,19 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/gifs"
)
// Search for a GIF
func main() {
gifsService := gifs.NewGifsService(os.Getenv("M3O_API_TOKEN"))
rsp, err := gifsService.Search(&gifs.SearchRequest{
Limit: 2,
Query: "dogs",
})
fmt.Println(rsp, err)
}

View File

@@ -29,6 +29,5 @@ func SearchForVideos() {
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
} }
``` ```

View File

@@ -1,18 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/google"
)
// Search for videos on Google
func main() {
googleService := google.NewGoogleService(os.Getenv("M3O_API_TOKEN"))
rsp, err := googleService.Search(&google.SearchRequest{
Query: "how to make donuts",
})
fmt.Println(rsp, err)
}

View File

@@ -29,7 +29,6 @@ func CallTheHelloworldService() {
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
} }
``` ```
## Stream ## Stream
@@ -50,27 +49,12 @@ import(
) )
// Stream returns a stream of "Hello $name" responses // Stream returns a stream of "Hello $name" responses
func StreamsResponsesFromTheServerUsingWebsockets() { func StreamsAreCurrentlyTemporarilyNotSupportedInClients() {
helloworldService := helloworld.NewHelloworldService(os.Getenv("M3O_API_TOKEN")) helloworldService := helloworld.NewHelloworldService(os.Getenv("M3O_API_TOKEN"))
rsp, err := helloworldService.Stream(&helloworld.StreamRequest{
stream, err := helloworldService.Stream(&helloworld.StreamRequest{ Name: "not supported",
Messages: 10,
Name: "John",
}) })
if err != nil { fmt.Println(rsp, err)
fmt.Println(err)
return
}
for {
rsp, err := stream.Recv()
if err != nil {
fmt.Println(err)
return
}
fmt.Println(rsp)
}
} }
``` ```

View File

@@ -1,18 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/helloworld"
)
// Call returns a personalised "Hello $name" response
func main() {
helloworldService := helloworld.NewHelloworldService(os.Getenv("M3O_API_TOKEN"))
rsp, err := helloworldService.Call(&helloworld.CallRequest{
Name: "John",
})
fmt.Println(rsp, err)
}

View File

@@ -1,31 +0,0 @@
package main
import (
"fmt"
"os"
"go.m3o.com/helloworld"
)
// Stream returns a stream of "Hello $name" responses
func main() {
helloworldService := helloworld.NewHelloworldService(os.Getenv("M3O_API_TOKEN"))
stream, err := helloworldService.Stream(&helloworld.StreamRequest{
Name: "not supported",
})
if err != nil {
fmt.Println(err)
return
}
for {
rsp, err := stream.Recv()
if err != nil {
fmt.Println(err)
return
}
fmt.Println(rsp)
}
}

Some files were not shown because too many files have changed in this diff Show More