Commit from m3o/m3o action

This commit is contained in:
m3o-actions
2022-02-19 18:01:25 +00:00
parent 95f8372cb9
commit 7a39dbb5ad
19 changed files with 1116 additions and 1169 deletions

View File

@@ -8,7 +8,6 @@ type Emoji interface {
Find(*FindRequest) (*FindResponse, error) Find(*FindRequest) (*FindResponse, error)
Flag(*FlagRequest) (*FlagResponse, error) Flag(*FlagRequest) (*FlagResponse, error)
Print(*PrintRequest) (*PrintResponse, error) Print(*PrintRequest) (*PrintResponse, error)
Send(*SendRequest) (*SendResponse, error)
} }
func NewEmojiService(token string) *EmojiService { func NewEmojiService(token string) *EmojiService {
@@ -48,14 +47,6 @@ func (t *EmojiService) Print(request *PrintRequest) (*PrintResponse, error) {
} }
// Send an emoji to anyone via SMS. Messages are sent in the form '<message> Sent from <from>'
func (t *EmojiService) Send(request *SendRequest) (*SendResponse, error) {
rsp := &SendResponse{}
return rsp, t.client.Call("emoji", "Send", request, rsp)
}
type FindRequest struct { type FindRequest struct {
// the alias code e.g :beer: // the alias code e.g :beer:
Alias string `json:"alias"` Alias string `json:"alias"`
@@ -85,17 +76,3 @@ type PrintResponse struct {
// text with rendered emojis // text with rendered emojis
Text string `json:"text"` Text string `json:"text"`
} }
type SendRequest struct {
// the name of the sender from e.g Alice
From string `json:"from"`
// message to send including emoji aliases
Message string `json:"message"`
// phone number to send to (including international dialing code)
To string `json:"to"`
}
type SendResponse struct {
// whether or not it succeeded
Success bool `json:"success"`
}

View File

@@ -4,6 +4,117 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/app/api](https
Endpoints: Endpoints:
## Update
Update the app. The latest source code will be downloaded, built and deployed.
[https://m3o.com/app/api#Update](https://m3o.com/app/api#Update)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/app"
)
// Update the app. The latest source code will be downloaded, built and deployed.
func UpdateAnApp() {
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
rsp, err := appService.Update(&app.UpdateRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```
## Delete
Delete an app
[https://m3o.com/app/api#Delete](https://m3o.com/app/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/app"
)
// Delete an app
func DeleteAnApp() {
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
rsp, err := appService.Delete(&app.DeleteRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```
## 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
@@ -119,114 +230,3 @@ func ResolveAppById() {
} }
``` ```
## Update
Update the app. The latest source code will be downloaded, built and deployed.
[https://m3o.com/app/api#Update](https://m3o.com/app/api#Update)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/app"
)
// Update the app. The latest source code will be downloaded, built and deployed.
func UpdateAnApp() {
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
rsp, err := appService.Update(&app.UpdateRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```
## Delete
Delete an app
[https://m3o.com/app/api#Delete](https://m3o.com/app/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/app"
)
// Delete an app
func DeleteAnApp() {
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
rsp, err := appService.Delete(&app.DeleteRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```
## 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,6 +4,116 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/chat/api](http
Endpoints: Endpoints:
## History
List the messages in a chat
[https://m3o.com/chat/api#History](https://m3o.com/chat/api#History)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/chat"
)
// List the messages in a chat
func GetChatHistory() {
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
rsp, err := chatService.History(&chat.HistoryRequest{
})
fmt.Println(rsp, err)
}
```
## Leave
Leave a chat room
[https://m3o.com/chat/api#Leave](https://m3o.com/chat/api#Leave)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/chat"
)
// Leave a chat room
func LeaveAroom() {
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
rsp, err := chatService.Leave(&chat.LeaveRequest{
})
fmt.Println(rsp, err)
}
```
## New
Create a new chat room
[https://m3o.com/chat/api#New](https://m3o.com/chat/api#New)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/chat"
)
// Create a new chat room
func CreateAnewChat() {
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
rsp, err := chatService.New(&chat.NewRequest{
Description: "The general chat room",
Name: "general",
})
fmt.Println(rsp, err)
}
```
## List
List available chats
[https://m3o.com/chat/api#List](https://m3o.com/chat/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/chat"
)
// List available chats
func ListChatRooms() {
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
rsp, err := chatService.List(&chat.ListRequest{
})
fmt.Println(rsp, err)
}
```
## Delete ## Delete
Delete a chat room Delete a chat room
@@ -157,113 +267,3 @@ func KickAuserFromAroom() {
} }
``` ```
## New
Create a new chat room
[https://m3o.com/chat/api#New](https://m3o.com/chat/api#New)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/chat"
)
// Create a new chat room
func CreateAnewChat() {
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
rsp, err := chatService.New(&chat.NewRequest{
Description: "The general chat room",
Name: "general",
})
fmt.Println(rsp, err)
}
```
## List
List available chats
[https://m3o.com/chat/api#List](https://m3o.com/chat/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/chat"
)
// List available chats
func ListChatRooms() {
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
rsp, err := chatService.List(&chat.ListRequest{
})
fmt.Println(rsp, err)
}
```
## History
List the messages in a chat
[https://m3o.com/chat/api#History](https://m3o.com/chat/api#History)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/chat"
)
// List the messages in a chat
func GetChatHistory() {
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
rsp, err := chatService.History(&chat.HistoryRequest{
})
fmt.Println(rsp, err)
}
```
## Leave
Leave a chat room
[https://m3o.com/chat/api#Leave](https://m3o.com/chat/api#Leave)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/chat"
)
// Leave a chat room
func LeaveAroom() {
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
rsp, err := chatService.Leave(&chat.LeaveRequest{
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,34 +4,6 @@ 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 ## Delete
@@ -217,3 +189,31 @@ 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)
}
```

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,35 @@ 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)
}
```
## Create ## Create
Create a record in the database. Optionally include an "id" field otherwise it's set automatically. Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
@@ -26,10 +55,10 @@ func CreateArecord() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Create(&db.CreateRequest{ rsp, err := dbService.Create(&db.CreateRequest{
Record: map[string]interface{}{ Record: map[string]interface{}{
"id": "1",
"name": "Jane", "name": "Jane",
"age": 42, "age": 42,
"isActive": true, "isActive": true,
"id": "1",
}, },
Table: "example", Table: "example",
@@ -93,34 +122,6 @@ func TruncateTable() {
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
}
```
## DropTable
Drop a table in the DB
[https://m3o.com/db/api#DropTable](https://m3o.com/db/api#DropTable)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Drop a table in the DB
func DropTable() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.DropTable(&db.DropTableRequest{
Table: "example",
})
fmt.Println(rsp, err)
} }
``` ```
## Count ## Count
@@ -176,35 +177,6 @@ func ListTables() {
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
}
```
## 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
@@ -268,3 +240,31 @@ Table: "example",
} }
``` ```
## 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)
}
```

View File

@@ -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{}{
"isActive": true,
"id": "1", "id": "1",
"name": "Jane", "name": "Jane",
"age": 42, "age": 42,
"isActive": true,
}, },
Table: "example", Table: "example",
}) })

View File

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

View File

@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/event/api](htt
Endpoints: Endpoints:
## Read
Read stored events
[https://m3o.com/event/api#Read](https://m3o.com/event/api#Read)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/event"
)
// Read stored events
func ReadEventsOnAtopic() {
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
rsp, err := eventService.Read(&event.ReadRequest{
Topic: "user",
})
fmt.Println(rsp, err)
}
```
## Publish ## Publish
Publish a event to the event stream. Publish a event to the event stream.
@@ -106,3 +78,31 @@ func ConsumeFromAtopic() {
} }
} }
``` ```
## Read
Read stored events
[https://m3o.com/event/api#Read](https://m3o.com/event/api#Read)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/event"
)
// Read stored events
func ReadEventsOnAtopic() {
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
rsp, err := eventService.Read(&event.ReadRequest{
Topic: "user",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,35 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/file/api](http
Endpoints: Endpoints:
## Delete
Delete a file by project name/path
[https://m3o.com/file/api#Delete](https://m3o.com/file/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/file"
)
// Delete a file by project name/path
func DeleteFile() {
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
rsp, err := fileService.Delete(&file.DeleteRequest{
Path: "/document/text-files/file.txt",
Project: "examples",
})
fmt.Println(rsp, err)
}
```
## Save ## Save
Save a file Save a file
@@ -122,3 +93,32 @@ Project: "examples",
} }
``` ```
## Delete
Delete a file by project name/path
[https://m3o.com/file/api#Delete](https://m3o.com/file/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/file"
)
// Delete a file by project name/path
func DeleteFile() {
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
rsp, err := fileService.Delete(&file.DeleteRequest{
Path: "/document/text-files/file.txt",
Project: "examples",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,34 @@ 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
@@ -60,31 +88,3 @@ 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

@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/function/api](
Endpoints: Endpoints:
## Reserve
Reserve function names and resources beyond free quota
[https://m3o.com/function/api#Reserve](https://m3o.com/function/api#Reserve)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Reserve function names and resources beyond free quota
func ReserveAfunction() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Reserve(&function.ReserveRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```
## Update ## Update
Update a function. Downloads the source, builds and redeploys Update a function. Downloads the source, builds and redeploys
@@ -88,6 +116,89 @@ func ListFunctions() {
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
}
```
## Delete
Delete a function by name
[https://m3o.com/function/api#Delete](https://m3o.com/function/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Delete a function by name
func DeleteAfunction() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Delete(&function.DeleteRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```
## Describe
Get the info for a deployed function
[https://m3o.com/function/api#Describe](https://m3o.com/function/api#Describe)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Get the info for a deployed function
func DescribeFunctionStatus() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Describe(&function.DescribeRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```
## Regions
Return a list of supported regions
[https://m3o.com/function/api#Regions](https://m3o.com/function/api#Regions)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Return a list of supported regions
func ListRegions() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Regions(&function.RegionsRequest{
})
fmt.Println(rsp, err)
} }
``` ```
## Proxy ## Proxy
@@ -152,114 +263,3 @@ Subfolder: "examples/go-function",
} }
``` ```
## Describe
Get the info for a deployed function
[https://m3o.com/function/api#Describe](https://m3o.com/function/api#Describe)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Get the info for a deployed function
func DescribeFunctionStatus() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Describe(&function.DescribeRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```
## Regions
Return a list of supported regions
[https://m3o.com/function/api#Regions](https://m3o.com/function/api#Regions)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Return a list of supported regions
func ListRegions() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Regions(&function.RegionsRequest{
})
fmt.Println(rsp, err)
}
```
## Reserve
Reserve function names and resources beyond free quota
[https://m3o.com/function/api#Reserve](https://m3o.com/function/api#Reserve)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Reserve function names and resources beyond free quota
func ReserveAfunction() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Reserve(&function.ReserveRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```
## Delete
Delete a function by name
[https://m3o.com/function/api#Delete](https://m3o.com/function/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Delete a function by name
func DeleteAfunction() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Delete(&function.DeleteRequest{
Name: "helloworld",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,42 @@ 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
@@ -66,39 +102,3 @@ 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,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,34 +4,6 @@ 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.
@@ -212,3 +184,31 @@ func CreateAnIndex() {
} }
``` ```
## DeleteIndex
Delete an index by name
[https://m3o.com/search/api#DeleteIndex](https://m3o.com/search/api#DeleteIndex)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/search"
)
// Delete an index by name
func DeleteAnIndex() {
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
rsp, err := searchService.DeleteIndex(&search.DeleteIndexRequest{
Index: "customers",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,94 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/space/api](htt
Endpoints: Endpoints:
## Upload
Upload a large object (> 10MB). Returns a time limited presigned URL to be used for uploading the object
[https://m3o.com/space/api#Upload](https://m3o.com/space/api#Upload)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/space"
)
// Upload a large object (> 10MB). Returns a time limited presigned URL to be used for uploading the object
func UploadAnObject() {
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
rsp, err := spaceService.Upload(&space.UploadRequest{
Name: "images/file.jpg",
})
fmt.Println(rsp, err)
}
```
## Create
Create an object. Returns error if object with this name already exists. Max object size of 10MB, see Upload endpoint for larger objects. If you want to update an existing object use the `Update` endpoint
[https://m3o.com/space/api#Create](https://m3o.com/space/api#Create)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/space"
)
// Create an object. Returns error if object with this name already exists. Max object size of 10MB, see Upload endpoint for larger objects. If you want to update an existing object use the `Update` endpoint
func CreateAnObject() {
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
rsp, err := spaceService.Create(&space.CreateRequest{
Name: "images/file.jpg",
Object: "<file bytes>",
Visibility: "public",
})
fmt.Println(rsp, err)
}
```
## Update
Update an object. If an object with this name does not exist, creates a new one.
[https://m3o.com/space/api#Update](https://m3o.com/space/api#Update)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/space"
)
// Update an object. If an object with this name does not exist, creates a new one.
func UpdateAnObject() {
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
rsp, err := spaceService.Update(&space.UpdateRequest{
Name: "images/file.jpg",
Object: "<file bytes>",
Visibility: "public",
})
fmt.Println(rsp, err)
}
```
## Delete ## Delete
Delete an object from space Delete an object from space
@@ -144,91 +232,3 @@ func DownloadAnObject() {
} }
``` ```
## Upload
Upload a large object (> 10MB). Returns a time limited presigned URL to be used for uploading the object
[https://m3o.com/space/api#Upload](https://m3o.com/space/api#Upload)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/space"
)
// Upload a large object (> 10MB). Returns a time limited presigned URL to be used for uploading the object
func UploadAnObject() {
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
rsp, err := spaceService.Upload(&space.UploadRequest{
Name: "images/file.jpg",
})
fmt.Println(rsp, err)
}
```
## Create
Create an object. Returns error if object with this name already exists. Max object size of 10MB, see Upload endpoint for larger objects. If you want to update an existing object use the `Update` endpoint
[https://m3o.com/space/api#Create](https://m3o.com/space/api#Create)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/space"
)
// Create an object. Returns error if object with this name already exists. Max object size of 10MB, see Upload endpoint for larger objects. If you want to update an existing object use the `Update` endpoint
func CreateAnObject() {
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
rsp, err := spaceService.Create(&space.CreateRequest{
Name: "images/file.jpg",
Object: "<file bytes>",
Visibility: "public",
})
fmt.Println(rsp, err)
}
```
## Update
Update an object. If an object with this name does not exist, creates a new one.
[https://m3o.com/space/api#Update](https://m3o.com/space/api#Update)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/space"
)
// Update an object. If an object with this name does not exist, creates a new one.
func UpdateAnObject() {
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
rsp, err := spaceService.Update(&space.UpdateRequest{
Name: "images/file.jpg",
Object: "<file bytes>",
Visibility: "public",
})
fmt.Println(rsp, err)
}
```

View File

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

View File

@@ -4,6 +4,61 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/twitter/api](h
Endpoints: Endpoints:
## Trends
Get the current global trending topics
[https://m3o.com/twitter/api#Trends](https://m3o.com/twitter/api#Trends)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/twitter"
)
// Get the current global trending topics
func GetTheCurrentGlobalTrendingTopics() {
twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN"))
rsp, err := twitterService.Trends(&twitter.TrendsRequest{
})
fmt.Println(rsp, err)
}
```
## User
Get a user's twitter profile
[https://m3o.com/twitter/api#User](https://m3o.com/twitter/api#User)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/twitter"
)
// Get a user's twitter profile
func GetAusersTwitterProfile() {
twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN"))
rsp, err := twitterService.User(&twitter.UserRequest{
Username: "crufter",
})
fmt.Println(rsp, err)
}
```
## Timeline ## Timeline
Get the timeline for a given user Get the timeline for a given user
@@ -61,58 +116,3 @@ func SearchForTweets() {
} }
``` ```
## Trends
Get the current global trending topics
[https://m3o.com/twitter/api#Trends](https://m3o.com/twitter/api#Trends)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/twitter"
)
// Get the current global trending topics
func GetTheCurrentGlobalTrendingTopics() {
twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN"))
rsp, err := twitterService.Trends(&twitter.TrendsRequest{
})
fmt.Println(rsp, err)
}
```
## User
Get a user's twitter profile
[https://m3o.com/twitter/api#User](https://m3o.com/twitter/api#User)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/twitter"
)
// Get a user's twitter profile
func GetAusersTwitterProfile() {
twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN"))
rsp, err := twitterService.User(&twitter.UserRequest{
Username: "crufter",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,134 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/user/api](http
Endpoints: Endpoints:
## 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)
}
```
## ResetPassword
Reset password with the code sent by the "SendPasswordResetEmail" endpoint.
[https://m3o.com/user/api#ResetPassword](https://m3o.com/user/api#ResetPassword)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Reset password with the code sent by the "SendPasswordResetEmail" endpoint.
func ResetPassword() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.ResetPassword(&user.ResetPasswordRequest{
Code: "012345",
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)
}
```
## 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
Create a new user account. The email address and username for the account must be unique. Create a new user account. The email address and username for the account must be unique.
@@ -194,13 +66,12 @@ UserId: "user-1",
} }
``` ```
## Login ## Read
Login using username or email. The response will return a new session for successful login, Read an account by id, username or email. Only one need to be specified.
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) [https://m3o.com/user/api#Read](https://m3o.com/user/api#Read)
```go ```go
package example package example
@@ -212,25 +83,23 @@ import(
"go.m3o.com/user" "go.m3o.com/user"
) )
// Login using username or email. The response will return a new session for successful login, // Read an account by id, username or email. Only one need to be specified.
// 401 in the case of login failure and 500 for any other error func ReadAnAccountById() {
func LogAuserIn() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.Login(&user.LoginRequest{ rsp, err := userService.Read(&user.ReadRequest{
Email: "joe@example.com", Id: "user-1",
Password: "Password1",
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
} }
``` ```
## List ## Read
List all users. Returns a paged list of results Read an account by id, username or email. Only one need to be specified.
[https://m3o.com/user/api#List](https://m3o.com/user/api#List) [https://m3o.com/user/api#Read](https://m3o.com/user/api#Read)
```go ```go
package example package example
@@ -242,12 +111,131 @@ import(
"go.m3o.com/user" "go.m3o.com/user"
) )
// List all users. Returns a paged list of results // Read an account by id, username or email. Only one need to be specified.
func ListAllUsers() { func ReadAccountByUsernameOrEmail() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.List(&user.ListRequest{ rsp, err := userService.Read(&user.ReadRequest{
Limit: 100, Username: "joe",
Offset: 0,
})
fmt.Println(rsp, err)
}
```
## Read
Read an account by id, username or email. Only one need to be specified.
[https://m3o.com/user/api#Read](https://m3o.com/user/api#Read)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Read an account by id, username or email. Only one need to be specified.
func ReadAccountByEmail() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.Read(&user.ReadRequest{
Email: "joe@example.com",
})
fmt.Println(rsp, err)
}
```
## Delete
Delete an account by id
[https://m3o.com/user/api#Delete](https://m3o.com/user/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Delete an account by id
func DeleteUserAccount() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.Delete(&user.DeleteRequest{
Id: "8b98acbe-0b6a-4d66-a414-5ffbf666786f",
})
fmt.Println(rsp, err)
}
```
## 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",
Username: "joe",
})
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) fmt.Println(rsp, err)
@@ -342,120 +330,6 @@ func VerifyAtoken() {
}) })
fmt.Println(rsp, err) 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",
Username: "joe",
})
fmt.Println(rsp, err)
}
```
## Read
Read an account by id, username or email. Only one need to be specified.
[https://m3o.com/user/api#Read](https://m3o.com/user/api#Read)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Read an account by id, username or email. Only one need to be specified.
func ReadAnAccountById() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.Read(&user.ReadRequest{
Id: "user-1",
})
fmt.Println(rsp, err)
}
```
## Read
Read an account by id, username or email. Only one need to be specified.
[https://m3o.com/user/api#Read](https://m3o.com/user/api#Read)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Read an account by id, username or email. Only one need to be specified.
func ReadAccountByUsernameOrEmail() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.Read(&user.ReadRequest{
Username: "joe",
})
fmt.Println(rsp, err)
}
```
## Read
Read an account by id, username or email. Only one need to be specified.
[https://m3o.com/user/api#Read](https://m3o.com/user/api#Read)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Read an account by id, username or email. Only one need to be specified.
func ReadAccountByEmail() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.Read(&user.ReadRequest{
Email: "joe@example.com",
})
fmt.Println(rsp, err)
} }
``` ```
## SendVerificationEmail ## SendVerificationEmail
@@ -505,12 +379,12 @@ Please verify your email by clicking this link: $micro_verification_link`,
} }
``` ```
## Delete ## ResetPassword
Delete an account by id Reset password with the code sent by the "SendPasswordResetEmail" endpoint.
[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
@@ -522,11 +396,137 @@ import(
"go.m3o.com/user" "go.m3o.com/user"
) )
// Delete an account by id // Reset password with the code sent by the "SendPasswordResetEmail" endpoint.
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)
}
```
## 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)
}
```
## 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)
}
```
## 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) fmt.Println(rsp, err)