Commit from m3o/m3o action

This commit is contained in:
m3o-actions
2022-02-16 21:45:47 +00:00
parent 5f6e71b7d0
commit f838c439a7
28 changed files with 1154 additions and 1152 deletions

View File

@@ -4,89 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/app/api](https
Endpoints:
## Regions
Return the support regions
[https://m3o.com/app/api#Regions](https://m3o.com/app/api#Regions)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/app"
)
// Return the support regions
func ListRegions() {
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
rsp, err := appService.Regions(&app.RegionsRequest{
})
fmt.Println(rsp, err)
}
```
## Status
Get the status of an app
[https://m3o.com/app/api#Status](https://m3o.com/app/api#Status)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/app"
)
// Get the status of an app
func GetTheStatusOfAnApp() {
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
rsp, err := appService.Status(&app.StatusRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```
## Resolve
Resolve an app by id to its raw backend endpoint
[https://m3o.com/app/api#Resolve](https://m3o.com/app/api#Resolve)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/app"
)
// Resolve an app by id to its raw backend endpoint
func ResolveAppById() {
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
rsp, err := appService.Resolve(&app.ResolveRequest{
Id: "helloworld",
})
fmt.Println(rsp, err)
}
```
## Update
Update the app. The latest source code will be downloaded, built and deployed.
@@ -230,3 +147,86 @@ Repo: "github.com/asim/helloworld",
}
```
## Regions
Return the support regions
[https://m3o.com/app/api#Regions](https://m3o.com/app/api#Regions)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/app"
)
// Return the support regions
func ListRegions() {
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
rsp, err := appService.Regions(&app.RegionsRequest{
})
fmt.Println(rsp, err)
}
```
## Status
Get the status of an app
[https://m3o.com/app/api#Status](https://m3o.com/app/api#Status)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/app"
)
// Get the status of an app
func GetTheStatusOfAnApp() {
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
rsp, err := appService.Status(&app.StatusRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```
## Resolve
Resolve an app by id to its raw backend endpoint
[https://m3o.com/app/api#Resolve](https://m3o.com/app/api#Resolve)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/app"
)
// Resolve an app by id to its raw backend endpoint
func ResolveAppById() {
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
rsp, err := appService.Resolve(&app.ResolveRequest{
Id: "helloworld",
})
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:
## 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)
}
```
## ListKeys
List all the available keys
[https://m3o.com/cache/api#ListKeys](https://m3o.com/cache/api#ListKeys)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/cache"
)
// List all the available keys
func ListTheKeys() {
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cacheService.ListKeys(&cache.ListKeysRequest{
})
fmt.Println(rsp, err)
}
```
## Set
Set an item in the cache. Overwrites any existing value already set.
@@ -118,59 +174,3 @@ Value: 2,
}
```
## 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)
}
```
## ListKeys
List all the available keys
[https://m3o.com/cache/api#ListKeys](https://m3o.com/cache/api#ListKeys)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/cache"
)
// List all the available keys
func ListTheKeys() {
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cacheService.ListKeys(&cache.ListKeysRequest{
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/crypto/api](ht
Endpoints:
## News
Get news related to a currency
[https://m3o.com/crypto/api#News](https://m3o.com/crypto/api#News)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/crypto"
)
// Get news related to a currency
func GetCryptocurrencyNews() {
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cryptoService.News(&crypto.NewsRequest{
Symbol: "BTCUSD",
})
fmt.Println(rsp, err)
}
```
## Price
Get the last price for a given crypto ticker
@@ -88,31 +116,3 @@ func GetPreviousClose() {
}
```
## News
Get news related to a currency
[https://m3o.com/crypto/api#News](https://m3o.com/crypto/api#News)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/crypto"
)
// Get news related to a currency
func GetCryptocurrencyNews() {
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cryptoService.News(&crypto.NewsRequest{
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:
## 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 returns the currency conversion rate between two pairs e.g USD/GBP
@@ -147,3 +92,58 @@ Date: "2021-05-30",
}
```
## 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

@@ -26,10 +26,10 @@ 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,
"id": "1",
},
Table: "example",
@@ -98,12 +98,12 @@ func TruncateTable() {
}
```
## DropTable
## Count
Drop a table in the DB
Count records in a table
[https://m3o.com/db/api#DropTable](https://m3o.com/db/api#DropTable)
[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count)
```go
package example
@@ -115,10 +115,10 @@ import(
"go.m3o.com/db"
)
// Drop a table in the DB
func DropTable() {
// Count records in a table
func CountEntriesInAtable() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.DropTable(&db.DropTableRequest{
rsp, err := dbService.Count(&db.CountRequest{
Table: "example",
})
@@ -240,12 +240,12 @@ Table: "example",
}
```
## Count
## DropTable
Count records in a table
Drop a table in the DB
[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count)
[https://m3o.com/db/api#DropTable](https://m3o.com/db/api#DropTable)
```go
package example
@@ -257,10 +257,10 @@ import(
"go.m3o.com/db"
)
// Count records in a table
func CountEntriesInAtable() {
// Drop a table in the DB
func DropTable() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Count(&db.CountRequest{
rsp, err := dbService.DropTable(&db.DropTableRequest{
Table: "example",
})

View File

@@ -12,10 +12,10 @@ 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: "example",
})

View File

@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/emoji/api](htt
Endpoints:
## Find
Find an emoji by its alias e.g :beer:
[https://m3o.com/emoji/api#Find](https://m3o.com/emoji/api#Find)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/emoji"
)
// Find an emoji by its alias e.g :beer:
func FindEmoji() {
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
rsp, err := emojiService.Find(&emoji.FindRequest{
Alias: ":beer:",
})
fmt.Println(rsp, err)
}
```
## Flag
Get the flag for a country. Requires country code e.g GB for great britain
@@ -119,3 +91,31 @@ To: "+44782669123",
}
```
## Find
Find an emoji by its alias e.g :beer:
[https://m3o.com/emoji/api#Find](https://m3o.com/emoji/api#Find)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/emoji"
)
// Find an emoji by its alias e.g :beer:
func FindEmoji() {
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
rsp, err := emojiService.Find(&emoji.FindRequest{
Alias: ":beer:",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,47 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/event/api](htt
Endpoints:
## Consume
Consume events from a given topic.
[https://m3o.com/event/api#Consume](https://m3o.com/event/api#Consume)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/event"
)
// Consume events from a given topic.
func ConsumeFromAtopic() {
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)
}
}
```
## Read
Read stored events
@@ -106,3 +65,44 @@ Topic: "user",
}
```
## Consume
Consume events from a given topic.
[https://m3o.com/event/api#Consume](https://m3o.com/event/api#Consume)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/event"
)
// Consume events from a given topic.
func ConsumeFromAtopic() {
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

@@ -4,6 +4,117 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/function/api](
Endpoints:
## Delete
Delete a function by name
[https://m3o.com/function/api#Delete](https://m3o.com/function/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Delete a function by name
func DeleteAfunction() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Delete(&function.DeleteRequest{
Name: "helloworld",
})
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: "helloworld",
})
fmt.Println(rsp, err)
}
```
## Regions
Return a list of supported regions
[https://m3o.com/function/api#Regions](https://m3o.com/function/api#Regions)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Return a list of supported regions
func ListRegions() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Regions(&function.RegionsRequest{
})
fmt.Println(rsp, err)
}
```
## Proxy
Return the backend url for proxying
[https://m3o.com/function/api#Proxy](https://m3o.com/function/api#Proxy)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Return the backend url for proxying
func ProxyUrl() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Proxy(&function.ProxyRequest{
Id: "helloworld",
})
fmt.Println(rsp, err)
}
```
## Deploy
Deploy a group of functions
@@ -64,60 +175,6 @@ func UpdateAfunction() {
})
fmt.Println(rsp, err)
}
```
## List
List all the deployed functions
[https://m3o.com/function/api#List](https://m3o.com/function/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// List all the deployed functions
func ListFunctions() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.List(&function.ListRequest{
})
fmt.Println(rsp, err)
}
```
## Regions
Return a list of supported regions
[https://m3o.com/function/api#Regions](https://m3o.com/function/api#Regions)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Return a list of supported regions
func ListRegions() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Regions(&function.RegionsRequest{
})
fmt.Println(rsp, err)
}
```
## Call
@@ -151,12 +208,12 @@ Request: map[string]interface{}{
}
```
## Delete
## List
Delete a function by name
List all the deployed functions
[https://m3o.com/function/api#Delete](https://m3o.com/function/api#Delete)
[https://m3o.com/function/api#List](https://m3o.com/function/api#List)
```go
package example
@@ -168,40 +225,11 @@ import(
"go.m3o.com/function"
)
// Delete a function by name
func DeleteAfunction() {
// List all the deployed functions
func ListFunctions() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Delete(&function.DeleteRequest{
Name: "helloworld",
})
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: "helloworld",
rsp, err := functionService.List(&function.ListRequest{
})
fmt.Println(rsp, err)
@@ -235,31 +263,3 @@ func ReserveAfunction() {
}
```
## Proxy
Return the backend url for proxying
[https://m3o.com/function/api#Proxy](https://m3o.com/function/api#Proxy)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Return the backend url for proxying
func ProxyUrl() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Proxy(&function.ProxyRequest{
Id: "helloworld",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,35 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/geocoding/api]
Endpoints:
## Reverse
Reverse lookup an address from gps coordinates
[https://m3o.com/geocoding/api#Reverse](https://m3o.com/geocoding/api#Reverse)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/geocoding"
)
// Reverse lookup an address from gps coordinates
func ReverseGeocodeLocation() {
geocodingService := geocoding.NewGeocodingService(os.Getenv("M3O_API_TOKEN"))
rsp, err := geocodingService.Reverse(&geocoding.ReverseRequest{
Latitude: 51.5123064,
Longitude: -0.1216235,
})
fmt.Println(rsp, err)
}
```
## Lookup
Lookup returns a geocoded address including normalized address and gps coordinates. All fields are optional, provide more to get more accurate results
@@ -35,32 +64,3 @@ Postcode: "wc2b",
}
```
## Reverse
Reverse lookup an address from gps coordinates
[https://m3o.com/geocoding/api#Reverse](https://m3o.com/geocoding/api#Reverse)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/geocoding"
)
// Reverse lookup an address from gps coordinates
func ReverseGeocodeLocation() {
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

@@ -4,41 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/image/api](htt
Endpoints:
## Convert
Convert an image from one format (jpeg, png etc.) to an other either on the fly (from base64 to base64),
or by uploading the conversion result.
To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
with each parameter as a form field.
[https://m3o.com/image/api#Convert](https://m3o.com/image/api#Convert)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/image"
)
// Convert an image from one format (jpeg, png etc.) to an other either on the fly (from base64 to base64),
// or by uploading the conversion result.
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
// with each parameter as a form field.
func ConvertApngImageToAjpegTakenFromAurlAndSavedToAurlOnMicrosCdn() {
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
rsp, err := imageService.Convert(&image.ConvertRequest{
Name: "cat.jpeg",
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.
@@ -256,3 +221,38 @@ Width: 100,
}
```
## Convert
Convert an image from one format (jpeg, png etc.) to an other either on the fly (from base64 to base64),
or by uploading the conversion result.
To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
with each parameter as a form field.
[https://m3o.com/image/api#Convert](https://m3o.com/image/api#Convert)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/image"
)
// Convert an image from one format (jpeg, png etc.) to an other either on the fly (from base64 to base64),
// or by uploading the conversion result.
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
// with each parameter as a form field.
func ConvertApngImageToAjpegTakenFromAurlAndSavedToAurlOnMicrosCdn() {
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
rsp, err := imageService.Convert(&image.ConvertRequest{
Name: "cat.jpeg",
Url: "somewebsite.com/cat.png",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,42 +4,6 @@ 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
@@ -102,3 +66,39 @@ Type: "bike",
}
```
## 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

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

View File

@@ -4,6 +4,35 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/place/api](htt
Endpoints:
## Search
Search for places by text query
[https://m3o.com/place/api#Search](https://m3o.com/place/api#Search)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/place"
)
// Search for places by text query
func SearchForPlaces() {
placeService := place.NewPlaceService(os.Getenv("M3O_API_TOKEN"))
rsp, err := placeService.Search(&place.SearchRequest{
Location: "51.5074577,-0.1297515",
Query: "food",
})
fmt.Println(rsp, err)
}
```
## Nearby
Find places nearby using a location
@@ -34,32 +63,3 @@ Type: "store",
}
```
## Search
Search for places by text query
[https://m3o.com/place/api#Search](https://m3o.com/place/api#Search)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/place"
)
// Search for places by text query
func SearchForPlaces() {
placeService := place.NewPlaceService(os.Getenv("M3O_API_TOKEN"))
rsp, err := placeService.Search(&place.SearchRequest{
Location: "51.5074577,-0.1297515",
Query: "food",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/quran/api](htt
Endpoints:
## Chapters
List the Chapters (surahs) of the Quran
[https://m3o.com/quran/api#Chapters](https://m3o.com/quran/api#Chapters)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/quran"
)
// List the Chapters (surahs) of the Quran
func ListChapters() {
quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN"))
rsp, err := quranService.Chapters(&quran.ChaptersRequest{
Language: "en",
})
fmt.Println(rsp, err)
}
```
## Summary
Get a summary for a given chapter (surah)
@@ -120,3 +92,31 @@ func SearchTheQuran() {
}
```
## Chapters
List the Chapters (surahs) of the Quran
[https://m3o.com/quran/api#Chapters](https://m3o.com/quran/api#Chapters)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/quran"
)
// List the Chapters (surahs) of the Quran
func ListChapters() {
quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN"))
rsp, err := quranService.Chapters(&quran.ChaptersRequest{
Language: "en",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,41 +4,6 @@ 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
@@ -109,3 +74,38 @@ Origin: &routing.Point{
}
```
## 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

@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/rss/api](https
Endpoints:
## Remove
Remove an RSS feed by name
[https://m3o.com/rss/api#Remove](https://m3o.com/rss/api#Remove)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/rss"
)
// Remove an RSS feed by name
func RemoveAfeed() {
rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN"))
rsp, err := rssService.Remove(&rss.RemoveRequest{
Name: "bbc",
})
fmt.Println(rsp, err)
}
```
## Add
Add a new RSS feed with a name, url, and category
@@ -89,31 +117,3 @@ func ListRssFeeds() {
}
```
## Remove
Remove an RSS feed by name
[https://m3o.com/rss/api#Remove](https://m3o.com/rss/api#Remove)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/rss"
)
// Remove an RSS feed by name
func RemoveAfeed() {
rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN"))
rsp, err := rssService.Remove(&rss.RemoveRequest{
Name: "bbc",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/search/api](ht
Endpoints:
## DeleteIndex
Delete an index by name
[https://m3o.com/search/api#DeleteIndex](https://m3o.com/search/api#DeleteIndex)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/search"
)
// Delete an index by name
func DeleteAnIndex() {
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
rsp, err := searchService.DeleteIndex(&search.DeleteIndexRequest{
Index: "customers",
})
fmt.Println(rsp, err)
}
```
## Index
Index a document i.e. insert a document to search for.
@@ -212,3 +184,31 @@ func CreateAnIndex() {
}
```
## DeleteIndex
Delete an index by name
[https://m3o.com/search/api#DeleteIndex](https://m3o.com/search/api#DeleteIndex)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/search"
)
// Delete an index by name
func DeleteAnIndex() {
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
rsp, err := searchService.DeleteIndex(&search.DeleteIndexRequest{
Index: "customers",
})
fmt.Println(rsp, err)
}
```

View File

@@ -13,9 +13,9 @@ func main() {
rsp, err := searchService.Index(&search.IndexRequest{
Document: &search.Document{
Contents: map[string]interface{}{
"name": "John Doe",
"age": 37,
"starsign": "Leo",
"name": "John Doe",
},
Id: "1234",
},

View File

@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/space/api](htt
Endpoints:
## List
List the objects in space
[https://m3o.com/space/api#List](https://m3o.com/space/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/space"
)
// List the objects in space
func ListObjectsWithPrefix() {
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
rsp, err := spaceService.List(&space.ListRequest{
Prefix: "images/",
})
fmt.Println(rsp, err)
}
```
## Head
Retrieve meta information about an object
@@ -204,31 +232,3 @@ func DeleteAnObject() {
}
```
## List
List the objects in space
[https://m3o.com/space/api#List](https://m3o.com/space/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/space"
)
// List the objects in space
func ListObjectsWithPrefix() {
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
rsp, err := spaceService.List(&space.ListRequest{
Prefix: "images/",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,62 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/stock/api](htt
Endpoints:
## Price
Get the last price for a given stock ticker
[https://m3o.com/stock/api#Price](https://m3o.com/stock/api#Price)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/stock"
)
// Get the last price for a given stock ticker
func GetAstockPrice() {
stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN"))
rsp, err := stockService.Price(&stock.PriceRequest{
Symbol: "AAPL",
})
fmt.Println(rsp, err)
}
```
## Quote
Get the last quote for the stock
[https://m3o.com/stock/api#Quote](https://m3o.com/stock/api#Quote)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/stock"
)
// Get the last quote for the stock
func GetAstockQuote() {
stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN"))
rsp, err := stockService.Quote(&stock.QuoteRequest{
Symbol: "AAPL",
})
fmt.Println(rsp, err)
}
```
## History
Get the historic open-close for a given day
@@ -65,59 +121,3 @@ Stock: "AAPL",
}
```
## Price
Get the last price for a given stock ticker
[https://m3o.com/stock/api#Price](https://m3o.com/stock/api#Price)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/stock"
)
// Get the last price for a given stock ticker
func GetAstockPrice() {
stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN"))
rsp, err := stockService.Price(&stock.PriceRequest{
Symbol: "AAPL",
})
fmt.Println(rsp, err)
}
```
## Quote
Get the last quote for the stock
[https://m3o.com/stock/api#Quote](https://m3o.com/stock/api#Quote)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/stock"
)
// Get the last quote for the stock
func GetAstockQuote() {
stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN"))
rsp, err := stockService.Quote(&stock.QuoteRequest{
Symbol: "AAPL",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,61 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/stream/api](ht
Endpoints:
## ListMessages
List messages for a given channel
[https://m3o.com/stream/api#ListMessages](https://m3o.com/stream/api#ListMessages)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/stream"
)
// List messages for a given channel
func ListMessages() {
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
rsp, err := streamService.ListMessages(&stream.ListMessagesRequest{
Channel: "general",
})
fmt.Println(rsp, err)
}
```
## ListChannels
List all the active channels
[https://m3o.com/stream/api#ListChannels](https://m3o.com/stream/api#ListChannels)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/stream"
)
// List all the active channels
func ListChannels() {
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
rsp, err := streamService.ListChannels(&stream.ListChannelsRequest{
})
fmt.Println(rsp, err)
}
```
## CreateChannel
Create a channel with a given name and description. Channels are created automatically but
@@ -119,3 +64,58 @@ Text: "Hey checkout this tweet https://twitter.com/m3oservices/status/1455291054
}
```
## ListMessages
List messages for a given channel
[https://m3o.com/stream/api#ListMessages](https://m3o.com/stream/api#ListMessages)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/stream"
)
// List messages for a given channel
func ListMessages() {
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
rsp, err := streamService.ListMessages(&stream.ListMessagesRequest{
Channel: "general",
})
fmt.Println(rsp, err)
}
```
## ListChannels
List all the active channels
[https://m3o.com/stream/api#ListChannels](https://m3o.com/stream/api#ListChannels)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/stream"
)
// List all the active channels
func ListChannels() {
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
rsp, err := streamService.ListChannels(&stream.ListChannelsRequest{
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,37 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/sunnah/api](ht
Endpoints:
## Hadiths
Hadiths returns a list of hadiths and their corresponding text for a
given book within a collection.
[https://m3o.com/sunnah/api#Hadiths](https://m3o.com/sunnah/api#Hadiths)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/sunnah"
)
// Hadiths returns a list of hadiths and their corresponding text for a
// given book within a collection.
func ListTheHadithsInAbook() {
sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN"))
rsp, err := sunnahService.Hadiths(&sunnah.HadithsRequest{
Book: 1,
Collection: "bukhari",
})
fmt.Println(rsp, err)
}
```
## Collections
Get a list of available collections. A collection is
@@ -92,34 +123,3 @@ Collection: "bukhari",
}
```
## Hadiths
Hadiths returns a list of hadiths and their corresponding text for a
given book within a collection.
[https://m3o.com/sunnah/api#Hadiths](https://m3o.com/sunnah/api#Hadiths)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/sunnah"
)
// Hadiths returns a list of hadiths and their corresponding text for a
// given book within a collection.
func ListTheHadithsInAbook() {
sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN"))
rsp, err := sunnahService.Hadiths(&sunnah.HadithsRequest{
Book: 1,
Collection: "bukhari",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,33 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/time/api](http
Endpoints:
## Now
Get the current time
[https://m3o.com/time/api#Now](https://m3o.com/time/api#Now)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/time"
)
// Get the current time
func ReturnsCurrentTimeOptionallyWithLocation() {
timeService := time.NewTimeService(os.Getenv("M3O_API_TOKEN"))
rsp, err := timeService.Now(&time.NowRequest{
})
fmt.Println(rsp, err)
}
```
## Zone
Get the timezone info for a specific location
@@ -32,30 +59,3 @@ func GetTheTimezoneInfoForAspecificLocation() {
}
```
## Now
Get the current time
[https://m3o.com/time/api#Now](https://m3o.com/time/api#Now)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/time"
)
// Get the current time
func ReturnsCurrentTimeOptionallyWithLocation() {
timeService := time.NewTimeService(os.Getenv("M3O_API_TOKEN"))
rsp, err := timeService.Now(&time.NowRequest{
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/url/api](https
Endpoints:
## List
List all the shortened URLs
[https://m3o.com/url/api#List](https://m3o.com/url/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/url"
)
// List all the shortened URLs
func ListYourShortenedUrls() {
urlService := url.NewUrlService(os.Getenv("M3O_API_TOKEN"))
rsp, err := urlService.List(&url.ListRequest{
})
fmt.Println(rsp, err)
}
```
## Shorten
Shorten a long URL
@@ -85,3 +58,30 @@ func ResolveAshortUrlToAlongDestinationUrl() {
}
```
## List
List all the shortened URLs
[https://m3o.com/url/api#List](https://m3o.com/url/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/url"
)
// List all the shortened URLs
func ListYourShortenedUrls() {
urlService := url.NewUrlService(os.Getenv("M3O_API_TOKEN"))
rsp, err := urlService.List(&url.ListRequest{
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,68 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/user/api](http
Endpoints:
## ReadSession
Read a session by the session id. In the event it has expired or is not found and error is returned.
[https://m3o.com/user/api#ReadSession](https://m3o.com/user/api#ReadSession)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Read a session by the session id. In the event it has expired or is not found and error is returned.
func ReadAsessionByTheSessionId() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.ReadSession(&user.ReadSessionRequest{
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
})
fmt.Println(rsp, err)
}
```
## VerifyToken
Check whether the token attached to MagicLink is valid or not.
Ideally, you need to call this endpoint from your http request
handler that handles the endpoint which is specified in the
SendMagicLink request.
[https://m3o.com/user/api#VerifyToken](https://m3o.com/user/api#VerifyToken)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Check whether the token attached to MagicLink is valid or not.
// Ideally, you need to call this endpoint from your http request
// handler that handles the endpoint which is specified in the
// SendMagicLink request.
func VerifyAtoken() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.VerifyToken(&user.VerifyTokenRequest{
Token: "EdsUiidouJJJLldjlloofUiorkojflsWWdld",
})
fmt.Println(rsp, err)
}
```
## Read
Read an account by id, username or email. Only one need to be specified.
@@ -88,13 +150,13 @@ func ReadAccountByEmail() {
}
```
## Login
## SendPasswordResetEmail
Login using username or email. The response will return a new session for successful login,
401 in the case of login failure and 500 for any other error
Send an email with a verification code to reset password.
Call "ResetPassword" endpoint once user provides the code.
[https://m3o.com/user/api#Login](https://m3o.com/user/api#Login)
[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail)
```go
package example
@@ -106,120 +168,44 @@ import(
"go.m3o.com/user"
)
// Login using username or email. The response will return a new session for successful login,
// 401 in the case of login failure and 500 for any other error
func LogAuserIn() {
// Send an email with a verification code to reset password.
// Call "ResetPassword" endpoint once user provides the code.
func SendPasswordResetEmail() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.Login(&user.LoginRequest{
rsp, err := userService.SendPasswordResetEmail(&user.SendPasswordResetEmailRequest{
Email: "joe@example.com",
Password: "Password1",
})
fmt.Println(rsp, err)
}
```
## List
List all users. Returns a paged list of results
[https://m3o.com/user/api#List](https://m3o.com/user/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// List all users. Returns a paged list of results
func ListAllUsers() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.List(&user.ListRequest{
Limit: 100,
Offset: 0,
})
fmt.Println(rsp, err)
}
```
## Create
Create a new user account. The email address and username for the account must be unique.
[https://m3o.com/user/api#Create](https://m3o.com/user/api#Create)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Create a new user account. The email address and username for the account must be unique.
func CreateAnAccount() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.Create(&user.CreateRequest{
Email: "joe@example.com",
Id: "user-1",
Password: "Password1",
Username: "joe",
})
fmt.Println(rsp, err)
}
```
## SendVerificationEmail
Send a verification email to a user.
Email "from" will be 'noreply@email.m3ocontent.com'.
The verification link will be injected in the email
as a template variable, $micro_verification_link e.g
'Welcome to M3O! Use the link below to verify your email: $micro_verification_link'
The variable will be replaced with a url similar to:
'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url'
[https://m3o.com/user/api#SendVerificationEmail](https://m3o.com/user/api#SendVerificationEmail)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Send a verification email to a user.
// Email "from" will be 'noreply@email.m3ocontent.com'.
// The verification link will be injected in the email
// as a template variable, $micro_verification_link e.g
// 'Welcome to M3O! Use the link below to verify your email: $micro_verification_link'
// The variable will be replaced with a url similar to:
// 'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url'
func SendVerificationEmail() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.SendVerificationEmail(&user.SendVerificationEmailRequest{
Email: "joe@example.com",
FailureRedirectUrl: "https://m3o.com/verification-failed",
FromName: "Awesome Dot Com",
RedirectUrl: "https://m3o.com",
Subject: "Email verification",
Subject: "Password reset",
TextContent: `Hi there,
click here to reset your password: myapp.com/reset/code?=$code`,
Please verify your email by clicking this link: $micro_verification_link`,
})
fmt.Println(rsp, err)
}
```
## Logout
Logout a user account
[https://m3o.com/user/api#Logout](https://m3o.com/user/api#Logout)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Logout a user account
func LogAuserOut() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.Logout(&user.LogoutRequest{
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
})
fmt.Println(rsp, err)
@@ -292,13 +278,18 @@ UserId: "user-1",
}
```
## SendPasswordResetEmail
## SendVerificationEmail
Send an email with a verification code to reset password.
Call "ResetPassword" endpoint once user provides the code.
Send a verification email to a user.
Email "from" will be 'noreply@email.m3ocontent.com'.
The verification link will be injected in the email
as a template variable, $micro_verification_link e.g
'Welcome to M3O! Use the link below to verify your email: $micro_verification_link'
The variable will be replaced with a url similar to:
'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url'
[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail)
[https://m3o.com/user/api#SendVerificationEmail](https://m3o.com/user/api#SendVerificationEmail)
```go
package example
@@ -310,16 +301,52 @@ import(
"go.m3o.com/user"
)
// Send an email with a verification code to reset password.
// Call "ResetPassword" endpoint once user provides the code.
func SendPasswordResetEmail() {
// Send a verification email to a user.
// Email "from" will be 'noreply@email.m3ocontent.com'.
// The verification link will be injected in the email
// as a template variable, $micro_verification_link e.g
// 'Welcome to M3O! Use the link below to verify your email: $micro_verification_link'
// The variable will be replaced with a url similar to:
// 'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url'
func SendVerificationEmail() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.SendPasswordResetEmail(&user.SendPasswordResetEmailRequest{
rsp, err := userService.SendVerificationEmail(&user.SendVerificationEmailRequest{
Email: "joe@example.com",
FailureRedirectUrl: "https://m3o.com/verification-failed",
FromName: "Awesome Dot Com",
Subject: "Password reset",
RedirectUrl: "https://m3o.com",
Subject: "Email verification",
TextContent: `Hi there,
click here to reset your password: myapp.com/reset/code?=$code`,
Please verify your email by clicking this link: $micro_verification_link`,
})
fmt.Println(rsp, err)
}
```
## VerifyEmail
Verify the email address of an account from a token sent in an email to the user.
[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Verify the email address of an account from a token sent in an email to the user.
func VerifyEmail() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.VerifyEmail(&user.VerifyEmailRequest{
Token: "012345",
})
fmt.Println(rsp, err)
@@ -357,15 +384,12 @@ NewPassword: "NewPassword1",
}
```
## VerifyToken
## Delete
Check whether the token attached to MagicLink is valid or not.
Ideally, you need to call this endpoint from your http request
handler that handles the endpoint which is specified in the
SendMagicLink request.
Delete an account by id
[https://m3o.com/user/api#VerifyToken](https://m3o.com/user/api#VerifyToken)
[https://m3o.com/user/api#Delete](https://m3o.com/user/api#Delete)
```go
package example
@@ -377,14 +401,71 @@ import(
"go.m3o.com/user"
)
// Check whether the token attached to MagicLink is valid or not.
// Ideally, you need to call this endpoint from your http request
// handler that handles the endpoint which is specified in the
// SendMagicLink request.
func VerifyAtoken() {
// Delete an account by id
func DeleteUserAccount() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.VerifyToken(&user.VerifyTokenRequest{
Token: "EdsUiidouJJJLldjlloofUiorkojflsWWdld",
rsp, err := userService.Delete(&user.DeleteRequest{
Id: "8b98acbe-0b6a-4d66-a414-5ffbf666786f",
})
fmt.Println(rsp, err)
}
```
## List
List all users. Returns a paged list of results
[https://m3o.com/user/api#List](https://m3o.com/user/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// List all users. Returns a paged list of results
func ListAllUsers() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.List(&user.ListRequest{
Limit: 100,
Offset: 0,
})
fmt.Println(rsp, err)
}
```
## Create
Create a new user account. The email address and username for the account must be unique.
[https://m3o.com/user/api#Create](https://m3o.com/user/api#Create)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Create a new user account. The email address and username for the account must be unique.
func CreateAnAccount() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.Create(&user.CreateRequest{
Email: "joe@example.com",
Id: "user-1",
Password: "Password1",
Username: "joe",
})
fmt.Println(rsp, err)
@@ -421,12 +502,13 @@ Username: "joe",
}
```
## VerifyEmail
## Login
Verify the email address of an account from a token sent in an email to the user.
Login using username or email. The response will return a new session for successful login,
401 in the case of login failure and 500 for any other error
[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail)
[https://m3o.com/user/api#Login](https://m3o.com/user/api#Login)
```go
package example
@@ -438,95 +520,13 @@ import(
"go.m3o.com/user"
)
// Verify the email address of an account from a token sent in an email to the user.
func VerifyEmail() {
// Login using username or email. The response will return a new session for successful login,
// 401 in the case of login failure and 500 for any other error
func LogAuserIn() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.VerifyEmail(&user.VerifyEmailRequest{
Token: "012345",
})
fmt.Println(rsp, err)
}
```
## Delete
Delete an account by id
[https://m3o.com/user/api#Delete](https://m3o.com/user/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Delete an account by id
func DeleteUserAccount() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.Delete(&user.DeleteRequest{
Id: "8b98acbe-0b6a-4d66-a414-5ffbf666786f",
})
fmt.Println(rsp, err)
}
```
## Logout
Logout a user account
[https://m3o.com/user/api#Logout](https://m3o.com/user/api#Logout)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Logout a user account
func LogAuserOut() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.Logout(&user.LogoutRequest{
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
})
fmt.Println(rsp, err)
}
```
## ReadSession
Read a session by the session id. In the event it has expired or is not found and error is returned.
[https://m3o.com/user/api#ReadSession](https://m3o.com/user/api#ReadSession)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Read a session by the session id. In the event it has expired or is not found and error is returned.
func ReadAsessionByTheSessionId() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.ReadSession(&user.ReadSessionRequest{
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
rsp, err := userService.Login(&user.LoginRequest{
Email: "joe@example.com",
Password: "Password1",
})
fmt.Println(rsp, err)

View File

@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/youtube/api](h
Endpoints:
## Search
Search for videos on YouTube
[https://m3o.com/youtube/api#Search](https://m3o.com/youtube/api#Search)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/youtube"
)
// Search for videos on YouTube
func SearchForVideos() {
youtubeService := youtube.NewYoutubeService(os.Getenv("M3O_API_TOKEN"))
rsp, err := youtubeService.Search(&youtube.SearchRequest{
Query: "donuts",
})
fmt.Println(rsp, err)
}
```
## Embed
Embed a YouTube video
@@ -60,3 +32,31 @@ func EmbedAyoutubeVideo() {
}
```
## Search
Search for videos on YouTube
[https://m3o.com/youtube/api#Search](https://m3o.com/youtube/api#Search)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/youtube"
)
// Search for videos on YouTube
func SearchForVideos() {
youtubeService := youtube.NewYoutubeService(os.Getenv("M3O_API_TOKEN"))
rsp, err := youtubeService.Search(&youtube.SearchRequest{
Query: "donuts",
})
fmt.Println(rsp, err)
}
```

View File

@@ -44,6 +44,8 @@ type LookupResponse struct {
FuelType string `json:"fuel_type"`
// date of last v5 issue
LastV5Issued string `json:"last_v5_issued"`
// url of logo for the make
LogoUrl string `json:"logo_url"`
// make of vehicle
Make string `json:"make"`
// month of first registration