Commit from m3o/m3o action

This commit is contained in:
m3o-actions
2022-03-02 10:19:39 +00:00
parent fd8353bc9c
commit ddef868d22
27 changed files with 1129 additions and 1129 deletions

View File

@@ -119,12 +119,12 @@ func ReadAccountByEmail() {
}
```
## VerifyEmail
## Logout
Verify the email address of an account from a token sent in an email to the user.
Logout a user account
[https://m3o.com/user/api#VerifyEmail](https://m3o.com/user/api#VerifyEmail)
[https://m3o.com/user/api#Logout](https://m3o.com/user/api#Logout)
```go
package example
@@ -136,23 +136,23 @@ import(
"go.m3o.com/user"
)
// Verify the email address of an account from a token sent in an email to the user.
func VerifyEmail() {
// Logout a user account
func LogAuserOut() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.VerifyEmail(&user.VerifyEmailRequest{
Token: "012345",
rsp, err := userService.Logout(&user.LogoutRequest{
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
})
fmt.Println(rsp, err)
}
```
## Delete
## List
Delete an account by id
List all users. Returns a paged list of results
[https://m3o.com/user/api#Delete](https://m3o.com/user/api#Delete)
[https://m3o.com/user/api#List](https://m3o.com/user/api#List)
```go
package example
@@ -164,29 +164,24 @@ import(
"go.m3o.com/user"
)
// Delete an account by id
func DeleteUserAccount() {
// List all users. Returns a paged list of results
func ListAllUsers() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.Delete(&user.DeleteRequest{
Id: "8b98acbe-0b6a-4d66-a414-5ffbf666786f",
rsp, err := userService.List(&user.ListRequest{
Limit: 100,
Offset: 0,
})
fmt.Println(rsp, err)
}
```
## SendVerificationEmail
## Create
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'
Create a new user account. The email address and username for the account must be unique.
[https://m3o.com/user/api#SendVerificationEmail](https://m3o.com/user/api#SendVerificationEmail)
[https://m3o.com/user/api#Create](https://m3o.com/user/api#Create)
```go
package example
@@ -198,24 +193,44 @@ import(
"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() {
// 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.SendVerificationEmail(&user.SendVerificationEmailRequest{
rsp, err := userService.Create(&user.CreateRequest{
Email: "joe@example.com",
FailureRedirectUrl: "https://m3o.com/verification-failed",
FromName: "Awesome Dot Com",
RedirectUrl: "https://m3o.com",
Subject: "Email verification",
TextContent: `Hi there,
Id: "user-1",
Password: "Password1",
Username: "joe",
Please verify your email by clicking this link: $micro_verification_link`,
})
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)
@@ -256,12 +271,12 @@ TextContent: `Hi there,
}
```
## Logout
## ResetPassword
Logout a user account
Reset password with the code sent by the "SendPasswordResetEmail" endpoint.
[https://m3o.com/user/api#Logout](https://m3o.com/user/api#Logout)
[https://m3o.com/user/api#ResetPassword](https://m3o.com/user/api#ResetPassword)
```go
package example
@@ -273,11 +288,42 @@ import(
"go.m3o.com/user"
)
// Logout a user account
func LogAuserOut() {
// Reset password with the code sent by the "SendPasswordResetEmail" endpoint.
func ResetPassword() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.Logout(&user.LogoutRequest{
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
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)
@@ -353,12 +399,18 @@ func VerifyAtoken() {
}
```
## Create
## SendVerificationEmail
Create a new user account. The email address and username for the account must be unique.
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#Create](https://m3o.com/user/api#Create)
[https://m3o.com/user/api#SendVerificationEmail](https://m3o.com/user/api#SendVerificationEmail)
```go
package example
@@ -370,26 +422,36 @@ import(
"go.m3o.com/user"
)
// Create a new user account. The email address and username for the account must be unique.
func CreateAnAccount() {
// 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.Create(&user.CreateRequest{
rsp, err := userService.SendVerificationEmail(&user.SendVerificationEmailRequest{
Email: "joe@example.com",
Id: "user-1",
Password: "Password1",
Username: "joe",
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)
}
```
## Update
## Delete
Update the account username or email
Delete an account by id
[https://m3o.com/user/api#Update](https://m3o.com/user/api#Update)
[https://m3o.com/user/api#Delete](https://m3o.com/user/api#Delete)
```go
package example
@@ -401,72 +463,11 @@ import(
"go.m3o.com/user"
)
// Update the account username or email
func UpdateAnAccount() {
// Delete an account by id
func DeleteUserAccount() {
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)
}
```
## 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)
}
```
## 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",
rsp, err := userService.Delete(&user.DeleteRequest{
Id: "8b98acbe-0b6a-4d66-a414-5ffbf666786f",
})
fmt.Println(rsp, err)
@@ -504,12 +505,12 @@ Password: "Password1",
}
```
## List
## ReadSession
List all users. Returns a paged list of results
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#List](https://m3o.com/user/api#List)
[https://m3o.com/user/api#ReadSession](https://m3o.com/user/api#ReadSession)
```go
package example
@@ -521,12 +522,11 @@ import(
"go.m3o.com/user"
)
// List all users. Returns a paged list of results
func ListAllUsers() {
// 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.List(&user.ListRequest{
Limit: 100,
Offset: 0,
rsp, err := userService.ReadSession(&user.ReadSessionRequest{
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
})
fmt.Println(rsp, err)