mirror of
https://github.com/kevin-DL/m3o-go.git
synced 2026-01-11 18:44:26 +00:00
Commit from m3o/m3o action
This commit is contained in:
@@ -4,96 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Db/api](https:
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## RenameTable
|
|
||||||
|
|
||||||
Rename a table
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/db/api#RenameTable](https://m3o.com/db/api#RenameTable)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/db"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Rename a table
|
|
||||||
func RenameTable() {
|
|
||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := dbService.RenameTable(&db.RenameTableRequest{
|
|
||||||
From: "examples2",
|
|
||||||
To: "examples3",
|
|
||||||
|
|
||||||
})
|
|
||||||
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{}{
|
|
||||||
"age": 43,
|
|
||||||
"id": "1",
|
|
||||||
},
|
|
||||||
Table: "example",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Delete
|
|
||||||
|
|
||||||
Delete a record in the database by id.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/db"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Delete a record in the database by id.
|
|
||||||
func DeleteArecord() {
|
|
||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := dbService.Delete(&db.DeleteRequest{
|
|
||||||
Id: "1",
|
|
||||||
Table: "example",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Truncate
|
## Truncate
|
||||||
|
|
||||||
Truncate the records in a table
|
Truncate the records in a table
|
||||||
@@ -150,12 +60,12 @@ func CountEntriesInAtable() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## ListTables
|
## RenameTable
|
||||||
|
|
||||||
List tables in the DB
|
Rename a table
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/db/api#ListTables](https://m3o.com/db/api#ListTables)
|
[https://m3o.com/db/api#RenameTable](https://m3o.com/db/api#RenameTable)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package example
|
package example
|
||||||
@@ -167,11 +77,13 @@ import(
|
|||||||
"go.m3o.com/db"
|
"go.m3o.com/db"
|
||||||
)
|
)
|
||||||
|
|
||||||
// List tables in the DB
|
// Rename a table
|
||||||
func ListTables() {
|
func RenameTable() {
|
||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := dbService.ListTables(&db.ListTablesRequest{
|
rsp, err := dbService.RenameTable(&db.RenameTableRequest{
|
||||||
|
From: "examples2",
|
||||||
|
To: "examples3",
|
||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
@@ -199,10 +111,42 @@ func CreateArecord() {
|
|||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := dbService.Create(&db.CreateRequest{
|
rsp, err := dbService.Create(&db.CreateRequest{
|
||||||
Record: map[string]interface{}{
|
Record: map[string]interface{}{
|
||||||
|
"isActive": true,
|
||||||
"id": "1",
|
"id": "1",
|
||||||
"name": "Jane",
|
"name": "Jane",
|
||||||
"age": 42,
|
"age": 42,
|
||||||
"isActive": true,
|
},
|
||||||
|
Table: "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",
|
Table: "example",
|
||||||
|
|
||||||
@@ -238,6 +182,35 @@ Table: "example",
|
|||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Delete
|
||||||
|
|
||||||
|
Delete a record in the database by id.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/db"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Delete a record in the database by id.
|
||||||
|
func DeleteArecord() {
|
||||||
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := dbService.Delete(&db.DeleteRequest{
|
||||||
|
Id: "1",
|
||||||
|
Table: "example",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## DropTable
|
## DropTable
|
||||||
@@ -268,3 +241,30 @@ func DropTable() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## ListTables
|
||||||
|
|
||||||
|
List tables in the DB
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/db/api#ListTables](https://m3o.com/db/api#ListTables)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/db"
|
||||||
|
)
|
||||||
|
|
||||||
|
// List tables in the DB
|
||||||
|
func ListTables() {
|
||||||
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := dbService.ListTables(&db.ListTablesRequest{
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ func main() {
|
|||||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := dbService.Create(&db.CreateRequest{
|
rsp, err := dbService.Create(&db.CreateRequest{
|
||||||
Record: map[string]interface{}{
|
Record: map[string]interface{}{
|
||||||
"name": "Jane",
|
|
||||||
"age": 42,
|
|
||||||
"isActive": true,
|
"isActive": true,
|
||||||
"id": "1",
|
"id": "1",
|
||||||
|
"name": "Jane",
|
||||||
|
"age": 42,
|
||||||
},
|
},
|
||||||
Table: "example",
|
Table: "example",
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Emoji/api](htt
|
|||||||
|
|
||||||
Endpoints:
|
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
|
## Flag
|
||||||
|
|
||||||
Get the flag for a country. Requires country code e.g GB for great britain
|
Get the flag for a country. Requires country code e.g GB for great britain
|
||||||
@@ -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)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/File/api](http
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## List
|
|
||||||
|
|
||||||
List files by their project and optionally a path.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/file/api#List](https://m3o.com/file/api#List)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/file"
|
|
||||||
)
|
|
||||||
|
|
||||||
// List files by their project and optionally a path.
|
|
||||||
func ListFiles() {
|
|
||||||
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := fileService.List(&file.ListRequest{
|
|
||||||
Project: "examples",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Delete
|
## Delete
|
||||||
|
|
||||||
Delete a file by project name/path
|
Delete a file by project name/path
|
||||||
@@ -122,3 +94,31 @@ func SaveFile() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## List
|
||||||
|
|
||||||
|
List files by their project and optionally a path.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/file/api#List](https://m3o.com/file/api#List)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/file"
|
||||||
|
)
|
||||||
|
|
||||||
|
// List files by their project and optionally a path.
|
||||||
|
func ListFiles() {
|
||||||
|
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := fileService.List(&file.ListRequest{
|
||||||
|
Project: "examples",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -4,6 +4,33 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Function/api](
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## 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)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## Delete
|
## Delete
|
||||||
|
|
||||||
Delete a function by name
|
Delete a function by name
|
||||||
@@ -121,30 +148,3 @@ Request: map[string]interface{}{
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## 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)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -67,9 +67,9 @@ func PublishAmessage() {
|
|||||||
mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN"))
|
mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := mqService.Publish(&mq.PublishRequest{
|
rsp, err := mqService.Publish(&mq.PublishRequest{
|
||||||
Message: map[string]interface{}{
|
Message: map[string]interface{}{
|
||||||
"id": "1",
|
|
||||||
"type": "signup",
|
"type": "signup",
|
||||||
"user": "john",
|
"user": "john",
|
||||||
|
"id": "1",
|
||||||
},
|
},
|
||||||
Topic: "events",
|
Topic: "events",
|
||||||
|
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ func main() {
|
|||||||
mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN"))
|
mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := mqService.Publish(&mq.PublishRequest{
|
rsp, err := mqService.Publish(&mq.PublishRequest{
|
||||||
Message: map[string]interface{}{
|
Message: map[string]interface{}{
|
||||||
|
"id": "1",
|
||||||
"type": "signup",
|
"type": "signup",
|
||||||
"user": "john",
|
"user": "john",
|
||||||
"id": "1",
|
|
||||||
},
|
},
|
||||||
Topic: "events",
|
Topic: "events",
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -4,34 +4,6 @@ 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)
|
||||||
@@ -89,3 +61,31 @@ 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)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -4,90 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Notes/api](htt
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## Create
|
|
||||||
|
|
||||||
Create a new note
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/notes/api#Create](https://m3o.com/notes/api#Create)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/notes"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Create a new note
|
|
||||||
func CreateAnote() {
|
|
||||||
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := notesService.Create(¬es.CreateRequest{
|
|
||||||
Text: "This is my note",
|
|
||||||
Title: "New Note",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Read
|
|
||||||
|
|
||||||
Read a note
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/notes/api#Read](https://m3o.com/notes/api#Read)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/notes"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Read a note
|
|
||||||
func ReadAnote() {
|
|
||||||
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := notesService.Read(¬es.ReadRequest{
|
|
||||||
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## List
|
|
||||||
|
|
||||||
List all the notes
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/notes/api#List](https://m3o.com/notes/api#List)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/notes"
|
|
||||||
)
|
|
||||||
|
|
||||||
// List all the notes
|
|
||||||
func ListAllNotes() {
|
|
||||||
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := notesService.List(¬es.ListRequest{
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Update
|
## Update
|
||||||
|
|
||||||
Update a note
|
Update a note
|
||||||
@@ -189,3 +105,87 @@ func SubscribeToEvents() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
## Create
|
||||||
|
|
||||||
|
Create a new note
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/notes/api#Create](https://m3o.com/notes/api#Create)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/notes"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Create a new note
|
||||||
|
func CreateAnote() {
|
||||||
|
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := notesService.Create(¬es.CreateRequest{
|
||||||
|
Text: "This is my note",
|
||||||
|
Title: "New Note",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Read
|
||||||
|
|
||||||
|
Read a note
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/notes/api#Read](https://m3o.com/notes/api#Read)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/notes"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Read a note
|
||||||
|
func ReadAnote() {
|
||||||
|
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := notesService.Read(¬es.ReadRequest{
|
||||||
|
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## List
|
||||||
|
|
||||||
|
List all the notes
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/notes/api#List](https://m3o.com/notes/api#List)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/notes"
|
||||||
|
)
|
||||||
|
|
||||||
|
// List all the notes
|
||||||
|
func ListAllNotes() {
|
||||||
|
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := notesService.List(¬es.ListRequest{
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -4,6 +4,36 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Rss/api](https
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## Add
|
||||||
|
|
||||||
|
Add a new RSS feed with a name, url, and category
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/rss/api#Add](https://m3o.com/rss/api#Add)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/rss"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add a new RSS feed with a name, url, and category
|
||||||
|
func AddAnewFeed() {
|
||||||
|
rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := rssService.Add(&rss.AddRequest{
|
||||||
|
Category: "news",
|
||||||
|
Name: "bbc",
|
||||||
|
Url: "http://feeds.bbci.co.uk/news/rss.xml",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## Feed
|
## Feed
|
||||||
|
|
||||||
Get an RSS feed by name. If no name is given, all feeds are returned. Default limit is 25 entries.
|
Get an RSS feed by name. If no name is given, all feeds are returned. Default limit is 25 entries.
|
||||||
@@ -87,33 +117,3 @@ func RemoveAfeed() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Add
|
|
||||||
|
|
||||||
Add a new RSS feed with a name, url, and category
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/rss/api#Add](https://m3o.com/rss/api#Add)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/rss"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Add a new RSS feed with a name, url, and category
|
|
||||||
func AddAnewFeed() {
|
|
||||||
rssService := rss.NewRssService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := rssService.Add(&rss.AddRequest{
|
|
||||||
Category: "news",
|
|
||||||
Name: "bbc",
|
|
||||||
Url: "http://feeds.bbci.co.uk/news/rss.xml",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Space/api](htt
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
|
## Download
|
||||||
|
|
||||||
|
Download an object via a presigned url
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/space/api#Download](https://m3o.com/space/api#Download)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/space"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Download an object via a presigned url
|
||||||
|
func DownloadAnObject() {
|
||||||
|
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := spaceService.Download(&space.DownloadRequest{
|
||||||
|
Name: "images/file.jpg",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
## Create
|
## Create
|
||||||
|
|
||||||
Create an object. Returns error if object with this name already exists. If you want to update an existing object use the `Update` endpoint
|
Create an object. Returns error if object with this name already exists. If you want to update an existing object use the `Update` endpoint
|
||||||
@@ -158,7 +186,7 @@ func HeadAnObject() {
|
|||||||
```
|
```
|
||||||
## Read
|
## Read
|
||||||
|
|
||||||
Read an object in space. Use for private objects.
|
Read an object in space
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/space/api#Read](https://m3o.com/space/api#Read)
|
[https://m3o.com/space/api#Read](https://m3o.com/space/api#Read)
|
||||||
@@ -173,7 +201,7 @@ import(
|
|||||||
"go.m3o.com/space"
|
"go.m3o.com/space"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Read an object in space. Use for private objects.
|
// Read an object in space
|
||||||
func ReadAnObject() {
|
func ReadAnObject() {
|
||||||
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := spaceService.Read(&space.ReadRequest{
|
rsp, err := spaceService.Read(&space.ReadRequest{
|
||||||
|
|||||||
17
examples/space/download/downloadAnObject/main.go
Executable file
17
examples/space/download/downloadAnObject/main.go
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/space"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Download an object via a presigned url
|
||||||
|
func main() {
|
||||||
|
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := spaceService.Download(&space.DownloadRequest{
|
||||||
|
Name: "images/file.jpg",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
}
|
||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"go.m3o.com/space"
|
"go.m3o.com/space"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Read an object in space. Use for private objects.
|
// Read an object in space
|
||||||
func main() {
|
func main() {
|
||||||
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := spaceService.Read(&space.ReadRequest{
|
rsp, err := spaceService.Read(&space.ReadRequest{
|
||||||
|
|||||||
@@ -4,6 +4,62 @@ 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
|
||||||
@@ -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)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -4,65 +4,6 @@ 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
|
|
||||||
|
|
||||||
Get a list of books from within a collection. A book can contain many chapters
|
|
||||||
each with its own hadiths.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/sunnah/api#Books](https://m3o.com/sunnah/api#Books)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/sunnah"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Get a list of books from within a collection. A book can contain many chapters
|
|
||||||
// each with its own hadiths.
|
|
||||||
func GetTheBooksWithinAcollection() {
|
|
||||||
sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := sunnahService.Books(&sunnah.BooksRequest{
|
|
||||||
Collection: "bukhari",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Chapters
|
## Chapters
|
||||||
|
|
||||||
Get all the chapters of a given book within a collection.
|
Get all the chapters of a given book within a collection.
|
||||||
@@ -123,3 +64,62 @@ 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)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Books
|
||||||
|
|
||||||
|
Get a list of books from within a collection. A book can contain many chapters
|
||||||
|
each with its own hadiths.
|
||||||
|
|
||||||
|
|
||||||
|
[https://m3o.com/sunnah/api#Books](https://m3o.com/sunnah/api#Books)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.m3o.com/sunnah"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get a list of books from within a collection. A book can contain many chapters
|
||||||
|
// each with its own hadiths.
|
||||||
|
func GetTheBooksWithinAcollection() {
|
||||||
|
sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := sunnahService.Books(&sunnah.BooksRequest{
|
||||||
|
Collection: "bukhari",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/User/api](http
|
|||||||
|
|
||||||
Endpoints:
|
Endpoints:
|
||||||
|
|
||||||
## ReadSession
|
## Create
|
||||||
|
|
||||||
Read a session by the session id. In the event it has expired or is not found and error is returned.
|
Create a new user account. The email address and username for the account must be unique.
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/user/api#ReadSession](https://m3o.com/user/api#ReadSession)
|
[https://m3o.com/user/api#Create](https://m3o.com/user/api#Create)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package example
|
package example
|
||||||
@@ -21,40 +21,14 @@ import(
|
|||||||
"go.m3o.com/user"
|
"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.
|
// Create a new user account. The email address and username for the account must be unique.
|
||||||
func ReadAsessionByTheSessionId() {
|
func CreateAnAccount() {
|
||||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := userService.ReadSession(&user.ReadSessionRequest{
|
rsp, err := userService.Create(&user.CreateRequest{
|
||||||
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
|
Email: "joe@example.com",
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Update
|
|
||||||
|
|
||||||
Update the account username or email
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/user/api#Update](https://m3o.com/user/api#Update)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.m3o.com/user"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Update the account username or email
|
|
||||||
func UpdateAnAccount() {
|
|
||||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := userService.Update(&user.UpdateRequest{
|
|
||||||
Email: "joe+2@example.com",
|
|
||||||
Id: "user-1",
|
Id: "user-1",
|
||||||
|
Password: "Password1",
|
||||||
|
Username: "joe",
|
||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
@@ -145,13 +119,12 @@ func ReadAccountByEmail() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## SendPasswordResetEmail
|
## VerifyEmail
|
||||||
|
|
||||||
Send an email with a verification code to reset password.
|
Verify the email address of an account from a token sent in an email to the user.
|
||||||
Call "ResetPassword" endpoint once user provides the code.
|
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail)
|
[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package example
|
package example
|
||||||
@@ -163,28 +136,24 @@ import(
|
|||||||
"go.m3o.com/user"
|
"go.m3o.com/user"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Send an email with a verification code to reset password.
|
// Verify the email address of an account from a token sent in an email to the user.
|
||||||
// Call "ResetPassword" endpoint once user provides the code.
|
func VerifyEmail() {
|
||||||
func SendPasswordResetEmail() {
|
|
||||||
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.VerifyEmail(&user.VerifyEmailRequest{
|
||||||
Email: "joe@example.com",
|
Email: "joe@example.com",
|
||||||
FromName: "Awesome Dot Com",
|
Token: "012345",
|
||||||
Subject: "Password reset",
|
|
||||||
TextContent: `Hi there,
|
|
||||||
click here to reset your password: myapp.com/reset/code?=$code`,
|
|
||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## ResetPassword
|
## Delete
|
||||||
|
|
||||||
Reset password with the code sent by the "SendPasswordResetEmail" endoint.
|
Delete an account by id
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/user/api#ResetPassword](https://m3o.com/user/api#ResetPassword)
|
[https://m3o.com/user/api#Delete](https://m3o.com/user/api#Delete)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package example
|
package example
|
||||||
@@ -196,14 +165,39 @@ import(
|
|||||||
"go.m3o.com/user"
|
"go.m3o.com/user"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Reset password with the code sent by the "SendPasswordResetEmail" endoint.
|
// Delete an account by id
|
||||||
func ResetPassword() {
|
func DeleteUserAccount() {
|
||||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := userService.ResetPassword(&user.ResetPasswordRequest{
|
rsp, err := userService.Delete(&user.DeleteRequest{
|
||||||
Code: "012345",
|
Id: "8b98acbe-0b6a-4d66-a414-5ffbf666786f",
|
||||||
ConfirmPassword: "NewPassword1",
|
|
||||||
Email: "joe@example.com",
|
})
|
||||||
NewPassword: "NewPassword1",
|
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",
|
||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
@@ -236,37 +230,6 @@ func LogAuserOut() {
|
|||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Login
|
|
||||||
|
|
||||||
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#Login](https://m3o.com/user/api#Login)
|
|
||||||
|
|
||||||
```go
|
|
||||||
package example
|
|
||||||
|
|
||||||
import(
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"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() {
|
|
||||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
|
||||||
rsp, err := userService.Login(&user.LoginRequest{
|
|
||||||
Email: "joe@example.com",
|
|
||||||
Password: "Password1",
|
|
||||||
|
|
||||||
})
|
|
||||||
fmt.Println(rsp, err)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## List
|
## List
|
||||||
@@ -298,12 +261,12 @@ Offset: 0,
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Create
|
## Update
|
||||||
|
|
||||||
Create a new user account. The email address and username for the account must be unique.
|
Update the account username or email
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/user/api#Create](https://m3o.com/user/api#Create)
|
[https://m3o.com/user/api#Update](https://m3o.com/user/api#Update)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package example
|
package example
|
||||||
@@ -315,14 +278,12 @@ import(
|
|||||||
"go.m3o.com/user"
|
"go.m3o.com/user"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Create a new user account. The email address and username for the account must be unique.
|
// Update the account username or email
|
||||||
func CreateAnAccount() {
|
func UpdateAnAccount() {
|
||||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := userService.Create(&user.CreateRequest{
|
rsp, err := userService.Update(&user.UpdateRequest{
|
||||||
Email: "joe@example.com",
|
Email: "joe+2@example.com",
|
||||||
Id: "user-1",
|
Id: "user-1",
|
||||||
Password: "Password1",
|
|
||||||
Username: "joe",
|
|
||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
@@ -406,12 +367,13 @@ Please verify your email by clicking this link: $micro_verification_link`,
|
|||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## VerifyEmail
|
## SendPasswordResetEmail
|
||||||
|
|
||||||
Verify the email address of an account from a token sent in an email to the user.
|
Send an email with a verification code to reset password.
|
||||||
|
Call "ResetPassword" endpoint once user provides the code.
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail)
|
[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package example
|
package example
|
||||||
@@ -423,24 +385,28 @@ import(
|
|||||||
"go.m3o.com/user"
|
"go.m3o.com/user"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Verify the email address of an account from a token sent in an email to the user.
|
// Send an email with a verification code to reset password.
|
||||||
func VerifyEmail() {
|
// Call "ResetPassword" endpoint once user provides the code.
|
||||||
|
func SendPasswordResetEmail() {
|
||||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := userService.VerifyEmail(&user.VerifyEmailRequest{
|
rsp, err := userService.SendPasswordResetEmail(&user.SendPasswordResetEmailRequest{
|
||||||
Email: "joe@example.com",
|
Email: "joe@example.com",
|
||||||
Token: "012345",
|
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)
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Delete
|
## ResetPassword
|
||||||
|
|
||||||
Delete an account by id
|
Reset password with the code sent by the "SendPasswordResetEmail" endoint.
|
||||||
|
|
||||||
|
|
||||||
[https://m3o.com/user/api#Delete](https://m3o.com/user/api#Delete)
|
[https://m3o.com/user/api#ResetPassword](https://m3o.com/user/api#ResetPassword)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package example
|
package example
|
||||||
@@ -452,11 +418,45 @@ import(
|
|||||||
"go.m3o.com/user"
|
"go.m3o.com/user"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Delete an account by id
|
// Reset password with the code sent by the "SendPasswordResetEmail" endoint.
|
||||||
func DeleteUserAccount() {
|
func ResetPassword() {
|
||||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
rsp, err := userService.Delete(&user.DeleteRequest{
|
rsp, err := userService.ResetPassword(&user.ResetPasswordRequest{
|
||||||
Id: "8b98acbe-0b6a-4d66-a414-5ffbf666786f",
|
Code: "012345",
|
||||||
|
ConfirmPassword: "NewPassword1",
|
||||||
|
Email: "joe@example.com",
|
||||||
|
NewPassword: "NewPassword1",
|
||||||
|
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Login
|
||||||
|
|
||||||
|
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#Login](https://m3o.com/user/api#Login)
|
||||||
|
|
||||||
|
```go
|
||||||
|
package example
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"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() {
|
||||||
|
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||||
|
rsp, err := userService.Login(&user.LoginRequest{
|
||||||
|
Email: "joe@example.com",
|
||||||
|
Password: "Password1",
|
||||||
|
|
||||||
})
|
})
|
||||||
fmt.Println(rsp, err)
|
fmt.Println(rsp, err)
|
||||||
|
|||||||
@@ -34,6 +34,14 @@ func (t *SpaceService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Download an object via a presigned url
|
||||||
|
func (t *SpaceService) Download(request *DownloadRequest) (*DownloadResponse, error) {
|
||||||
|
|
||||||
|
rsp := &DownloadResponse{}
|
||||||
|
return rsp, t.client.Call("space", "Download", request, rsp)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Retrieve meta information about an object
|
// Retrieve meta information about an object
|
||||||
func (t *SpaceService) Head(request *HeadRequest) (*HeadResponse, error) {
|
func (t *SpaceService) Head(request *HeadRequest) (*HeadResponse, error) {
|
||||||
|
|
||||||
@@ -50,7 +58,7 @@ func (t *SpaceService) List(request *ListRequest) (*ListResponse, error) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read an object in space. Use for private objects.
|
// Read an object in space
|
||||||
func (t *SpaceService) Read(request *ReadRequest) (*ReadResponse, error) {
|
func (t *SpaceService) Read(request *ReadRequest) (*ReadResponse, error) {
|
||||||
|
|
||||||
rsp := &ReadResponse{}
|
rsp := &ReadResponse{}
|
||||||
@@ -90,6 +98,16 @@ type DeleteRequest struct {
|
|||||||
type DeleteResponse struct {
|
type DeleteResponse struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type DownloadRequest struct {
|
||||||
|
// name of object
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DownloadResponse struct {
|
||||||
|
// presigned url
|
||||||
|
Url string `json:"url"`
|
||||||
|
}
|
||||||
|
|
||||||
type HeadObject struct {
|
type HeadObject struct {
|
||||||
// when was this created
|
// when was this created
|
||||||
Created string `json:"created"`
|
Created string `json:"created"`
|
||||||
@@ -129,14 +147,29 @@ type ListResponse struct {
|
|||||||
Objects []ListObject `json:"objects"`
|
Objects []ListObject `json:"objects"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Object struct {
|
||||||
|
// when was this created
|
||||||
|
Created string `json:"created"`
|
||||||
|
// the data within the object
|
||||||
|
Data string `json:"data"`
|
||||||
|
// when was this last modified
|
||||||
|
Modified string `json:"modified"`
|
||||||
|
// name of object
|
||||||
|
Name string `json:"name"`
|
||||||
|
// URL to access the object if it is public
|
||||||
|
Url string `json:"url"`
|
||||||
|
// is this public or private
|
||||||
|
Visibility string `json:"visibility"`
|
||||||
|
}
|
||||||
|
|
||||||
type ReadRequest struct {
|
type ReadRequest struct {
|
||||||
// name of the object
|
// name of the object
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ReadResponse struct {
|
type ReadResponse struct {
|
||||||
// Returns the object as raw data
|
// The object itself
|
||||||
Object string `json:"object"`
|
Object *Object `json:"object"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UpdateRequest struct {
|
type UpdateRequest struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user