Commit from m3o/m3o action

This commit is contained in:
m3o-actions
2022-02-14 14:12:45 +00:00
parent 97accc758e
commit 56cdd3c583
24 changed files with 1115 additions and 1115 deletions

View File

@@ -4,6 +4,61 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/app/api](https
Endpoints: Endpoints:
## Reserve
Reserve apps beyond the free quota. Call Run after.
[https://m3o.com/app/api#Reserve](https://m3o.com/app/api#Reserve)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/app"
)
// Reserve apps beyond the free quota. Call Run after.
func ReserveAppName() {
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
rsp, err := appService.Reserve(&app.ReserveRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```
## List
List all the apps
[https://m3o.com/app/api#List](https://m3o.com/app/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/app"
)
// List all the apps
func ListTheApps() {
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
rsp, err := appService.List(&app.ListRequest{
})
fmt.Println(rsp, err)
}
```
## Run ## Run
Run an app from source Run an app from source
@@ -175,58 +230,3 @@ func DeleteAnApp() {
} }
``` ```
## Reserve
Reserve apps beyond the free quota. Call Run after.
[https://m3o.com/app/api#Reserve](https://m3o.com/app/api#Reserve)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/app"
)
// Reserve apps beyond the free quota. Call Run after.
func ReserveAppName() {
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
rsp, err := appService.Reserve(&app.ReserveRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```
## List
List all the apps
[https://m3o.com/app/api#List](https://m3o.com/app/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/app"
)
// List all the apps
func ListTheApps() {
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
rsp, err := appService.List(&app.ListRequest{
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,91 +4,6 @@ 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). 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)
}
```
## 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
Set an item in the cache. Overwrites any existing value already set. Set an item in the cache. Overwrites any existing value already set.
@@ -174,3 +89,88 @@ func DeleteAvalue() {
} }
``` ```
## 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)
}
```
## 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,62 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/contact/api](h
Endpoints: Endpoints:
## Read
[https://m3o.com/contact/api#Read](https://m3o.com/contact/api#Read)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/contact"
)
//
func GetAcontact() {
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
rsp, err := contactService.Read(&contact.ReadRequest{
Id: "42e48a3c-6221-11ec-96d2-acde48001122",
})
fmt.Println(rsp, err)
}
```
## Delete
[https://m3o.com/contact/api#Delete](https://m3o.com/contact/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/contact"
)
//
func DeleteAcontact() {
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
rsp, err := contactService.Delete(&contact.DeleteRequest{
Id: "42e48a3c-6221-11ec-96d2-acde48001122",
})
fmt.Println(rsp, err)
}
```
## List ## List
@@ -161,59 +217,3 @@ contact.Phone{
} }
``` ```
## Read
[https://m3o.com/contact/api#Read](https://m3o.com/contact/api#Read)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/contact"
)
//
func GetAcontact() {
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
rsp, err := contactService.Read(&contact.ReadRequest{
Id: "42e48a3c-6221-11ec-96d2-acde48001122",
})
fmt.Println(rsp, err)
}
```
## Delete
[https://m3o.com/contact/api#Delete](https://m3o.com/contact/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/contact"
)
//
func DeleteAcontact() {
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
rsp, err := contactService.Delete(&contact.DeleteRequest{
Id: "42e48a3c-6221-11ec-96d2-acde48001122",
})
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
@@ -116,3 +60,59 @@ func GetCryptocurrencyPrice() {
} }
``` ```
## 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

@@ -4,6 +4,129 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/db/api](https:
Endpoints: Endpoints:
## 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{}{
"isActive": true,
"id": "1",
"name": "Jane",
"age": 42,
},
Table: "example",
})
fmt.Println(rsp, err)
}
```
## Update
Update a record in the database. Include an "id" in the record to update.
[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Update a record in the database. Include an "id" in the record to update.
func UpdateArecord() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Update(&db.UpdateRequest{
Record: map[string]interface{}{
"id": "1",
"age": 43,
},
Table: "example",
})
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: "example",
})
fmt.Println(rsp, err)
}
```
## Read
Read data from a table. Lookup can be by ID or via querying any field in the record.
[https://m3o.com/db/api#Read](https://m3o.com/db/api#Read)
```go
package example
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 ReadRecords() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Read(&db.ReadRequest{
Query: "age == 43",
Table: "example",
})
fmt.Println(rsp, err)
}
```
## Delete ## Delete
Delete a record in the database by id. Delete a record in the database by id.
@@ -33,12 +156,12 @@ Table: "example",
} }
``` ```
## Truncate ## DropTable
Truncate the records in a table Drop a table in the DB
[https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate) [https://m3o.com/db/api#DropTable](https://m3o.com/db/api#DropTable)
```go ```go
package example package example
@@ -50,10 +173,10 @@ import(
"go.m3o.com/db" "go.m3o.com/db"
) )
// Truncate the records in a table // Drop a table in the DB
func TruncateTable() { func DropTable() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Truncate(&db.TruncateRequest{ rsp, err := dbService.DropTable(&db.DropTableRequest{
Table: "example", Table: "example",
}) })
@@ -114,129 +237,6 @@ func ListTables() {
}) })
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{}{
"id": "1",
"name": "Jane",
"age": 42,
"isActive": true,
},
Table: "example",
})
fmt.Println(rsp, err)
}
```
## Update
Update a record in the database. Include an "id" in the record to update.
[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Update a record in the database. Include an "id" in the record to update.
func UpdateArecord() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Update(&db.UpdateRequest{
Record: map[string]interface{}{
"id": "1",
"age": 43,
},
Table: "example",
})
fmt.Println(rsp, err)
}
```
## Read
Read data from a table. Lookup can be by ID or via querying any field in the record.
[https://m3o.com/db/api#Read](https://m3o.com/db/api#Read)
```go
package example
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 ReadRecords() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Read(&db.ReadRequest{
Query: "age == 43",
Table: "example",
})
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: "example",
})
fmt.Println(rsp, err)
} }
``` ```
## RenameTable ## RenameTable

View File

@@ -4,6 +4,33 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/evchargers/api
Endpoints: Endpoints:
## ReferenceData
Retrieve reference data as used by this API and in conjunction with the Search endpoint
[https://m3o.com/evchargers/api#ReferenceData](https://m3o.com/evchargers/api#ReferenceData)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/evchargers"
)
// Retrieve reference data as used by this API and in conjunction with the Search endpoint
func GetReferenceData() {
evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN"))
rsp, err := evchargersService.ReferenceData(&evchargers.ReferenceDataRequest{
})
fmt.Println(rsp, err)
}
```
## Search ## Search
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
@@ -98,30 +125,3 @@ Location: &evchargers.Coordinates{
} }
``` ```
## ReferenceData
Retrieve reference data as used by this API and in conjunction with the Search endpoint
[https://m3o.com/evchargers/api#ReferenceData](https://m3o.com/evchargers/api#ReferenceData)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/evchargers"
)
// Retrieve reference data as used by this API and in conjunction with the Search endpoint
func GetReferenceData() {
evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN"))
rsp, err := evchargersService.ReferenceData(&evchargers.ReferenceDataRequest{
})
fmt.Println(rsp, err)
}
```

View File

@@ -26,9 +26,9 @@ func PublishAnEvent() {
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

@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/forex/api](htt
Endpoints: Endpoints:
## History
Returns the data for the previous close
[https://m3o.com/forex/api#History](https://m3o.com/forex/api#History)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/forex"
)
// Returns the data for the previous close
func GetPreviousClose() {
forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN"))
rsp, err := forexService.History(&forex.HistoryRequest{
Symbol: "GBPUSD",
})
fmt.Println(rsp, err)
}
```
## Price ## Price
Get the latest price for a given forex ticker Get the latest price for a given forex ticker
@@ -88,3 +60,31 @@ func GetAfxQuote() {
} }
``` ```
## History
Returns the data for the previous close
[https://m3o.com/forex/api#History](https://m3o.com/forex/api#History)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/forex"
)
// Returns the data for the previous close
func GetPreviousClose() {
forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN"))
rsp, err := forexService.History(&forex.HistoryRequest{
Symbol: "GBPUSD",
})
fmt.Println(rsp, err)
}
```

View File

@@ -38,12 +38,12 @@ Subfolder: "examples/go-function",
} }
``` ```
## Delete ## Describe
Delete a function by name Get the info for a deployed function
[https://m3o.com/function/api#Delete](https://m3o.com/function/api#Delete) [https://m3o.com/function/api#Describe](https://m3o.com/function/api#Describe)
```go ```go
package example package example
@@ -55,42 +55,15 @@ import(
"go.m3o.com/function" "go.m3o.com/function"
) )
// Delete a function by name // Get the info for a deployed function
func DeleteAfunction() { func DescribeFunctionStatus() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Delete(&function.DeleteRequest{ rsp, err := functionService.Describe(&function.DescribeRequest{
Name: "helloworld", Name: "helloworld",
}) })
fmt.Println(rsp, err) 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)
} }
``` ```
## Reserve ## Reserve
@@ -119,6 +92,34 @@ func ReserveAfunction() {
}) })
fmt.Println(rsp, err) 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)
} }
``` ```
## Update ## Update
@@ -207,12 +208,12 @@ func ListFunctions() {
} }
``` ```
## Describe ## Delete
Get the info for a deployed function Delete a function by name
[https://m3o.com/function/api#Describe](https://m3o.com/function/api#Describe) [https://m3o.com/function/api#Delete](https://m3o.com/function/api#Delete)
```go ```go
package example package example
@@ -224,10 +225,10 @@ import(
"go.m3o.com/function" "go.m3o.com/function"
) )
// Get the info for a deployed function // Delete a function by name
func DescribeFunctionStatus() { func DeleteAfunction() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Describe(&function.DescribeRequest{ rsp, err := functionService.Delete(&function.DeleteRequest{
Name: "helloworld", Name: "helloworld",
}) })
@@ -235,12 +236,12 @@ func DescribeFunctionStatus() {
} }
``` ```
## Proxy ## Regions
Return the backend url for proxying Return a list of supported regions
[https://m3o.com/function/api#Proxy](https://m3o.com/function/api#Proxy) [https://m3o.com/function/api#Regions](https://m3o.com/function/api#Regions)
```go ```go
package example package example
@@ -252,12 +253,11 @@ import(
"go.m3o.com/function" "go.m3o.com/function"
) )
// Return the backend url for proxying // Return a list of supported regions
func ProxyUrl() { func ListRegions() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN")) functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Proxy(&function.ProxyRequest{ rsp, err := functionService.Regions(&function.RegionsRequest{
Id: "helloworld",
}) })
fmt.Println(rsp, err) 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: 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
Lookup returns a geocoded address including normalized address and gps coordinates. All fields are optional, provide more to get more accurate results 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,42 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/location/api](
Endpoints: 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
Read an entity by its ID 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

@@ -4,6 +4,39 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/mq/api](https:
Endpoints: Endpoints:
## Publish
Publish a message. Specify a topic to group messages for a specific topic.
[https://m3o.com/mq/api#Publish](https://m3o.com/mq/api#Publish)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/mq"
)
// Publish a message. Specify a topic to group messages for a specific topic.
func PublishAmessage() {
mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN"))
rsp, err := mqService.Publish(&mq.PublishRequest{
Message: map[string]interface{}{
"id": "1",
"type": "signup",
"user": "john",
},
Topic: "events",
})
fmt.Println(rsp, err)
}
```
## Subscribe ## Subscribe
Subscribe to messages for a given topic. Subscribe to messages for a given topic.
@@ -45,36 +78,3 @@ func SubscribeToAtopic() {
} }
} }
``` ```
## Publish
Publish a message. Specify a topic to group messages for a specific topic.
[https://m3o.com/mq/api#Publish](https://m3o.com/mq/api#Publish)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/mq"
)
// Publish a message. Specify a topic to group messages for a specific topic.
func PublishAmessage() {
mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN"))
rsp, err := mqService.Publish(&mq.PublishRequest{
Message: map[string]interface{}{
"type": "signup",
"user": "john",
"id": "1",
},
Topic: "events",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/nft/api](https
Endpoints: Endpoints:
## Assets
Return a list of assets
[https://m3o.com/nft/api#Assets](https://m3o.com/nft/api#Assets)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/nft"
)
// Return a list of assets
func GetAlistOfAssets() {
nftService := nft.NewNftService(os.Getenv("M3O_API_TOKEN"))
rsp, err := nftService.Assets(&nft.AssetsRequest{
Limit: 1,
})
fmt.Println(rsp, err)
}
```
## Create ## Create
Create your own NFT (coming soon) Create your own NFT (coming soon)
@@ -61,31 +89,3 @@ func ListCollections() {
} }
``` ```
## Assets
Return a list of assets
[https://m3o.com/nft/api#Assets](https://m3o.com/nft/api#Assets)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/nft"
)
// Return a list of assets
func GetAlistOfAssets() {
nftService := nft.NewNftService(os.Getenv("M3O_API_TOKEN"))
rsp, err := nftService.Assets(&nft.AssetsRequest{
Limit: 1,
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,47 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/notes/api](htt
Endpoints: Endpoints:
## Events
Subscribe to notes events
[https://m3o.com/notes/api#Events](https://m3o.com/notes/api#Events)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/notes"
)
// Subscribe to notes events
func SubscribeToEvents() {
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
stream, err := notesService.Events(&notes.EventsRequest{
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
})
if err != nil {
fmt.Println(err)
return
}
for {
rsp, err := stream.Recv()
if err != nil {
fmt.Println(err)
return
}
fmt.Println(rsp)
}
}
```
## Create ## Create
Create a new note Create a new note
@@ -189,3 +148,44 @@ func DeleteAnote() {
} }
``` ```
## Events
Subscribe to notes events
[https://m3o.com/notes/api#Events](https://m3o.com/notes/api#Events)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/notes"
)
// Subscribe to notes events
func SubscribeToEvents() {
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
stream, err := notesService.Events(&notes.EventsRequest{
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
})
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/quran/api](htt
Endpoints: Endpoints:
## Search
Search the Quran for any form of query or questions
[https://m3o.com/quran/api#Search](https://m3o.com/quran/api#Search)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/quran"
)
// Search the Quran for any form of query or questions
func SearchTheQuran() {
quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN"))
rsp, err := quranService.Search(&quran.SearchRequest{
Query: "messenger",
})
fmt.Println(rsp, err)
}
```
## Chapters ## Chapters
List the Chapters (surahs) of the Quran List the Chapters (surahs) of the Quran
@@ -92,31 +120,3 @@ func GetVersesOfAchapter() {
} }
``` ```
## Search
Search the Quran for any form of query or questions
[https://m3o.com/quran/api#Search](https://m3o.com/quran/api#Search)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/quran"
)
// Search the Quran for any form of query or questions
func SearchTheQuran() {
quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN"))
rsp, err := quranService.Search(&quran.SearchRequest{
Query: "messenger",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,61 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/rss/api](https
Endpoints: Endpoints:
## List
List the saved RSS fields
[https://m3o.com/rss/api#List](https://m3o.com/rss/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/rss"
)
// List the saved RSS fields
func ListRssFeeds() {
rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN"))
rsp, err := rssService.List(&rss.ListRequest{
})
fmt.Println(rsp, err)
}
```
## 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
Add a new RSS feed with a name, url, and category Add a new RSS feed with a name, url, and category
@@ -117,3 +62,58 @@ func ReadAfeed() {
} }
``` ```
## List
List the saved RSS fields
[https://m3o.com/rss/api#List](https://m3o.com/rss/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/rss"
)
// List the saved RSS fields
func ListRssFeeds() {
rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN"))
rsp, err := rssService.List(&rss.ListRequest{
})
fmt.Println(rsp, err)
}
```
## 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,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/search/api](ht
Endpoints: 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
Index a document i.e. insert a document to search for. Index a document i.e. insert a document to search for.
@@ -184,31 +212,3 @@ 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{ rsp, err := searchService.Index(&search.IndexRequest{
Document: &search.Document{ Document: &search.Document{
Contents: map[string]interface{}{ Contents: map[string]interface{}{
"starsign": "Leo",
"name": "John Doe", "name": "John Doe",
"age": 37, "age": 37,
"starsign": "Leo",
}, },
Id: "1234", Id: "1234",
}, },

View File

@@ -4,62 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/stock/api](htt
Endpoints: 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 ## History
Get the historic open-close for a given day Get the historic open-close for a given day
@@ -121,3 +65,59 @@ 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,6 +4,35 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/sunnah/api](ht
Endpoints: Endpoints:
## Collections
Get a list of available collections. A collection is
a compilation of hadiths collected and written by an author.
[https://m3o.com/sunnah/api#Collections](https://m3o.com/sunnah/api#Collections)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/sunnah"
)
// Get a list of available collections. A collection is
// a compilation of hadiths collected and written by an author.
func ListAvailableCollections() {
sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN"))
rsp, err := sunnahService.Collections(&sunnah.CollectionsRequest{
})
fmt.Println(rsp, err)
}
```
## Books ## Books
Get a list of books from within a collection. A book can contain many chapters Get a list of books from within a collection. A book can contain many chapters
@@ -94,32 +123,3 @@ Collection: "bukhari",
} }
``` ```
## Collections
Get a list of available collections. A collection is
a compilation of hadiths collected and written by an author.
[https://m3o.com/sunnah/api#Collections](https://m3o.com/sunnah/api#Collections)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/sunnah"
)
// Get a list of available collections. A collection is
// a compilation of hadiths collected and written by an author.
func ListAvailableCollections() {
sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN"))
rsp, err := sunnahService.Collections(&sunnah.CollectionsRequest{
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,35 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/twitter/api](h
Endpoints: Endpoints:
## Timeline
Get the timeline for a given user
[https://m3o.com/twitter/api#Timeline](https://m3o.com/twitter/api#Timeline)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/twitter"
)
// Get the timeline for a given user
func GetAtwitterTimeline() {
twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN"))
rsp, err := twitterService.Timeline(&twitter.TimelineRequest{
Limit: 1,
Username: "m3oservices",
})
fmt.Println(rsp, err)
}
```
## Search ## Search
Search for tweets with a simple query Search for tweets with a simple query
@@ -116,3 +87,32 @@ func GetAusersTwitterProfile() {
} }
``` ```
## Timeline
Get the timeline for a given user
[https://m3o.com/twitter/api#Timeline](https://m3o.com/twitter/api#Timeline)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/twitter"
)
// Get the timeline for a given user
func GetAtwitterTimeline() {
twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN"))
rsp, err := twitterService.Timeline(&twitter.TimelineRequest{
Limit: 1,
Username: "m3oservices",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,33 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/url/api](https
Endpoints: 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
Shorten a long URL Shorten a long URL
@@ -58,30 +85,3 @@ 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,116 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/user/api](http
Endpoints: Endpoints:
## 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)
}
```
## 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)
}
```
## 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",
TextContent: `Hi there,
Please verify your email by clicking this link: $micro_verification_link`,
})
fmt.Println(rsp, err)
}
```
## UpdatePassword ## UpdatePassword
Update the account password Update the account password
@@ -174,34 +64,6 @@ NewPassword: "NewPassword1",
}) })
fmt.Println(rsp, err) 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 ## ReadSession
@@ -230,41 +92,6 @@ func ReadAsessionByTheSessionId() {
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
}
```
## SendMagicLink
Login using email only - Passwordless
[https://m3o.com/user/api#SendMagicLink](https://m3o.com/user/api#SendMagicLink)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Login using email only - Passwordless
func SendAmagicLink() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.SendMagicLink(&user.SendMagicLinkRequest{
Address: "www.example.com",
Email: "joe@example.com",
Endpoint: "verifytoken",
FromName: "Awesome Dot Com",
Subject: "MagicLink to access your account",
TextContent: `Hi there,
Click here to access your account $micro_verification_link`,
})
fmt.Println(rsp, err)
} }
``` ```
## Create ## Create
@@ -296,6 +123,40 @@ Username: "joe",
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
}
```
## SendPasswordResetEmail
Send an email with a verification code to reset password.
Call "ResetPassword" endpoint once user provides the code.
[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// 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.SendPasswordResetEmail(&user.SendPasswordResetEmailRequest{
Email: "joe@example.com",
FromName: "Awesome Dot Com",
Subject: "Password reset",
TextContent: `Hi there,
click here to reset your password: myapp.com/reset/code?=$code`,
})
fmt.Println(rsp, err)
} }
``` ```
## Read ## Read
@@ -382,13 +243,18 @@ func ReadAccountByEmail() {
} }
``` ```
## SendPasswordResetEmail ## SendVerificationEmail
Send an email with a verification code to reset password. Send a verification email to a user.
Call "ResetPassword" endpoint once user provides the code. 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 ```go
package example package example
@@ -400,16 +266,24 @@ import(
"go.m3o.com/user" "go.m3o.com/user"
) )
// Send an email with a verification code to reset password. // Send a verification email to a user.
// Call "ResetPassword" endpoint once user provides the code. // Email "from" will be 'noreply@email.m3ocontent.com'.
func SendPasswordResetEmail() { // 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")) userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.SendPasswordResetEmail(&user.SendPasswordResetEmailRequest{ rsp, err := userService.SendVerificationEmail(&user.SendVerificationEmailRequest{
Email: "joe@example.com", Email: "joe@example.com",
FailureRedirectUrl: "https://m3o.com/verification-failed",
FromName: "Awesome Dot Com", FromName: "Awesome Dot Com",
Subject: "Password reset", RedirectUrl: "https://m3o.com",
Subject: "Email verification",
TextContent: `Hi there, 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) fmt.Println(rsp, err)
@@ -473,6 +347,41 @@ Password: "Password1",
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
}
```
## SendMagicLink
Login using email only - Passwordless
[https://m3o.com/user/api#SendMagicLink](https://m3o.com/user/api#SendMagicLink)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Login using email only - Passwordless
func SendAmagicLink() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.SendMagicLink(&user.SendMagicLinkRequest{
Address: "www.example.com",
Email: "joe@example.com",
Endpoint: "verifytoken",
FromName: "Awesome Dot Com",
Subject: "MagicLink to access your account",
TextContent: `Hi there,
Click here to access your account $micro_verification_link`,
})
fmt.Println(rsp, err)
} }
``` ```
## Update ## Update
@@ -532,3 +441,94 @@ func DeleteUserAccount() {
} }
``` ```
## 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)
}
```
## 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)
}
```
## 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)
}
```

View File

@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/weather/api](h
Endpoints: Endpoints:
## Now
Get the current weather report for a location by postcode, city, zip code, ip address
[https://m3o.com/weather/api#Now](https://m3o.com/weather/api#Now)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/weather"
)
// Get the current weather report for a location by postcode, city, zip code, ip address
func GetCurrentWeather() {
weatherService := weather.NewWeatherService(os.Getenv("M3O_API_TOKEN"))
rsp, err := weatherService.Now(&weather.NowRequest{
Location: "london",
})
fmt.Println(rsp, err)
}
```
## Forecast ## Forecast
Get the weather forecast for the next 1-10 days Get the weather forecast for the next 1-10 days
@@ -33,31 +61,3 @@ Location: "London",
} }
``` ```
## Now
Get the current weather report for a location by postcode, city, zip code, ip address
[https://m3o.com/weather/api#Now](https://m3o.com/weather/api#Now)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/weather"
)
// Get the current weather report for a location by postcode, city, zip code, ip address
func GetCurrentWeather() {
weatherService := weather.NewWeatherService(os.Getenv("M3O_API_TOKEN"))
rsp, err := weatherService.Now(&weather.NowRequest{
Location: "london",
})
fmt.Println(rsp, err)
}
```