Commit from m3o/m3o action

This commit is contained in:
m3o-actions
2021-11-03 15:36:34 +00:00
parent aecab5372c
commit 7335a0576f
182 changed files with 1044 additions and 517 deletions

View File

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

View File

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

10
cache/cache.go vendored
View File

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

View File

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

View File

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

View File

@@ -18,38 +18,50 @@ type DbService struct {
// 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{}
return rsp, t.client.Call("db", "Create", request, rsp)
}
// Delete a record in the database by id.
func (t *DbService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
rsp := &DeleteResponse{}
return rsp, t.client.Call("db", "Delete", request, rsp)
}
// 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) {
rsp := &ReadResponse{}
return rsp, t.client.Call("db", "Read", request, rsp)
}
// Truncate the records in a table
func (t *DbService) Truncate(request *TruncateRequest) (*TruncateResponse, error) {
rsp := &TruncateResponse{}
return rsp, t.client.Call("db", "Truncate", request, rsp)
}
// Update a record in the database. Include an "id" in the record to update.
func (t *DbService) Update(request *UpdateRequest) (*UpdateResponse, error) {
rsp := &UpdateResponse{}
return rsp, t.client.Call("db", "Update", request, rsp)
}
type CountRequest struct {

View File

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

View File

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

View File

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

View File

@@ -17,21 +17,43 @@ type EventService struct {
}
// Consume events from a given topic.
func (t *EventService) Consume(request *ConsumeRequest) (*ConsumeResponse, error) {
rsp := &ConsumeResponse{}
return rsp, t.client.Call("event", "Consume", request, rsp)
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) {
rsp := &PublishResponse{}
return rsp, t.client.Call("event", "Publish", request, rsp)
}
// Read stored events
func (t *EventService) Read(request *ReadRequest) (*ReadResponse, error) {
rsp := &ReadResponse{}
return rsp, t.client.Call("event", "Read", request, rsp)
}
type ConsumeRequest struct {

View File

@@ -14,4 +14,5 @@ func main() {
Postcode: "SW1A 2AA",
})
fmt.Println(rsp, err)
}

View File

@@ -14,4 +14,5 @@ func main() {
Query: "microsoft",
})
fmt.Println(rsp, err)
}

View File

@@ -7,7 +7,7 @@ import (
"go.m3o.com/cache"
)
// Decrement a value (if it's a number)
// 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{
@@ -15,4 +15,5 @@ func main() {
Value: 2,
})
fmt.Println(rsp, err)
}

View File

@@ -7,11 +7,12 @@ import (
"go.m3o.com/cache"
)
// Delete a value from the 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,11 +7,12 @@ import (
"go.m3o.com/cache"
)
// Get an item from the cache by key
// 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"
)
// Increment a value (if it's a number)
// 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{
@@ -15,4 +15,5 @@ func main() {
Value: 2,
})
fmt.Println(rsp, err)
}

View File

@@ -15,4 +15,5 @@ func main() {
Value: "bar",
})
fmt.Println(rsp, err)
}

View File

@@ -14,4 +14,5 @@ func main() {
Symbol: "BTCUSD",
})
fmt.Println(rsp, err)
}

View File

@@ -14,4 +14,5 @@ func main() {
Symbol: "BTCUSD",
})
fmt.Println(rsp, err)
}

View File

@@ -14,4 +14,5 @@ func main() {
Symbol: "BTCUSD",
})
fmt.Println(rsp, err)
}

View File

@@ -14,4 +14,5 @@ func main() {
Symbol: "BTCUSD",
})
fmt.Println(rsp, err)
}

View File

@@ -12,4 +12,5 @@ func main() {
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
rsp, err := currencyService.Codes(&currency.CodesRequest{})
fmt.Println(rsp, err)
}

View File

@@ -16,4 +16,5 @@ func main() {
To: "GBP",
})
fmt.Println(rsp, err)
}

View File

@@ -15,4 +15,5 @@ func main() {
To: "GBP",
})
fmt.Println(rsp, err)
}

View File

@@ -15,4 +15,5 @@ func main() {
Date: "2021-05-30",
})
fmt.Println(rsp, err)
}

View File

@@ -14,4 +14,5 @@ func main() {
Code: "USD",
})
fmt.Println(rsp, err)
}

View File

@@ -4,88 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Db/api](https:
Endpoints:
## Delete
Delete a record in the database by id.
[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Delete a record in the database by id.
func DeleteArecord() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Delete(&db.DeleteRequest{
Id: "1",
Table: "users",
})
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)
}
```
## 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.
@@ -178,3 +96,85 @@ Table: "users",
fmt.Println(rsp, err)
}
```
## Delete
Delete a record in the database by id.
[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Delete a record in the database by id.
func DeleteArecord() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Delete(&db.DeleteRequest{
Id: "1",
Table: "users",
})
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)
}
```
## 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)
}
```

View File

@@ -14,4 +14,5 @@ func main() {
Table: "users",
})
fmt.Println(rsp, err)
}

View File

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

View File

@@ -15,4 +15,5 @@ func main() {
Table: "users",
})
fmt.Println(rsp, err)
}

View File

@@ -15,4 +15,5 @@ func main() {
Table: "users",
})
fmt.Println(rsp, err)
}

View File

@@ -14,4 +14,5 @@ func main() {
Table: "users",
})
fmt.Println(rsp, err)
}

View File

@@ -18,4 +18,5 @@ func main() {
Table: "users",
})
fmt.Println(rsp, err)
}

View File

@@ -18,4 +18,5 @@ func main() {
Please verify your email by clicking this link: $micro_verification_link`,
})
fmt.Println(rsp, err)
}

View File

@@ -14,4 +14,5 @@ func main() {
Alias: ":beer:",
})
fmt.Println(rsp, err)
}

View File

@@ -12,4 +12,5 @@ func main() {
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
rsp, err := emojiService.Flag(&emoji.FlagRequest{})
fmt.Println(rsp, err)
}

View File

@@ -15,4 +15,5 @@ func main() {
Text: "let's grab a :beer:",
})
fmt.Println(rsp, err)
}

View File

@@ -16,4 +16,5 @@ func main() {
To: "+44782669123",
})
fmt.Println(rsp, err)
}

View File

@@ -12,4 +12,5 @@ func main() {
evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN"))
rsp, err := evchargersService.ReferenceData(&evchargers.ReferenceDataRequest{})
fmt.Println(rsp, err)
}

View File

@@ -14,4 +14,5 @@ func main() {
Box: &evchargers.BoundingBox{},
})
fmt.Println(rsp, err)
}

View File

@@ -18,4 +18,5 @@ func main() {
},
})
fmt.Println(rsp, err)
}

View File

@@ -19,4 +19,5 @@ func main() {
},
})
fmt.Println(rsp, err)
}

View File

@@ -4,6 +4,33 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Event/api](htt
Endpoints:
## 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",
})
fmt.Println(rsp, err)
}
```
## Publish
Publish a event to the event stream.
@@ -63,30 +90,3 @@ func ConsumeFromAtopic() {
fmt.Println(rsp, err)
}
```
## 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",
})
fmt.Println(rsp, err)
}
```

View File

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

View File

@@ -19,4 +19,5 @@ func main() {
Topic: "user",
})
fmt.Println(rsp, err)
}

View File

@@ -14,4 +14,5 @@ func main() {
Topic: "user",
})
fmt.Println(rsp, err)
}

View File

@@ -15,4 +15,5 @@ func main() {
Project: "examples",
})
fmt.Println(rsp, err)
}

View File

@@ -14,4 +14,5 @@ func main() {
Project: "examples",
})
fmt.Println(rsp, err)
}

View File

@@ -15,4 +15,5 @@ func main() {
Project: "examples",
})
fmt.Println(rsp, err)
}

View File

@@ -18,4 +18,5 @@ func main() {
},
})
fmt.Println(rsp, err)
}

View File

@@ -14,4 +14,5 @@ func main() {
Symbol: "GBPUSD",
})
fmt.Println(rsp, err)
}

View File

@@ -14,4 +14,5 @@ func main() {
Symbol: "GBPUSD",
})
fmt.Println(rsp, err)
}

View File

@@ -14,4 +14,5 @@ func main() {
Symbol: "GBPUSD",
})
fmt.Println(rsp, err)
}

View File

@@ -15,4 +15,5 @@ func main() {
Request: map[string]interface{}{},
})
fmt.Println(rsp, err)
}

View File

@@ -15,4 +15,5 @@ func main() {
Project: "tests",
})
fmt.Println(rsp, err)
}

View File

@@ -18,4 +18,5 @@ func main() {
Runtime: "nodejs14",
})
fmt.Println(rsp, err)
}

View File

@@ -15,4 +15,5 @@ func main() {
Project: "tests",
})
fmt.Println(rsp, err)
}

View File

@@ -12,4 +12,5 @@ func main() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.List(&function.ListRequest{})
fmt.Println(rsp, err)
}

View File

@@ -17,4 +17,5 @@ func main() {
Postcode: "wc2b",
})
fmt.Println(rsp, err)
}

View File

@@ -15,4 +15,5 @@ func main() {
Longitude: -0.1216235,
})
fmt.Println(rsp, err)
}

View File

@@ -15,4 +15,5 @@ func main() {
Query: "dogs",
})
fmt.Println(rsp, err)
}

View File

@@ -14,4 +14,5 @@ func main() {
Query: "how to make donuts",
})
fmt.Println(rsp, err)
}

View File

@@ -14,4 +14,5 @@ func main() {
Name: "John",
})
fmt.Println(rsp, err)
}

View File

@@ -10,8 +10,22 @@ import (
// Stream returns a stream of "Hello $name" responses
func main() {
helloworldService := helloworld.NewHelloworldService(os.Getenv("M3O_API_TOKEN"))
rsp, err := helloworldService.Stream(&helloworld.StreamRequest{
stream, err := helloworldService.Stream(&helloworld.StreamRequest{
Name: "not supported",
})
fmt.Println(rsp, err)
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,4 +12,5 @@ func main() {
holidaysService := holidays.NewHolidaysService(os.Getenv("M3O_API_TOKEN"))
rsp, err := holidaysService.Countries(&holidays.CountriesRequest{})
fmt.Println(rsp, err)
}

View File

@@ -14,4 +14,5 @@ func main() {
Year: 2022,
})
fmt.Println(rsp, err)
}

View File

@@ -14,4 +14,5 @@ func main() {
Type: "bigflake",
})
fmt.Println(rsp, err)
}

View File

@@ -14,4 +14,5 @@ func main() {
Type: "shortid",
})
fmt.Println(rsp, err)
}

View File

@@ -14,4 +14,5 @@ func main() {
Type: "snowflake",
})
fmt.Println(rsp, err)
}

View File

@@ -14,4 +14,5 @@ func main() {
Type: "uuid",
})
fmt.Println(rsp, err)
}

View File

@@ -12,4 +12,5 @@ func main() {
idService := id.NewIdService(os.Getenv("M3O_API_TOKEN"))
rsp, err := idService.Types(&id.TypesRequest{})
fmt.Println(rsp, err)
}

View File

@@ -4,6 +4,66 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Image/api](htt
Endpoints:
## Upload
Upload an image by either sending a base64 encoded image to this endpoint or a URL.
To resize an image before uploading, see the Resize endpoint.
[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/image"
)
// Upload an image by either sending a base64 encoded image to this endpoint or a URL.
// To resize an image before uploading, see the Resize endpoint.
func UploadAbase64imageToMicrosCdn() {
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
rsp, err := imageService.Upload(&image.UploadRequest{
Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAx0lEQVR4nOzaMaoDMQyE4ZHj+x82vVdhwQoTkzKQEcwP5r0ihT7sbjUTeAJ4HCegXQJYfOYefOyjDuBiz3yjwJBoCIl6QZOeUjTC1Ix1IxEJXF9+0KWsf2bD4bn37OO/c/wuQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9Sa/NG94Tf3j4WBdaxudMEkn4IM2rZBA0wBrvo7aOcpj2emXvLeVt0IGm0GVXUj91mvAAAA//+V2CZl+4AKXwAAAABJRU5ErkJggg==",
Name: "cat.jpeg",
})
fmt.Println(rsp, err)
}
```
## Upload
Upload an image by either sending a base64 encoded image to this endpoint or a URL.
To resize an image before uploading, see the Resize endpoint.
[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/image"
)
// Upload an image by either sending a base64 encoded image to this endpoint or a URL.
// To resize an image before uploading, see the Resize endpoint.
func UploadAnImageFromAurlToMicrosCdn() {
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
rsp, err := imageService.Upload(&image.UploadRequest{
Name: "cat.jpeg",
Url: "somewebsite.com/cat.png",
})
fmt.Println(rsp, err)
}
```
## Resize
Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
@@ -138,63 +198,3 @@ Url: "somewebsite.com/cat.png",
fmt.Println(rsp, err)
}
```
## Upload
Upload an image by either sending a base64 encoded image to this endpoint or a URL.
To resize an image before uploading, see the Resize endpoint.
[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/image"
)
// Upload an image by either sending a base64 encoded image to this endpoint or a URL.
// To resize an image before uploading, see the Resize endpoint.
func UploadAbase64imageToMicrosCdn() {
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
rsp, err := imageService.Upload(&image.UploadRequest{
Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAx0lEQVR4nOzaMaoDMQyE4ZHj+x82vVdhwQoTkzKQEcwP5r0ihT7sbjUTeAJ4HCegXQJYfOYefOyjDuBiz3yjwJBoCIl6QZOeUjTC1Ix1IxEJXF9+0KWsf2bD4bn37OO/c/wuQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9Sa/NG94Tf3j4WBdaxudMEkn4IM2rZBA0wBrvo7aOcpj2emXvLeVt0IGm0GVXUj91mvAAAA//+V2CZl+4AKXwAAAABJRU5ErkJggg==",
Name: "cat.jpeg",
})
fmt.Println(rsp, err)
}
```
## Upload
Upload an image by either sending a base64 encoded image to this endpoint or a URL.
To resize an image before uploading, see the Resize endpoint.
[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/image"
)
// Upload an image by either sending a base64 encoded image to this endpoint or a URL.
// To resize an image before uploading, see the Resize endpoint.
func UploadAnImageFromAurlToMicrosCdn() {
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
rsp, err := imageService.Upload(&image.UploadRequest{
Name: "cat.jpeg",
Url: "somewebsite.com/cat.png",
})
fmt.Println(rsp, err)
}
```

View File

@@ -16,4 +16,5 @@ func main() {
Url: "somewebsite.com/cat.png",
})
fmt.Println(rsp, err)
}

View File

@@ -18,4 +18,5 @@ func main() {
Width: 100,
})
fmt.Println(rsp, err)
}

View File

@@ -22,4 +22,5 @@ func main() {
Width: 100,
})
fmt.Println(rsp, err)
}

View File

@@ -19,4 +19,5 @@ func main() {
Width: 100,
})
fmt.Println(rsp, err)
}

View File

@@ -16,4 +16,5 @@ func main() {
Name: "cat.jpeg",
})
fmt.Println(rsp, err)
}

View File

@@ -16,4 +16,5 @@ func main() {
Url: "somewebsite.com/cat.png",
})
fmt.Println(rsp, err)
}

View File

@@ -14,4 +14,5 @@ func main() {
Ip: "93.148.214.31",
})
fmt.Println(rsp, err)
}

View File

@@ -4,6 +4,41 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Location/api](
Endpoints:
## Save
Save an entity's current position
[https://m3o.com/location/api#Save](https://m3o.com/location/api#Save)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/location"
)
// Save an entity's current position
func SaveAnEntity() {
locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN"))
rsp, err := locationService.Save(&location.SaveRequest{
Entity: &location.Entity{
Id: "1",
Location: &location.Point{
Latitude: 51.511061,
Longitude: -0.120022,
Timestamp: 1622802761,
},
Type: "bike",
},
})
fmt.Println(rsp, err)
}
```
## Read
Read an entity by its ID
@@ -64,38 +99,3 @@ Type: "bike",
fmt.Println(rsp, err)
}
```
## Save
Save an entity's current position
[https://m3o.com/location/api#Save](https://m3o.com/location/api#Save)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/location"
)
// Save an entity's current position
func SaveAnEntity() {
locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN"))
rsp, err := locationService.Save(&location.SaveRequest{
Entity: &location.Entity{
Id: "1",
Location: &location.Point{
Latitude: 51.511061,
Longitude: -0.120022,
Timestamp: 1622802761,
},
Type: "bike",
},
})
fmt.Println(rsp, err)
}
```

View File

@@ -14,4 +14,5 @@ func main() {
Id: "1",
})
fmt.Println(rsp, err)
}

View File

@@ -22,4 +22,5 @@ func main() {
},
})
fmt.Println(rsp, err)
}

View File

@@ -20,4 +20,5 @@ func main() {
Type: "bike",
})
fmt.Println(rsp, err)
}

View File

@@ -19,4 +19,5 @@ func main() {
Topic: "events",
})
fmt.Println(rsp, err)
}

View File

@@ -10,8 +10,22 @@ import (
// Subscribe to messages for a given topic.
func main() {
mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN"))
rsp, err := mqService.Subscribe(&mq.SubscribeRequest{
stream, err := mqService.Subscribe(&mq.SubscribeRequest{
Topic: "events",
})
fmt.Println(rsp, err)
if err != nil {
fmt.Println(err)
return
}
for {
rsp, err := stream.Recv()
if err != nil {
fmt.Println(err)
return
}
fmt.Println(rsp)
}
}

View File

@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Notes/api](htt
Endpoints:
## Create
Create a new note
[https://m3o.com/notes/api#Create](https://m3o.com/notes/api#Create)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/notes"
)
// Create a new note
func CreateAnote() {
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
rsp, err := notesService.Create(&notes.CreateRequest{
Text: "This is my note",
Title: "New Note",
})
fmt.Println(rsp, err)
}
```
## Read
Read a note
@@ -142,31 +170,3 @@ func SubscribeToEvents() {
fmt.Println(rsp, err)
}
```
## Create
Create a new note
[https://m3o.com/notes/api#Create](https://m3o.com/notes/api#Create)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/notes"
)
// Create a new note
func CreateAnote() {
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
rsp, err := notesService.Create(&notes.CreateRequest{
Text: "This is my note",
Title: "New Note",
})
fmt.Println(rsp, err)
}
```

View File

@@ -14,4 +14,5 @@ func main() {
Id: "asim@example.com",
})
fmt.Println(rsp, err)
}

View File

@@ -15,4 +15,5 @@ func main() {
Id: "asim@example.com",
})
fmt.Println(rsp, err)
}

View File

@@ -14,4 +14,5 @@ func main() {
Postcode: "SW1A 2AA",
})
fmt.Println(rsp, err)
}

View File

@@ -12,4 +12,5 @@ func main() {
postcodeService := postcode.NewPostcodeService(os.Getenv("M3O_API_TOKEN"))
rsp, err := postcodeService.Random(&postcode.RandomRequest{})
fmt.Println(rsp, err)
}

View File

@@ -14,4 +14,5 @@ func main() {
Postcode: "SW1A 2AA",
})
fmt.Println(rsp, err)
}

View File

@@ -14,4 +14,5 @@ func main() {
Location: "london",
})
fmt.Println(rsp, err)
}

View File

@@ -15,4 +15,5 @@ func main() {
Text: "https://m3o.com/qr",
})
fmt.Println(rsp, err)
}

View File

@@ -14,4 +14,5 @@ func main() {
Language: "en",
})
fmt.Println(rsp, err)
}

View File

@@ -14,4 +14,5 @@ func main() {
Query: "messenger",
})
fmt.Println(rsp, err)
}

View File

@@ -14,4 +14,5 @@ func main() {
Chapter: 1,
})
fmt.Println(rsp, err)
}

View File

@@ -16,4 +16,5 @@ func main() {
Chapter: 1,
})
fmt.Println(rsp, err)
}

View File

@@ -4,6 +4,40 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Routing/api](h
Endpoints:
## Eta
Get the eta for a route from origin to destination. The eta is an estimated time based on car routes
[https://m3o.com/routing/api#Eta](https://m3o.com/routing/api#Eta)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/routing"
)
// Get the eta for a route from origin to destination. The eta is an estimated time based on car routes
func EtaFromPointAtoPointB() {
routingService := routing.NewRoutingService(os.Getenv("M3O_API_TOKEN"))
rsp, err := routingService.Eta(&routing.EtaRequest{
Destination: &routing.Point{
Latitude: 52.529407,
Longitude: 13.397634,
},
Origin: &routing.Point{
Latitude: 52.517037,
Longitude: 13.38886,
},
})
fmt.Println(rsp, err)
}
```
## Directions
Turn by turn directions from a start point to an end point including maneuvers and bearings
@@ -72,37 +106,3 @@ Origin: &routing.Point{
fmt.Println(rsp, err)
}
```
## Eta
Get the eta for a route from origin to destination. The eta is an estimated time based on car routes
[https://m3o.com/routing/api#Eta](https://m3o.com/routing/api#Eta)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/routing"
)
// Get the eta for a route from origin to destination. The eta is an estimated time based on car routes
func EtaFromPointAtoPointB() {
routingService := routing.NewRoutingService(os.Getenv("M3O_API_TOKEN"))
rsp, err := routingService.Eta(&routing.EtaRequest{
Destination: &routing.Point{
Latitude: 52.529407,
Longitude: 13.397634,
},
Origin: &routing.Point{
Latitude: 52.517037,
Longitude: 13.38886,
},
})
fmt.Println(rsp, err)
}
```

View File

@@ -21,4 +21,5 @@ func main() {
},
})
fmt.Println(rsp, err)
}

View File

@@ -21,4 +21,5 @@ func main() {
},
})
fmt.Println(rsp, err)
}

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