mirror of
https://github.com/kevin-DL/m3o-go.git
synced 2026-01-11 10:34:27 +00:00
Commit from m3o/m3o action
This commit is contained in:
@@ -4,6 +4,90 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/app/api](https
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Status
|
||||
|
||||
Get the status of an app
|
||||
|
||||
|
||||
[https://m3o.com/app/api#Status](https://m3o.com/app/api#Status)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/app"
|
||||
)
|
||||
|
||||
// Get the status of an app
|
||||
func GetTheStatusOfAnApp() {
|
||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := appService.Status(&app.StatusRequest{
|
||||
Name: "helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Resolve
|
||||
|
||||
Resolve an app by id to its raw backend endpoint
|
||||
|
||||
|
||||
[https://m3o.com/app/api#Resolve](https://m3o.com/app/api#Resolve)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/app"
|
||||
)
|
||||
|
||||
// Resolve an app by id to its raw backend endpoint
|
||||
func ResolveAppById() {
|
||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := appService.Resolve(&app.ResolveRequest{
|
||||
Id: "helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Update
|
||||
|
||||
Update the app. The latest source code will be downloaded, built and deployed.
|
||||
|
||||
|
||||
[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
|
||||
@@ -146,87 +230,3 @@ func ListRegions() {
|
||||
|
||||
}
|
||||
```
|
||||
## Status
|
||||
|
||||
Get the status of an app
|
||||
|
||||
|
||||
[https://m3o.com/app/api#Status](https://m3o.com/app/api#Status)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/app"
|
||||
)
|
||||
|
||||
// Get the status of an app
|
||||
func GetTheStatusOfAnApp() {
|
||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := appService.Status(&app.StatusRequest{
|
||||
Name: "helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Resolve
|
||||
|
||||
Resolve an app by id to its raw backend endpoint
|
||||
|
||||
|
||||
[https://m3o.com/app/api#Resolve](https://m3o.com/app/api#Resolve)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/app"
|
||||
)
|
||||
|
||||
// Resolve an app by id to its raw backend endpoint
|
||||
func ResolveAppById() {
|
||||
appService := app.NewAppService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := appService.Resolve(&app.ResolveRequest{
|
||||
Id: "helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Update
|
||||
|
||||
Update the app. The latest source code will be downloaded, built and deployed.
|
||||
|
||||
|
||||
[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)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,12 +4,12 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/chat/api](http
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Delete
|
||||
## Kick
|
||||
|
||||
Delete a chat room
|
||||
Kick a user from a chat room
|
||||
|
||||
|
||||
[https://m3o.com/chat/api#Delete](https://m3o.com/chat/api#Delete)
|
||||
[https://m3o.com/chat/api#Kick](https://m3o.com/chat/api#Kick)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -21,10 +21,71 @@ import(
|
||||
"go.m3o.com/chat"
|
||||
)
|
||||
|
||||
// Delete a chat room
|
||||
func DeleteAchat() {
|
||||
// Kick a user from a chat room
|
||||
func KickAuserFromAroom() {
|
||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := chatService.Delete(&chat.DeleteRequest{
|
||||
rsp, err := chatService.Kick(&chat.KickRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Create
|
||||
|
||||
Create a new chat room
|
||||
|
||||
|
||||
[https://m3o.com/chat/api#Create](https://m3o.com/chat/api#Create)
|
||||
|
||||
```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.Create(&chat.CreateRequest{
|
||||
Description: "The general chat room",
|
||||
Name: "general",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Send
|
||||
|
||||
Connect to a chat to receive a stream of messages
|
||||
Send a message to a chat
|
||||
|
||||
|
||||
[https://m3o.com/chat/api#Send](https://m3o.com/chat/api#Send)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/chat"
|
||||
)
|
||||
|
||||
// Connect to a chat to receive a stream of messages
|
||||
// Send a message to a chat
|
||||
func SendAmessage() {
|
||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := chatService.Send(&chat.SendRequest{
|
||||
Client: "web",
|
||||
Subject: "Random",
|
||||
Text: "Hey whats up?",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
@@ -98,89 +159,6 @@ func JoinAroom() {
|
||||
}
|
||||
}
|
||||
```
|
||||
## Kick
|
||||
|
||||
Kick a user from a chat room
|
||||
|
||||
|
||||
[https://m3o.com/chat/api#Kick](https://m3o.com/chat/api#Kick)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/chat"
|
||||
)
|
||||
|
||||
// Kick a user from a chat room
|
||||
func KickAuserFromAroom() {
|
||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := chatService.Kick(&chat.KickRequest{
|
||||
|
||||
})
|
||||
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)
|
||||
|
||||
}
|
||||
```
|
||||
## Create
|
||||
|
||||
Create a new chat room
|
||||
|
||||
|
||||
[https://m3o.com/chat/api#Create](https://m3o.com/chat/api#Create)
|
||||
|
||||
```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.Create(&chat.CreateRequest{
|
||||
Description: "The general chat room",
|
||||
Name: "general",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
List available chats
|
||||
@@ -206,6 +184,33 @@ func ListChatRooms() {
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
|
||||
Delete a chat room
|
||||
|
||||
|
||||
[https://m3o.com/chat/api#Delete](https://m3o.com/chat/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/chat"
|
||||
)
|
||||
|
||||
// Delete a chat room
|
||||
func DeleteAchat() {
|
||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := chatService.Delete(&chat.DeleteRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Invite
|
||||
@@ -235,13 +240,12 @@ func InviteAuser() {
|
||||
|
||||
}
|
||||
```
|
||||
## Send
|
||||
## Leave
|
||||
|
||||
Connect to a chat to receive a stream of messages
|
||||
Send a message to a chat
|
||||
Leave a chat room
|
||||
|
||||
|
||||
[https://m3o.com/chat/api#Send](https://m3o.com/chat/api#Send)
|
||||
[https://m3o.com/chat/api#Leave](https://m3o.com/chat/api#Leave)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -253,14 +257,10 @@ import(
|
||||
"go.m3o.com/chat"
|
||||
)
|
||||
|
||||
// Connect to a chat to receive a stream of messages
|
||||
// Send a message to a chat
|
||||
func SendAmessage() {
|
||||
// Leave a chat room
|
||||
func LeaveAroom() {
|
||||
chatService := chat.NewChatService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := chatService.Send(&chat.SendRequest{
|
||||
Client: "web",
|
||||
Subject: "Random",
|
||||
Text: "Hey whats up?",
|
||||
rsp, err := chatService.Leave(&chat.LeaveRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/comments/api](
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Read
|
||||
|
||||
Read a comment
|
||||
|
||||
|
||||
[https://m3o.com/comments/api#Read](https://m3o.com/comments/api#Read)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/comments"
|
||||
)
|
||||
|
||||
// Read a comment
|
||||
func ReadAcomment() {
|
||||
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := commentsService.Read(&comments.ReadRequest{
|
||||
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
List all the comments
|
||||
@@ -160,31 +188,3 @@ func CreateAcomment() {
|
||||
|
||||
}
|
||||
```
|
||||
## Read
|
||||
|
||||
Read a comment
|
||||
|
||||
|
||||
[https://m3o.com/comments/api#Read](https://m3o.com/comments/api#Read)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/comments"
|
||||
)
|
||||
|
||||
// Read a comment
|
||||
func ReadAcomment() {
|
||||
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := commentsService.Read(&comments.ReadRequest{
|
||||
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,62 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/contact/api](h
|
||||
|
||||
Endpoints:
|
||||
|
||||
## List
|
||||
|
||||
List contacts
|
||||
|
||||
|
||||
[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/contact"
|
||||
)
|
||||
|
||||
// List contacts
|
||||
func ListContactsWithDefaultOffsetAndLimitDefaultLimitIs20() {
|
||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := contactService.List(&contact.ListRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
List contacts
|
||||
|
||||
|
||||
[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/contact"
|
||||
)
|
||||
|
||||
// List contacts
|
||||
func ListContactsWithSpecificOffsetAndLimit() {
|
||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := contactService.List(&contact.ListRequest{
|
||||
Limit: 1,
|
||||
Offset: 1,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Create
|
||||
|
||||
Create a contact
|
||||
@@ -217,3 +161,59 @@ func DeleteAcontact() {
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
List contacts
|
||||
|
||||
|
||||
[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/contact"
|
||||
)
|
||||
|
||||
// List contacts
|
||||
func ListContactsWithDefaultOffsetAndLimitDefaultLimitIs20() {
|
||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := contactService.List(&contact.ListRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
List contacts
|
||||
|
||||
|
||||
[https://m3o.com/contact/api#List](https://m3o.com/contact/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/contact"
|
||||
)
|
||||
|
||||
// List contacts
|
||||
func ListContactsWithSpecificOffsetAndLimit() {
|
||||
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := contactService.List(&contact.ListRequest{
|
||||
Limit: 1,
|
||||
Offset: 1,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,62 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/crypto/api](ht
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Price
|
||||
|
||||
Get the last price for a given crypto ticker
|
||||
|
||||
|
||||
[https://m3o.com/crypto/api#Price](https://m3o.com/crypto/api#Price)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/crypto"
|
||||
)
|
||||
|
||||
// Get the last price for a given crypto ticker
|
||||
func GetCryptocurrencyPrice() {
|
||||
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cryptoService.Price(&crypto.PriceRequest{
|
||||
Symbol: "BTCUSD",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## 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
|
||||
@@ -87,59 +143,3 @@ func GetCryptocurrencyNews() {
|
||||
|
||||
}
|
||||
```
|
||||
## Price
|
||||
|
||||
Get the last price for a given crypto ticker
|
||||
|
||||
|
||||
[https://m3o.com/crypto/api#Price](https://m3o.com/crypto/api#Price)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/crypto"
|
||||
)
|
||||
|
||||
// Get the last price for a given crypto ticker
|
||||
func GetCryptocurrencyPrice() {
|
||||
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cryptoService.Price(&crypto.PriceRequest{
|
||||
Symbol: "BTCUSD",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,35 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/currency/api](
|
||||
|
||||
Endpoints:
|
||||
|
||||
## History
|
||||
|
||||
Returns the historic rates for a currency on a given date
|
||||
|
||||
|
||||
[https://m3o.com/currency/api#History](https://m3o.com/currency/api#History)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/currency"
|
||||
)
|
||||
|
||||
// Returns the historic rates for a currency on a given date
|
||||
func HistoricRatesForAcurrency() {
|
||||
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := currencyService.History(¤cy.HistoryRequest{
|
||||
Code: "USD",
|
||||
Date: "2021-05-30",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Codes
|
||||
|
||||
Codes returns the supported currency codes for the API
|
||||
@@ -147,3 +118,32 @@ To: "GBP",
|
||||
|
||||
}
|
||||
```
|
||||
## History
|
||||
|
||||
Returns the historic rates for a currency on a given date
|
||||
|
||||
|
||||
[https://m3o.com/currency/api#History](https://m3o.com/currency/api#History)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/currency"
|
||||
)
|
||||
|
||||
// Returns the historic rates for a currency on a given date
|
||||
func HistoricRatesForAcurrency() {
|
||||
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := currencyService.History(¤cy.HistoryRequest{
|
||||
Code: "USD",
|
||||
Date: "2021-05-30",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,12 +4,12 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/db/api](https:
|
||||
|
||||
Endpoints:
|
||||
|
||||
## RenameTable
|
||||
## Update
|
||||
|
||||
Rename a table
|
||||
Update a record in the database. Include an "id" in the record to update.
|
||||
|
||||
|
||||
[https://m3o.com/db/api#RenameTable](https://m3o.com/db/api#RenameTable)
|
||||
[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -21,12 +21,15 @@ import(
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Rename a table
|
||||
func RenameTable() {
|
||||
// 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.RenameTable(&db.RenameTableRequest{
|
||||
From: "examples2",
|
||||
To: "examples3",
|
||||
rsp, err := dbService.Update(&db.UpdateRequest{
|
||||
Record: map[string]interface{}{
|
||||
"age": 43,
|
||||
"id": "1",
|
||||
},
|
||||
Table: "example",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
@@ -62,12 +65,12 @@ Table: "example",
|
||||
|
||||
}
|
||||
```
|
||||
## DropTable
|
||||
## Count
|
||||
|
||||
Drop a table in the DB
|
||||
Count records in a table
|
||||
|
||||
|
||||
[https://m3o.com/db/api#DropTable](https://m3o.com/db/api#DropTable)
|
||||
[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -79,15 +82,49 @@ import(
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Drop a table in the DB
|
||||
func DropTable() {
|
||||
// Count records in a table
|
||||
func CountEntriesInAtable() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.DropTable(&db.DropTableRequest{
|
||||
rsp, err := dbService.Count(&db.CountRequest{
|
||||
Table: "example",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Create
|
||||
|
||||
Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||
func CreateArecord() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Create(&db.CreateRequest{
|
||||
Record: map[string]interface{}{
|
||||
"id": "1",
|
||||
"name": "Jane",
|
||||
"age": 42,
|
||||
"isActive": true,
|
||||
},
|
||||
Table: "example",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Read
|
||||
@@ -147,12 +184,12 @@ func TruncateTable() {
|
||||
|
||||
}
|
||||
```
|
||||
## Count
|
||||
## DropTable
|
||||
|
||||
Count records in a table
|
||||
Drop a table in the DB
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count)
|
||||
[https://m3o.com/db/api#DropTable](https://m3o.com/db/api#DropTable)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -164,10 +201,10 @@ import(
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Count records in a table
|
||||
func CountEntriesInAtable() {
|
||||
// Drop a table in the DB
|
||||
func DropTable() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Count(&db.CountRequest{
|
||||
rsp, err := dbService.DropTable(&db.DropTableRequest{
|
||||
Table: "example",
|
||||
|
||||
})
|
||||
@@ -202,12 +239,12 @@ func ListTables() {
|
||||
|
||||
}
|
||||
```
|
||||
## Create
|
||||
## RenameTable
|
||||
|
||||
Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||
Rename a table
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create)
|
||||
[https://m3o.com/db/api#RenameTable](https://m3o.com/db/api#RenameTable)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -219,49 +256,12 @@ import(
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||
func CreateArecord() {
|
||||
// Rename a table
|
||||
func RenameTable() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Create(&db.CreateRequest{
|
||||
Record: map[string]interface{}{
|
||||
"id": "1",
|
||||
"name": "Jane",
|
||||
"age": 42,
|
||||
"isActive": true,
|
||||
},
|
||||
Table: "example",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Update
|
||||
|
||||
Update a record in the database. Include an "id" in the record to update.
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Update a record in the database. Include an "id" in the record to update.
|
||||
func UpdateArecord() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Update(&db.UpdateRequest{
|
||||
Record: map[string]interface{}{
|
||||
"age": 43,
|
||||
"id": "1",
|
||||
},
|
||||
Table: "example",
|
||||
rsp, err := dbService.RenameTable(&db.RenameTableRequest{
|
||||
From: "examples2",
|
||||
To: "examples3",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
@@ -4,6 +4,36 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/emoji/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Print
|
||||
|
||||
Print text and renders the emojis with aliases e.g
|
||||
let's grab a :beer: becomes let's grab a 🍺
|
||||
|
||||
|
||||
[https://m3o.com/emoji/api#Print](https://m3o.com/emoji/api#Print)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/emoji"
|
||||
)
|
||||
|
||||
// Print text and renders the emojis with aliases e.g
|
||||
// let's grab a :beer: becomes let's grab a 🍺
|
||||
func PrintTextIncludingEmoji() {
|
||||
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := emojiService.Print(&emoji.PrintRequest{
|
||||
Text: "let's grab a :beer:",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Find
|
||||
|
||||
Find an emoji by its alias e.g :beer:
|
||||
@@ -59,33 +89,3 @@ func GetFlagByCountryCode() {
|
||||
|
||||
}
|
||||
```
|
||||
## Print
|
||||
|
||||
Print text and renders the emojis with aliases e.g
|
||||
let's grab a :beer: becomes let's grab a 🍺
|
||||
|
||||
|
||||
[https://m3o.com/emoji/api#Print](https://m3o.com/emoji/api#Print)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/emoji"
|
||||
)
|
||||
|
||||
// Print text and renders the emojis with aliases e.g
|
||||
// let's grab a :beer: becomes let's grab a 🍺
|
||||
func PrintTextIncludingEmoji() {
|
||||
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := emojiService.Print(&emoji.PrintRequest{
|
||||
Text: "let's grab a :beer:",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/forex/api](htt
|
||||
|
||||
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
|
||||
|
||||
Get the latest price for a given forex ticker
|
||||
@@ -88,3 +60,31 @@ func GetAfxQuote() {
|
||||
|
||||
}
|
||||
```
|
||||
## History
|
||||
|
||||
Returns the data for the previous close
|
||||
|
||||
|
||||
[https://m3o.com/forex/api#History](https://m3o.com/forex/api#History)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/forex"
|
||||
)
|
||||
|
||||
// Returns the data for the previous close
|
||||
func GetPreviousClose() {
|
||||
forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := forexService.History(&forex.HistoryRequest{
|
||||
Symbol: "GBPUSD",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,12 +4,12 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/function/api](
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Regions
|
||||
## Runtimes
|
||||
|
||||
Return a list of supported regions
|
||||
Return a list of supported runtimes
|
||||
|
||||
|
||||
[https://m3o.com/function/api#Regions](https://m3o.com/function/api#Regions)
|
||||
[https://m3o.com/function/api#Runtimes](https://m3o.com/function/api#Runtimes)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -21,38 +21,10 @@ import(
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Return a list of supported regions
|
||||
func ListRegions() {
|
||||
// Return a list of supported runtimes
|
||||
func ListRuntimes() {
|
||||
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",
|
||||
rsp, err := functionService.Runtimes(&function.RuntimesRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
@@ -91,6 +63,149 @@ Subfolder: "examples/go-function",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Update
|
||||
|
||||
Update a function. Downloads the source, builds and redeploys
|
||||
|
||||
|
||||
[https://m3o.com/function/api#Update](https://m3o.com/function/api#Update)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Update a function. Downloads the source, builds and redeploys
|
||||
func UpdateAfunction() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Update(&function.UpdateRequest{
|
||||
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)
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
## Proxy
|
||||
|
||||
Return the backend url for proxying
|
||||
|
||||
|
||||
[https://m3o.com/function/api#Proxy](https://m3o.com/function/api#Proxy)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Return the backend url for proxying
|
||||
func ProxyUrl() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Proxy(&function.ProxyRequest{
|
||||
Id: "helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Call
|
||||
|
||||
Call a function by name
|
||||
|
||||
|
||||
[https://m3o.com/function/api#Call](https://m3o.com/function/api#Call)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Call a function by name
|
||||
func CallAfunction() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Call(&function.CallRequest{
|
||||
Name: "helloworld",
|
||||
Request: map[string]interface{}{
|
||||
"name": "Alice",
|
||||
},
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
@@ -148,12 +263,12 @@ func DeleteAfunction() {
|
||||
|
||||
}
|
||||
```
|
||||
## Describe
|
||||
## Regions
|
||||
|
||||
Get the info for a deployed function
|
||||
Return a list of supported regions
|
||||
|
||||
|
||||
[https://m3o.com/function/api#Describe](https://m3o.com/function/api#Describe)
|
||||
[https://m3o.com/function/api#Regions](https://m3o.com/function/api#Regions)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -165,125 +280,10 @@ import(
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Get the info for a deployed function
|
||||
func DescribeFunctionStatus() {
|
||||
// Return a list of supported regions
|
||||
func ListRegions() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Describe(&function.DescribeRequest{
|
||||
Name: "helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Update
|
||||
|
||||
Update a function. Downloads the source, builds and redeploys
|
||||
|
||||
|
||||
[https://m3o.com/function/api#Update](https://m3o.com/function/api#Update)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Update a function. Downloads the source, builds and redeploys
|
||||
func UpdateAfunction() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Update(&function.UpdateRequest{
|
||||
Name: "helloworld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Call
|
||||
|
||||
Call a function by name
|
||||
|
||||
|
||||
[https://m3o.com/function/api#Call](https://m3o.com/function/api#Call)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Call a function by name
|
||||
func CallAfunction() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Call(&function.CallRequest{
|
||||
Name: "helloworld",
|
||||
Request: map[string]interface{}{
|
||||
"name": "Alice",
|
||||
},
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Runtimes
|
||||
|
||||
Return a list of supported runtimes
|
||||
|
||||
|
||||
[https://m3o.com/function/api#Runtimes](https://m3o.com/function/api#Runtimes)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Return a list of supported runtimes
|
||||
func ListRuntimes() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Runtimes(&function.RuntimesRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Proxy
|
||||
|
||||
Return the backend url for proxying
|
||||
|
||||
|
||||
[https://m3o.com/function/api#Proxy](https://m3o.com/function/api#Proxy)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/function"
|
||||
)
|
||||
|
||||
// Return the backend url for proxying
|
||||
func ProxyUrl() {
|
||||
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := functionService.Proxy(&function.ProxyRequest{
|
||||
Id: "helloworld",
|
||||
rsp, err := functionService.Regions(&function.RegionsRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
@@ -4,88 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/lists/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Create
|
||||
|
||||
Create a new list
|
||||
|
||||
|
||||
[https://m3o.com/lists/api#Create](https://m3o.com/lists/api#Create)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/lists"
|
||||
)
|
||||
|
||||
// Create a new list
|
||||
func CreateAlist() {
|
||||
listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := listsService.Create(&lists.CreateRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Read
|
||||
|
||||
Read a list
|
||||
|
||||
|
||||
[https://m3o.com/lists/api#Read](https://m3o.com/lists/api#Read)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/lists"
|
||||
)
|
||||
|
||||
// Read a list
|
||||
func ReadAlist() {
|
||||
listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := listsService.Read(&lists.ReadRequest{
|
||||
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
List all the lists
|
||||
|
||||
|
||||
[https://m3o.com/lists/api#List](https://m3o.com/lists/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/lists"
|
||||
)
|
||||
|
||||
// List all the lists
|
||||
func ListAllLists() {
|
||||
listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := listsService.List(&lists.ListRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Update
|
||||
|
||||
Update a list
|
||||
@@ -185,3 +103,85 @@ func SubscribeToEvents() {
|
||||
}
|
||||
}
|
||||
```
|
||||
## Create
|
||||
|
||||
Create a new list
|
||||
|
||||
|
||||
[https://m3o.com/lists/api#Create](https://m3o.com/lists/api#Create)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/lists"
|
||||
)
|
||||
|
||||
// Create a new list
|
||||
func CreateAlist() {
|
||||
listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := listsService.Create(&lists.CreateRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Read
|
||||
|
||||
Read a list
|
||||
|
||||
|
||||
[https://m3o.com/lists/api#Read](https://m3o.com/lists/api#Read)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/lists"
|
||||
)
|
||||
|
||||
// Read a list
|
||||
func ReadAlist() {
|
||||
listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := listsService.Read(&lists.ReadRequest{
|
||||
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
List all the lists
|
||||
|
||||
|
||||
[https://m3o.com/lists/api#List](https://m3o.com/lists/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/lists"
|
||||
)
|
||||
|
||||
// List all the lists
|
||||
func ListAllLists() {
|
||||
listsService := lists.NewListsService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := listsService.List(&lists.ListRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,39 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/mq/api](https:
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Publish
|
||||
|
||||
Publish a message. Specify a topic to group messages for a specific topic.
|
||||
|
||||
|
||||
[https://m3o.com/mq/api#Publish](https://m3o.com/mq/api#Publish)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/mq"
|
||||
)
|
||||
|
||||
// Publish a message. Specify a topic to group messages for a specific topic.
|
||||
func PublishAmessage() {
|
||||
mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := mqService.Publish(&mq.PublishRequest{
|
||||
Message: map[string]interface{}{
|
||||
"id": "1",
|
||||
"type": "signup",
|
||||
"user": "john",
|
||||
},
|
||||
Topic: "events",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Subscribe
|
||||
|
||||
Subscribe to messages for a given topic.
|
||||
@@ -78,3 +45,36 @@ func SubscribeToAtopic() {
|
||||
}
|
||||
}
|
||||
```
|
||||
## Publish
|
||||
|
||||
Publish a message. Specify a topic to group messages for a specific topic.
|
||||
|
||||
|
||||
[https://m3o.com/mq/api#Publish](https://m3o.com/mq/api#Publish)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/mq"
|
||||
)
|
||||
|
||||
// Publish a message. Specify a topic to group messages for a specific topic.
|
||||
func PublishAmessage() {
|
||||
mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := mqService.Publish(&mq.PublishRequest{
|
||||
Message: map[string]interface{}{
|
||||
"id": "1",
|
||||
"type": "signup",
|
||||
"user": "john",
|
||||
},
|
||||
Topic: "events",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -6,7 +6,7 @@ Endpoints:
|
||||
|
||||
## Generate
|
||||
|
||||
Generate a strong random password
|
||||
Generate a strong random password. Use the switches to control which character types are included, defaults to using all of them
|
||||
|
||||
|
||||
[https://m3o.com/password/api#Generate](https://m3o.com/password/api#Generate)
|
||||
@@ -21,7 +21,7 @@ import(
|
||||
"go.m3o.com/password"
|
||||
)
|
||||
|
||||
// Generate a strong random password
|
||||
// Generate a strong random password. Use the switches to control which character types are included, defaults to using all of them
|
||||
func GeneratePassword() {
|
||||
passwordService := password.NewPasswordService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := passwordService.Generate(&password.GenerateRequest{
|
||||
@@ -32,3 +32,35 @@ func GeneratePassword() {
|
||||
|
||||
}
|
||||
```
|
||||
## Generate
|
||||
|
||||
Generate a strong random password. Use the switches to control which character types are included, defaults to using all of them
|
||||
|
||||
|
||||
[https://m3o.com/password/api#Generate](https://m3o.com/password/api#Generate)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/password"
|
||||
)
|
||||
|
||||
// Generate a strong random password. Use the switches to control which character types are included, defaults to using all of them
|
||||
func GeneratePasswordWithoutSpecialCharacters() {
|
||||
passwordService := password.NewPasswordService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := passwordService.Generate(&password.GenerateRequest{
|
||||
Length: 16,
|
||||
Lowercase: true,
|
||||
Numbers: true,
|
||||
Special: false,
|
||||
Uppercase: true,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"go.m3o.com/password"
|
||||
)
|
||||
|
||||
// Generate a strong random password
|
||||
// Generate a strong random password. Use the switches to control which character types are included, defaults to using all of them
|
||||
func main() {
|
||||
passwordService := password.NewPasswordService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := passwordService.Generate(&password.GenerateRequest{
|
||||
|
||||
21
examples/password/generate/generatePasswordWithoutSpecialCharacters/main.go
Executable file
21
examples/password/generate/generatePasswordWithoutSpecialCharacters/main.go
Executable file
@@ -0,0 +1,21 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/password"
|
||||
)
|
||||
|
||||
// Generate a strong random password. Use the switches to control which character types are included, defaults to using all of them
|
||||
func main() {
|
||||
passwordService := password.NewPasswordService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := passwordService.Generate(&password.GenerateRequest{
|
||||
Length: 16,
|
||||
Lowercase: true,
|
||||
Numbers: true,
|
||||
Special: false,
|
||||
Uppercase: true,
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
@@ -4,6 +4,35 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/place/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Search
|
||||
|
||||
Search for places by text query
|
||||
|
||||
|
||||
[https://m3o.com/place/api#Search](https://m3o.com/place/api#Search)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/place"
|
||||
)
|
||||
|
||||
// Search for places by text query
|
||||
func SearchForPlaces() {
|
||||
placeService := place.NewPlaceService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := placeService.Search(&place.SearchRequest{
|
||||
Location: "51.5074577,-0.1297515",
|
||||
Query: "food",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Nearby
|
||||
|
||||
Find places nearby using a location
|
||||
@@ -34,32 +63,3 @@ Type: "store",
|
||||
|
||||
}
|
||||
```
|
||||
## Search
|
||||
|
||||
Search for places by text query
|
||||
|
||||
|
||||
[https://m3o.com/place/api#Search](https://m3o.com/place/api#Search)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/place"
|
||||
)
|
||||
|
||||
// Search for places by text query
|
||||
func SearchForPlaces() {
|
||||
placeService := place.NewPlaceService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := placeService.Search(&place.SearchRequest{
|
||||
Location: "51.5074577,-0.1297515",
|
||||
Query: "food",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/search/api](ht
|
||||
|
||||
Endpoints:
|
||||
|
||||
## DeleteIndex
|
||||
|
||||
Delete an index by name
|
||||
|
||||
|
||||
[https://m3o.com/search/api#DeleteIndex](https://m3o.com/search/api#DeleteIndex)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/search"
|
||||
)
|
||||
|
||||
// Delete an index by name
|
||||
func DeleteAnIndex() {
|
||||
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := searchService.DeleteIndex(&search.DeleteIndexRequest{
|
||||
Index: "customers",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Index
|
||||
|
||||
Index a record i.e. insert a document to search for.
|
||||
@@ -26,9 +54,9 @@ func IndexArecord() {
|
||||
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := searchService.Index(&search.IndexRequest{
|
||||
Data: map[string]interface{}{
|
||||
"age": 37,
|
||||
"starsign": "Leo",
|
||||
"name": "John Doe",
|
||||
"age": 37,
|
||||
},
|
||||
Index: "customers",
|
||||
|
||||
@@ -181,31 +209,3 @@ func CreateAnIndex() {
|
||||
|
||||
}
|
||||
```
|
||||
## DeleteIndex
|
||||
|
||||
Delete an index by name
|
||||
|
||||
|
||||
[https://m3o.com/search/api#DeleteIndex](https://m3o.com/search/api#DeleteIndex)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/search"
|
||||
)
|
||||
|
||||
// Delete an index by name
|
||||
func DeleteAnIndex() {
|
||||
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := searchService.DeleteIndex(&search.DeleteIndexRequest{
|
||||
Index: "customers",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,62 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/space/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## List
|
||||
|
||||
List the objects in space
|
||||
|
||||
|
||||
[https://m3o.com/space/api#List](https://m3o.com/space/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/space"
|
||||
)
|
||||
|
||||
// List the objects in space
|
||||
func ListObjectsWithPrefix() {
|
||||
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := spaceService.List(&space.ListRequest{
|
||||
Prefix: "images/",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Head
|
||||
|
||||
Retrieve meta information about an object
|
||||
|
||||
|
||||
[https://m3o.com/space/api#Head](https://m3o.com/space/api#Head)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/space"
|
||||
)
|
||||
|
||||
// Retrieve meta information about an object
|
||||
func HeadAnObject() {
|
||||
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := spaceService.Head(&space.HeadRequest{
|
||||
Name: "images/file.jpg",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Read
|
||||
|
||||
Read an object in space
|
||||
@@ -232,3 +176,59 @@ func DeleteAnObject() {
|
||||
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
List the objects in space
|
||||
|
||||
|
||||
[https://m3o.com/space/api#List](https://m3o.com/space/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/space"
|
||||
)
|
||||
|
||||
// List the objects in space
|
||||
func ListObjectsWithPrefix() {
|
||||
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := spaceService.List(&space.ListRequest{
|
||||
Prefix: "images/",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Head
|
||||
|
||||
Retrieve meta information about an object
|
||||
|
||||
|
||||
[https://m3o.com/space/api#Head](https://m3o.com/space/api#Head)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/space"
|
||||
)
|
||||
|
||||
// Retrieve meta information about an object
|
||||
func HeadAnObject() {
|
||||
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := spaceService.Head(&space.HeadRequest{
|
||||
Name: "images/file.jpg",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,62 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/stock/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Price
|
||||
|
||||
Get the last price for a given stock ticker
|
||||
|
||||
|
||||
[https://m3o.com/stock/api#Price](https://m3o.com/stock/api#Price)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/stock"
|
||||
)
|
||||
|
||||
// Get the last price for a given stock ticker
|
||||
func GetAstockPrice() {
|
||||
stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := stockService.Price(&stock.PriceRequest{
|
||||
Symbol: "AAPL",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Quote
|
||||
|
||||
Get the last quote for the stock
|
||||
|
||||
|
||||
[https://m3o.com/stock/api#Quote](https://m3o.com/stock/api#Quote)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/stock"
|
||||
)
|
||||
|
||||
// Get the last quote for the stock
|
||||
func GetAstockQuote() {
|
||||
stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := stockService.Quote(&stock.QuoteRequest{
|
||||
Symbol: "AAPL",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## History
|
||||
|
||||
Get the historic open-close for a given day
|
||||
@@ -65,59 +121,3 @@ Stock: "AAPL",
|
||||
|
||||
}
|
||||
```
|
||||
## Price
|
||||
|
||||
Get the last price for a given stock ticker
|
||||
|
||||
|
||||
[https://m3o.com/stock/api#Price](https://m3o.com/stock/api#Price)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/stock"
|
||||
)
|
||||
|
||||
// Get the last price for a given stock ticker
|
||||
func GetAstockPrice() {
|
||||
stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := stockService.Price(&stock.PriceRequest{
|
||||
Symbol: "AAPL",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Quote
|
||||
|
||||
Get the last quote for the stock
|
||||
|
||||
|
||||
[https://m3o.com/stock/api#Quote](https://m3o.com/stock/api#Quote)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/stock"
|
||||
)
|
||||
|
||||
// Get the last quote for the stock
|
||||
func GetAstockQuote() {
|
||||
stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := stockService.Quote(&stock.QuoteRequest{
|
||||
Symbol: "AAPL",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,35 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/sunnah/api](ht
|
||||
|
||||
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
|
||||
@@ -123,3 +94,32 @@ 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)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,61 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/twitter/api](h
|
||||
|
||||
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
|
||||
|
||||
Get the timeline for a given user
|
||||
@@ -116,3 +61,58 @@ 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)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,128 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/user/api](http
|
||||
|
||||
Endpoints:
|
||||
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
## VerifyEmail
|
||||
|
||||
Verify the email address of an account from a token sent in an email to the user.
|
||||
|
||||
|
||||
[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Verify the email address of an account from a token sent in an email to the user.
|
||||
func VerifyEmail() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.VerifyEmail(&user.VerifyEmailRequest{
|
||||
Token: "012345",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
## SendMagicLink
|
||||
|
||||
Login using email only - Passwordless
|
||||
|
||||
|
||||
[https://m3o.com/user/api#SendMagicLink](https://m3o.com/user/api#SendMagicLink)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Login using email only - Passwordless
|
||||
func SendAmagicLink() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.SendMagicLink(&user.SendMagicLinkRequest{
|
||||
Address: "www.example.com",
|
||||
Email: "joe@example.com",
|
||||
Endpoint: "verifytoken",
|
||||
FromName: "Awesome Dot Com",
|
||||
Subject: "MagicLink to access your account",
|
||||
TextContent: `Hi there,
|
||||
|
||||
Click here to access your account $micro_verification_link`,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Update
|
||||
|
||||
Update the account username or email
|
||||
@@ -32,6 +154,240 @@ Username: "joe",
|
||||
})
|
||||
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)
|
||||
|
||||
}
|
||||
```
|
||||
## UpdatePassword
|
||||
|
||||
Update the account password
|
||||
|
||||
|
||||
[https://m3o.com/user/api#UpdatePassword](https://m3o.com/user/api#UpdatePassword)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Update the account password
|
||||
func UpdateTheAccountPassword() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.UpdatePassword(&user.UpdatePasswordRequest{
|
||||
ConfirmPassword: "Password2",
|
||||
NewPassword: "Password2",
|
||||
OldPassword: "Password1",
|
||||
UserId: "user-1",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## SendVerificationEmail
|
||||
|
||||
Send a verification email to a user.
|
||||
Email "from" will be 'noreply@email.m3ocontent.com'.
|
||||
The verification link will be injected in the email
|
||||
as a template variable, $micro_verification_link e.g
|
||||
'Welcome to M3O! Use the link below to verify your email: $micro_verification_link'
|
||||
The variable will be replaced with a url similar to:
|
||||
'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url'
|
||||
|
||||
|
||||
[https://m3o.com/user/api#SendVerificationEmail](https://m3o.com/user/api#SendVerificationEmail)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Send a verification email to a user.
|
||||
// Email "from" will be 'noreply@email.m3ocontent.com'.
|
||||
// The verification link will be injected in the email
|
||||
// as a template variable, $micro_verification_link e.g
|
||||
// 'Welcome to M3O! Use the link below to verify your email: $micro_verification_link'
|
||||
// The variable will be replaced with a url similar to:
|
||||
// 'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url'
|
||||
func SendVerificationEmail() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.SendVerificationEmail(&user.SendVerificationEmailRequest{
|
||||
Email: "joe@example.com",
|
||||
FailureRedirectUrl: "https://m3o.com/verification-failed",
|
||||
FromName: "Awesome Dot Com",
|
||||
RedirectUrl: "https://m3o.com",
|
||||
Subject: "Email verification",
|
||||
TextContent: `Hi there,
|
||||
|
||||
Please verify your email by clicking this link: $micro_verification_link`,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
## ReadSession
|
||||
|
||||
Read a session by the session id. In the event it has expired or is not found and error is returned.
|
||||
|
||||
|
||||
[https://m3o.com/user/api#ReadSession](https://m3o.com/user/api#ReadSession)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Read a session by the session id. In the event it has expired or is not found and error is returned.
|
||||
func ReadAsessionByTheSessionId() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.ReadSession(&user.ReadSessionRequest{
|
||||
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## VerifyToken
|
||||
|
||||
Check whether the token attached to MagicLink is valid or not.
|
||||
Ideally, you need to call this endpoint from your http request
|
||||
handler that handles the endpoint which is specified in the
|
||||
SendMagicLink request.
|
||||
|
||||
|
||||
[https://m3o.com/user/api#VerifyToken](https://m3o.com/user/api#VerifyToken)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Check whether the token attached to MagicLink is valid or not.
|
||||
// Ideally, you need to call this endpoint from your http request
|
||||
// handler that handles the endpoint which is specified in the
|
||||
// SendMagicLink request.
|
||||
func VerifyAtoken() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.VerifyToken(&user.VerifyTokenRequest{
|
||||
Token: "EdsUiidouJJJLldjlloofUiorkojflsWWdld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Create
|
||||
|
||||
Create a new user account. The email address and username for the account must be unique.
|
||||
|
||||
|
||||
[https://m3o.com/user/api#Create](https://m3o.com/user/api#Create)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Create a new user account. The email address and username for the account must be unique.
|
||||
func CreateAnAccount() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.Create(&user.CreateRequest{
|
||||
Email: "joe@example.com",
|
||||
Id: "user-1",
|
||||
Password: "Password1",
|
||||
Username: "joe",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Read
|
||||
@@ -118,12 +474,13 @@ func ReadAccountByEmail() {
|
||||
|
||||
}
|
||||
```
|
||||
## ResetPassword
|
||||
## Login
|
||||
|
||||
Reset password with the code sent by the "SendPasswordResetEmail" endpoint.
|
||||
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#ResetPassword](https://m3o.com/user/api#ResetPassword)
|
||||
[https://m3o.com/user/api#Login](https://m3o.com/user/api#Login)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -135,133 +492,13 @@ import(
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Reset password with the code sent by the "SendPasswordResetEmail" endpoint.
|
||||
func ResetPassword() {
|
||||
// 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.ResetPassword(&user.ResetPasswordRequest{
|
||||
Code: "012345",
|
||||
ConfirmPassword: "NewPassword1",
|
||||
Email: "joe@example.com",
|
||||
NewPassword: "NewPassword1",
|
||||
|
||||
})
|
||||
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)
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
## VerifyEmail
|
||||
|
||||
Verify the email address of an account from a token sent in an email to the user.
|
||||
|
||||
|
||||
[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Verify the email address of an account from a token sent in an email to the user.
|
||||
func VerifyEmail() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.VerifyEmail(&user.VerifyEmailRequest{
|
||||
Token: "012345",
|
||||
rsp, err := userService.Login(&user.LoginRequest{
|
||||
Email: "joe@example.com",
|
||||
Password: "Password1",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
@@ -296,240 +533,3 @@ func LogAuserOut() {
|
||||
|
||||
}
|
||||
```
|
||||
## UpdatePassword
|
||||
|
||||
Update the account password
|
||||
|
||||
|
||||
[https://m3o.com/user/api#UpdatePassword](https://m3o.com/user/api#UpdatePassword)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Update the account password
|
||||
func UpdateTheAccountPassword() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.UpdatePassword(&user.UpdatePasswordRequest{
|
||||
ConfirmPassword: "Password2",
|
||||
NewPassword: "Password2",
|
||||
OldPassword: "Password1",
|
||||
UserId: "user-1",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## SendVerificationEmail
|
||||
|
||||
Send a verification email to a user.
|
||||
Email "from" will be 'noreply@email.m3ocontent.com'.
|
||||
The verification link will be injected in the email
|
||||
as a template variable, $micro_verification_link e.g
|
||||
'Welcome to M3O! Use the link below to verify your email: $micro_verification_link'
|
||||
The variable will be replaced with a url similar to:
|
||||
'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url'
|
||||
|
||||
|
||||
[https://m3o.com/user/api#SendVerificationEmail](https://m3o.com/user/api#SendVerificationEmail)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Send a verification email to a user.
|
||||
// Email "from" will be 'noreply@email.m3ocontent.com'.
|
||||
// The verification link will be injected in the email
|
||||
// as a template variable, $micro_verification_link e.g
|
||||
// 'Welcome to M3O! Use the link below to verify your email: $micro_verification_link'
|
||||
// The variable will be replaced with a url similar to:
|
||||
// 'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url'
|
||||
func SendVerificationEmail() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.SendVerificationEmail(&user.SendVerificationEmailRequest{
|
||||
Email: "joe@example.com",
|
||||
FailureRedirectUrl: "https://m3o.com/verification-failed",
|
||||
FromName: "Awesome Dot Com",
|
||||
RedirectUrl: "https://m3o.com",
|
||||
Subject: "Email verification",
|
||||
TextContent: `Hi there,
|
||||
|
||||
Please verify your email by clicking this link: $micro_verification_link`,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## 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 all users. Returns a paged list of results
|
||||
|
||||
|
||||
[https://m3o.com/user/api#List](https://m3o.com/user/api#List)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// List all users. Returns a paged list of results
|
||||
func ListAllUsers() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.List(&user.ListRequest{
|
||||
Limit: 100,
|
||||
Offset: 0,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## VerifyToken
|
||||
|
||||
Check whether the token attached to MagicLink is valid or not.
|
||||
Ideally, you need to call this endpoint from your http request
|
||||
handler that handles the endpoint which is specified in the
|
||||
SendMagicLink request.
|
||||
|
||||
|
||||
[https://m3o.com/user/api#VerifyToken](https://m3o.com/user/api#VerifyToken)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Check whether the token attached to MagicLink is valid or not.
|
||||
// Ideally, you need to call this endpoint from your http request
|
||||
// handler that handles the endpoint which is specified in the
|
||||
// SendMagicLink request.
|
||||
func VerifyAtoken() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.VerifyToken(&user.VerifyTokenRequest{
|
||||
Token: "EdsUiidouJJJLldjlloofUiorkojflsWWdld",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## Create
|
||||
|
||||
Create a new user account. The email address and username for the account must be unique.
|
||||
|
||||
|
||||
[https://m3o.com/user/api#Create](https://m3o.com/user/api#Create)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Create a new user account. The email address and username for the account must be unique.
|
||||
func CreateAnAccount() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.Create(&user.CreateRequest{
|
||||
Email: "joe@example.com",
|
||||
Id: "user-1",
|
||||
Password: "Password1",
|
||||
Username: "joe",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
@@ -20,7 +20,7 @@ type PasswordService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Generate a strong random password
|
||||
// Generate a strong random password. Use the switches to control which character types are included, defaults to using all of them
|
||||
func (t *PasswordService) Generate(request *GenerateRequest) (*GenerateResponse, error) {
|
||||
|
||||
rsp := &GenerateResponse{}
|
||||
@@ -29,8 +29,16 @@ func (t *PasswordService) Generate(request *GenerateRequest) (*GenerateResponse,
|
||||
}
|
||||
|
||||
type GenerateRequest struct {
|
||||
// password length; defaults to 16 chars
|
||||
// password length; defaults to 8 chars
|
||||
Length int32 `json:"length"`
|
||||
// include lowercase letters
|
||||
Lowercase bool `json:"lowercase"`
|
||||
// include numbers
|
||||
Numbers bool `json:"numbers"`
|
||||
// include special characters (!@#$%&*)
|
||||
Special bool `json:"special"`
|
||||
// include uppercase letters
|
||||
Uppercase bool `json:"uppercase"`
|
||||
}
|
||||
|
||||
type GenerateResponse struct {
|
||||
|
||||
Reference in New Issue
Block a user