Commit from m3o/m3o action

This commit is contained in:
m3o-actions
2022-02-20 21:44:00 +00:00
parent 29cb72c55b
commit a6dc177797
28 changed files with 1634 additions and 1443 deletions

View File

@@ -4,6 +4,62 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/app/api](https
Endpoints: Endpoints:
## 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
Delete an app Delete an app
@@ -174,59 +230,3 @@ func GetTheStatusOfAnApp() {
} }
``` ```
## 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)
}
```

View File

@@ -4,91 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/cache/api](htt
Endpoints: Endpoints:
## Set
Set an item in the cache. Overwrites any existing value already set.
[https://m3o.com/cache/api#Set](https://m3o.com/cache/api#Set)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/cache"
)
// Set an item in the cache. Overwrites any existing value already set.
func SetAvalue() {
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cacheService.Set(&cache.SetRequest{
Key: "foo",
Value: "bar",
})
fmt.Println(rsp, err)
}
```
## Get
Get an item from the cache by key. If key is not found, an empty response is returned.
[https://m3o.com/cache/api#Get](https://m3o.com/cache/api#Get)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/cache"
)
// Get an item from the cache by key. If key is not found, an empty response is returned.
func GetAvalue() {
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cacheService.Get(&cache.GetRequest{
Key: "foo",
})
fmt.Println(rsp, err)
}
```
## Delete
Delete a value from the cache. If key not found a success response is returned.
[https://m3o.com/cache/api#Delete](https://m3o.com/cache/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/cache"
)
// Delete a value from the cache. If key not found a success response is returned.
func DeleteAvalue() {
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cacheService.Delete(&cache.DeleteRequest{
Key: "foo",
})
fmt.Println(rsp, err)
}
```
## Increment ## Increment
Increment a value (if it's a number). If key not found it is equivalent to set. Increment a value (if it's a number). If key not found it is equivalent to set.
@@ -174,3 +89,88 @@ func ListTheKeys() {
} }
``` ```
## Set
Set an item in the cache. Overwrites any existing value already set.
[https://m3o.com/cache/api#Set](https://m3o.com/cache/api#Set)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/cache"
)
// Set an item in the cache. Overwrites any existing value already set.
func SetAvalue() {
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cacheService.Set(&cache.SetRequest{
Key: "foo",
Value: "bar",
})
fmt.Println(rsp, err)
}
```
## Get
Get an item from the cache by key. If key is not found, an empty response is returned.
[https://m3o.com/cache/api#Get](https://m3o.com/cache/api#Get)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/cache"
)
// Get an item from the cache by key. If key is not found, an empty response is returned.
func GetAvalue() {
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cacheService.Get(&cache.GetRequest{
Key: "foo",
})
fmt.Println(rsp, err)
}
```
## Delete
Delete a value from the cache. If key not found a success response is returned.
[https://m3o.com/cache/api#Delete](https://m3o.com/cache/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/cache"
)
// Delete a value from the cache. If key not found a success response is returned.
func DeleteAvalue() {
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cacheService.Delete(&cache.DeleteRequest{
Key: "foo",
})
fmt.Println(rsp, err)
}
```

View File

@@ -34,33 +34,6 @@ Text: "Hey whats up?",
}) })
fmt.Println(rsp, err) 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)
} }
``` ```
## Kick ## Kick
@@ -225,6 +198,33 @@ func InviteAuser() {
}) })
fmt.Println(rsp, err) 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)
} }
``` ```
## Join ## Join

View File

@@ -4,47 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/comments/api](
Endpoints: Endpoints:
## Events
Subscribe to comments events
[https://m3o.com/comments/api#Events](https://m3o.com/comments/api#Events)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/comments"
)
// Subscribe to comments events
func SubscribeToEvents() {
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
stream, err := commentsService.Events(&comments.EventsRequest{
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
})
if err != nil {
fmt.Println(err)
return
}
for {
rsp, err := stream.Recv()
if err != nil {
fmt.Println(err)
return
}
fmt.Println(rsp)
}
}
```
## Create ## Create
Create a new comment Create a new comment
@@ -188,3 +147,44 @@ func DeleteAcomment() {
} }
``` ```
## Events
Subscribe to comments events
[https://m3o.com/comments/api#Events](https://m3o.com/comments/api#Events)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/comments"
)
// Subscribe to comments events
func SubscribeToEvents() {
commentsService := comments.NewCommentsService(os.Getenv("M3O_API_TOKEN"))
stream, err := commentsService.Events(&comments.EventsRequest{
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
})
if err != nil {
fmt.Println(err)
return
}
for {
rsp, err := stream.Recv()
if err != nil {
fmt.Println(err)
return
}
fmt.Println(rsp)
}
}
```

View File

@@ -4,62 +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
[https://m3o.com/contact/api#Delete](https://m3o.com/contact/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/contact"
)
//
func DeleteAcontact() {
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
rsp, err := contactService.Delete(&contact.DeleteRequest{
Id: "42e48a3c-6221-11ec-96d2-acde48001122",
})
fmt.Println(rsp, err)
}
```
## List ## List
@@ -217,3 +161,59 @@ contact.Phone{
} }
``` ```
## Read
[https://m3o.com/contact/api#Read](https://m3o.com/contact/api#Read)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/contact"
)
//
func GetAcontact() {
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
rsp, err := contactService.Read(&contact.ReadRequest{
Id: "42e48a3c-6221-11ec-96d2-acde48001122",
})
fmt.Println(rsp, err)
}
```
## Delete
[https://m3o.com/contact/api#Delete](https://m3o.com/contact/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/contact"
)
//
func DeleteAcontact() {
contactService := contact.NewContactService(os.Getenv("M3O_API_TOKEN"))
rsp, err := contactService.Delete(&contact.DeleteRequest{
Id: "42e48a3c-6221-11ec-96d2-acde48001122",
})
fmt.Println(rsp, err)
}
```

View File

@@ -36,12 +36,12 @@ Table: "example",
} }
``` ```
## Truncate ## Read
Truncate the records in a table Read data from a table. Lookup can be by ID or via querying any field in the record.
[https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate) [https://m3o.com/db/api#Read](https://m3o.com/db/api#Read)
```go ```go
package example package example
@@ -53,11 +53,39 @@ import(
"go.m3o.com/db" "go.m3o.com/db"
) )
// Truncate the records in a table // Read data from a table. Lookup can be by ID or via querying any field in the record.
func TruncateTable() { func ReadRecords() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Truncate(&db.TruncateRequest{ rsp, err := dbService.Read(&db.ReadRequest{
Table: "example", Query: "age == 43",
Table: "example",
})
fmt.Println(rsp, err)
}
```
## ListTables
List tables in the DB
[https://m3o.com/db/api#ListTables](https://m3o.com/db/api#ListTables)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// List tables in the DB
func ListTables() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.ListTables(&db.ListTablesRequest{
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
@@ -127,12 +155,12 @@ Table: "example",
} }
``` ```
## Delete ## Truncate
Delete a record in the database by id. Truncate the records in a table
[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete) [https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate)
```go ```go
package example package example
@@ -144,12 +172,11 @@ import(
"go.m3o.com/db" "go.m3o.com/db"
) )
// Delete a record in the database by id. // Truncate the records in a table
func DeleteArecord() { func TruncateTable() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Delete(&db.DeleteRequest{ rsp, err := dbService.Truncate(&db.TruncateRequest{
Id: "1", Table: "example",
Table: "example",
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
@@ -212,12 +239,12 @@ func CountEntriesInAtable() {
} }
``` ```
## ListTables ## Delete
List tables in the DB Delete a record in the database by id.
[https://m3o.com/db/api#ListTables](https://m3o.com/db/api#ListTables) [https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete)
```go ```go
package example package example
@@ -229,38 +256,11 @@ import(
"go.m3o.com/db" "go.m3o.com/db"
) )
// List tables in the DB // Delete a record in the database by id.
func ListTables() { func DeleteArecord() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.ListTables(&db.ListTablesRequest{ rsp, err := dbService.Delete(&db.DeleteRequest{
Id: "1",
})
fmt.Println(rsp, err)
}
```
## Read
Read data from a table. Lookup can be by ID or via querying any field in the record.
[https://m3o.com/db/api#Read](https://m3o.com/db/api#Read)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Read data from a table. Lookup can be by ID or via querying any field in the record.
func ReadRecords() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Read(&db.ReadRequest{
Query: "age == 43",
Table: "example", Table: "example",
}) })

View File

@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/email/api](htt
Endpoints: Endpoints:
## Validate
Validate an email address format
[https://m3o.com/email/api#Validate](https://m3o.com/email/api#Validate)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/email"
)
// Validate an email address format
func ValidateEmail() {
emailService := email.NewEmailService(os.Getenv("M3O_API_TOKEN"))
rsp, err := emailService.Validate(&email.ValidateRequest{
Address: "joe@example.com",
})
fmt.Println(rsp, err)
}
```
## Send ## Send
Send an email by passing in from, to, subject, and a text or html body Send an email by passing in from, to, subject, and a text or html body
@@ -92,3 +64,31 @@ func ParseEmail() {
} }
``` ```
## Validate
Validate an email address format
[https://m3o.com/email/api#Validate](https://m3o.com/email/api#Validate)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/email"
)
// Validate an email address format
func ValidateEmail() {
emailService := email.NewEmailService(os.Getenv("M3O_API_TOKEN"))
rsp, err := emailService.Validate(&email.ValidateRequest{
Address: "joe@example.com",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,36 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/emoji/api](htt
Endpoints: 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
Find an emoji by its alias e.g :beer: Find an emoji by its alias e.g :beer:
@@ -89,3 +59,33 @@ 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)
}
```

View File

@@ -26,9 +26,9 @@ func PublishAnEvent() {
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN")) eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
rsp, err := eventService.Publish(&event.PublishRequest{ rsp, err := eventService.Publish(&event.PublishRequest{
Message: map[string]interface{}{ Message: map[string]interface{}{
"user": "john",
"id": "1", "id": "1",
"type": "signup", "type": "signup",
"user": "john",
}, },
Topic: "user", Topic: "user",

View File

@@ -4,6 +4,63 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/file/api](http
Endpoints: Endpoints:
## List
List files by their project and optionally a path.
[https://m3o.com/file/api#List](https://m3o.com/file/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/file"
)
// List files by their project and optionally a path.
func ListFiles() {
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
rsp, err := fileService.List(&file.ListRequest{
Project: "examples",
})
fmt.Println(rsp, err)
}
```
## Read
Read a file by path
[https://m3o.com/file/api#Read](https://m3o.com/file/api#Read)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/file"
)
// Read a file by path
func ReadFile() {
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
rsp, err := fileService.Read(&file.ReadRequest{
Path: "/document/text-files/file.txt",
Project: "examples",
})
fmt.Println(rsp, err)
}
```
## Delete ## Delete
Delete a file by project name/path Delete a file by project name/path
@@ -65,60 +122,3 @@ func SaveFile() {
} }
``` ```
## List
List files by their project and optionally a path.
[https://m3o.com/file/api#List](https://m3o.com/file/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/file"
)
// List files by their project and optionally a path.
func ListFiles() {
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
rsp, err := fileService.List(&file.ListRequest{
Project: "examples",
})
fmt.Println(rsp, err)
}
```
## Read
Read a file by path
[https://m3o.com/file/api#Read](https://m3o.com/file/api#Read)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/file"
)
// Read a file by path
func ReadFile() {
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
rsp, err := fileService.Read(&file.ReadRequest{
Path: "/document/text-files/file.txt",
Project: "examples",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,68 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/function/api](
Endpoints: Endpoints:
## 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)
}
```
## Deploy
Deploy a group of functions
[https://m3o.com/function/api#Deploy](https://m3o.com/function/api#Deploy)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Deploy a group of functions
func DeployAfunction() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Deploy(&function.DeployRequest{
Branch: "main",
Entrypoint: "Helloworld",
Name: "helloworld",
Region: "europe-west1",
Repo: "https://github.com/m3o/m3o",
Runtime: "go116",
Subfolder: "examples/go-function",
})
fmt.Println(rsp, err)
}
```
## Call ## Call
Call a function by name Call a function by name
@@ -88,6 +150,34 @@ func DeleteAfunction() {
}) })
fmt.Println(rsp, err) 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
@@ -116,40 +206,6 @@ func ReserveAfunction() {
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
}
```
## Deploy
Deploy a group of functions
[https://m3o.com/function/api#Deploy](https://m3o.com/function/api#Deploy)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/function"
)
// Deploy a group of functions
func DeployAfunction() {
functionService := function.NewFunctionService(os.Getenv("M3O_API_TOKEN"))
rsp, err := functionService.Deploy(&function.DeployRequest{
Branch: "main",
Entrypoint: "Helloworld",
Name: "helloworld",
Region: "europe-west1",
Repo: "https://github.com/m3o/m3o",
Runtime: "go116",
Subfolder: "examples/go-function",
})
fmt.Println(rsp, err)
} }
``` ```
## Update ## Update
@@ -178,34 +234,6 @@ func UpdateAfunction() {
}) })
fmt.Println(rsp, err) 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 ## Regions
@@ -235,31 +263,3 @@ func ListRegions() {
} }
``` ```
## 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)
}
```

View File

@@ -4,104 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/image/api](htt
Endpoints: Endpoints:
## Upload
Upload an image by either sending a base64 encoded image to this endpoint or a URL.
To resize an image before uploading, see the Resize endpoint.
To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
with each parameter as a form field.
[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/image"
)
// Upload an image by either sending a base64 encoded image to this endpoint or a URL.
// To resize an image before uploading, see the Resize endpoint.
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
// with each parameter as a form field.
func UploadAbase64imageToMicrosCdn() {
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
rsp, err := imageService.Upload(&image.UploadRequest{
Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAx0lEQVR4nOzaMaoDMQyE4ZHj+x82vVdhwQoTkzKQEcwP5r0ihT7sbjUTeAJ4HCegXQJYfOYefOyjDuBiz3yjwJBoCIl6QZOeUjTC1Ix1IxEJXF9+0KWsf2bD4bn37OO/c/wuQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9Sa/NG94Tf3j4WBdaxudMEkn4IM2rZBA0wBrvo7aOcpj2emXvLeVt0IGm0GVXUj91mvAAAA//+V2CZl+4AKXwAAAABJRU5ErkJggg==",
Name: "cat.jpeg",
})
fmt.Println(rsp, err)
}
```
## Upload
Upload an image by either sending a base64 encoded image to this endpoint or a URL.
To resize an image before uploading, see the Resize endpoint.
To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
with each parameter as a form field.
[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/image"
)
// Upload an image by either sending a base64 encoded image to this endpoint or a URL.
// To resize an image before uploading, see the Resize endpoint.
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
// with each parameter as a form field.
func UploadAnImageFromAurlToMicrosCdn() {
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
rsp, err := imageService.Upload(&image.UploadRequest{
Name: "cat.jpeg",
Url: "somewebsite.com/cat.png",
})
fmt.Println(rsp, err)
}
```
## Delete
Delete an image previously uploaded.
[https://m3o.com/image/api#Delete](https://m3o.com/image/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/image"
)
// Delete an image previously uploaded.
func DeleteAnUploadedImage() {
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
rsp, err := imageService.Delete(&image.DeleteRequest{
Url: "https://cdn.m3ocontent.com/micro/images/micro/41e23b39-48dd-42b6-9738-79a313414bb8/cat.png",
})
fmt.Println(rsp, err)
}
```
## Resize ## Resize
Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters. Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
@@ -256,3 +158,101 @@ Url: "somewebsite.com/cat.png",
} }
``` ```
## Upload
Upload an image by either sending a base64 encoded image to this endpoint or a URL.
To resize an image before uploading, see the Resize endpoint.
To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
with each parameter as a form field.
[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/image"
)
// Upload an image by either sending a base64 encoded image to this endpoint or a URL.
// To resize an image before uploading, see the Resize endpoint.
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
// with each parameter as a form field.
func UploadAbase64imageToMicrosCdn() {
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
rsp, err := imageService.Upload(&image.UploadRequest{
Base64: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAx0lEQVR4nOzaMaoDMQyE4ZHj+x82vVdhwQoTkzKQEcwP5r0ihT7sbjUTeAJ4HCegXQJYfOYefOyjDuBiz3yjwJBoCIl6QZOeUjTC1Ix1IxEJXF9+0KWsf2bD4bn37OO/c/wuQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9Sa/NG94Tf3j4WBdaxudMEkn4IM2rZBA0wBrvo7aOcpj2emXvLeVt0IGm0GVXUj91mvAAAA//+V2CZl+4AKXwAAAABJRU5ErkJggg==",
Name: "cat.jpeg",
})
fmt.Println(rsp, err)
}
```
## Upload
Upload an image by either sending a base64 encoded image to this endpoint or a URL.
To resize an image before uploading, see the Resize endpoint.
To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
with each parameter as a form field.
[https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/image"
)
// Upload an image by either sending a base64 encoded image to this endpoint or a URL.
// To resize an image before uploading, see the Resize endpoint.
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
// with each parameter as a form field.
func UploadAnImageFromAurlToMicrosCdn() {
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
rsp, err := imageService.Upload(&image.UploadRequest{
Name: "cat.jpeg",
Url: "somewebsite.com/cat.png",
})
fmt.Println(rsp, err)
}
```
## Delete
Delete an image previously uploaded.
[https://m3o.com/image/api#Delete](https://m3o.com/image/api#Delete)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/image"
)
// Delete an image previously uploaded.
func DeleteAnUploadedImage() {
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
rsp, err := imageService.Delete(&image.DeleteRequest{
Url: "https://cdn.m3ocontent.com/micro/images/micro/41e23b39-48dd-42b6-9738-79a313414bb8/cat.png",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,88 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/lists/api](htt
Endpoints: 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
Update a list Update a list
@@ -103,85 +185,3 @@ 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)
}
```

61
examples/meme/README.md Executable file
View File

@@ -0,0 +1,61 @@
# Meme
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/meme/api](https://m3o.com/meme/api).
Endpoints:
## Templates
List the available templates
[https://m3o.com/meme/api#Templates](https://m3o.com/meme/api#Templates)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/meme"
)
// List the available templates
func MemeTemplates() {
memeService := meme.NewMemeService(os.Getenv("M3O_API_TOKEN"))
rsp, err := memeService.Templates(&meme.TemplatesRequest{
})
fmt.Println(rsp, err)
}
```
## Generate
[https://m3o.com/meme/api#Generate](https://m3o.com/meme/api#Generate)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/meme"
)
//
func GenerateAmeme() {
memeService := meme.NewMemeService(os.Getenv("M3O_API_TOKEN"))
rsp, err := memeService.Generate(&meme.GenerateRequest{
Id: "444501",
})
fmt.Println(rsp, err)
}
```

View File

@@ -0,0 +1,17 @@
package main
import (
"fmt"
"os"
"go.m3o.com/meme"
)
//
func main() {
memeService := meme.NewMemeService(os.Getenv("M3O_API_TOKEN"))
rsp, err := memeService.Generate(&meme.GenerateRequest{
Id: "444501",
})
fmt.Println(rsp, err)
}

View File

@@ -0,0 +1,15 @@
package main
import (
"fmt"
"os"
"go.m3o.com/meme"
)
// List the available templates
func main() {
memeService := meme.NewMemeService(os.Getenv("M3O_API_TOKEN"))
rsp, err := memeService.Templates(&meme.TemplatesRequest{})
fmt.Println(rsp, err)
}

View File

@@ -4,6 +4,90 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/notes/api](htt
Endpoints: Endpoints:
## Create
Create a new note
[https://m3o.com/notes/api#Create](https://m3o.com/notes/api#Create)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/notes"
)
// Create a new note
func CreateAnote() {
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
rsp, err := notesService.Create(&notes.CreateRequest{
Text: "This is my note",
Title: "New Note",
})
fmt.Println(rsp, err)
}
```
## Read
Read a note
[https://m3o.com/notes/api#Read](https://m3o.com/notes/api#Read)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/notes"
)
// Read a note
func ReadAnote() {
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
rsp, err := notesService.Read(&notes.ReadRequest{
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
})
fmt.Println(rsp, err)
}
```
## List
List all the notes
[https://m3o.com/notes/api#List](https://m3o.com/notes/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/notes"
)
// List all the notes
func ListAllNotes() {
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
rsp, err := notesService.List(&notes.ListRequest{
})
fmt.Println(rsp, err)
}
```
## Update ## Update
Update a note Update a note
@@ -105,87 +189,3 @@ func SubscribeToEvents() {
} }
} }
``` ```
## Create
Create a new note
[https://m3o.com/notes/api#Create](https://m3o.com/notes/api#Create)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/notes"
)
// Create a new note
func CreateAnote() {
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
rsp, err := notesService.Create(&notes.CreateRequest{
Text: "This is my note",
Title: "New Note",
})
fmt.Println(rsp, err)
}
```
## Read
Read a note
[https://m3o.com/notes/api#Read](https://m3o.com/notes/api#Read)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/notes"
)
// Read a note
func ReadAnote() {
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
rsp, err := notesService.Read(&notes.ReadRequest{
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
})
fmt.Println(rsp, err)
}
```
## List
List all the notes
[https://m3o.com/notes/api#List](https://m3o.com/notes/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/notes"
)
// List all the notes
func ListAllNotes() {
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
rsp, err := notesService.List(&notes.ListRequest{
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/ping/api](http
Endpoints: Endpoints:
## Tcp
Ping a TCP port is open
[https://m3o.com/ping/api#Tcp](https://m3o.com/ping/api#Tcp)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/ping"
)
// Ping a TCP port is open
func DialAtcpAddress() {
pingService := ping.NewPingService(os.Getenv("M3O_API_TOKEN"))
rsp, err := pingService.Tcp(&ping.TcpRequest{
Address: "google.com:80",
})
fmt.Println(rsp, err)
}
```
## Url ## Url
Ping a HTTP URL Ping a HTTP URL
@@ -88,3 +60,31 @@ func PingAnIp() {
} }
``` ```
## Tcp
Ping a TCP port is open
[https://m3o.com/ping/api#Tcp](https://m3o.com/ping/api#Tcp)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/ping"
)
// Ping a TCP port is open
func DialAtcpAddress() {
pingService := ping.NewPingService(os.Getenv("M3O_API_TOKEN"))
rsp, err := pingService.Tcp(&ping.TcpRequest{
Address: "google.com:80",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/postcode/api](
Endpoints: Endpoints:
## Validate
Validate a postcode.
[https://m3o.com/postcode/api#Validate](https://m3o.com/postcode/api#Validate)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/postcode"
)
// Validate a postcode.
func ReturnArandomPostcodeAndItsInformation() {
postcodeService := postcode.NewPostcodeService(os.Getenv("M3O_API_TOKEN"))
rsp, err := postcodeService.Validate(&postcode.ValidateRequest{
Postcode: "SW1A 2AA",
})
fmt.Println(rsp, err)
}
```
## Lookup ## Lookup
Lookup a postcode to retrieve the related region, county, etc Lookup a postcode to retrieve the related region, county, etc
@@ -87,3 +59,31 @@ func ReturnArandomPostcodeAndItsInformation() {
} }
``` ```
## Validate
Validate a postcode.
[https://m3o.com/postcode/api#Validate](https://m3o.com/postcode/api#Validate)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/postcode"
)
// Validate a postcode.
func ReturnArandomPostcodeAndItsInformation() {
postcodeService := postcode.NewPostcodeService(os.Getenv("M3O_API_TOKEN"))
rsp, err := postcodeService.Validate(&postcode.ValidateRequest{
Postcode: "SW1A 2AA",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,62 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/quran/api](htt
Endpoints: Endpoints:
## Chapters
List the Chapters (surahs) of the Quran
[https://m3o.com/quran/api#Chapters](https://m3o.com/quran/api#Chapters)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/quran"
)
// List the Chapters (surahs) of the Quran
func ListChapters() {
quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN"))
rsp, err := quranService.Chapters(&quran.ChaptersRequest{
Language: "en",
})
fmt.Println(rsp, err)
}
```
## Summary
Get a summary for a given chapter (surah)
[https://m3o.com/quran/api#Summary](https://m3o.com/quran/api#Summary)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/quran"
)
// Get a summary for a given chapter (surah)
func GetChapterSummary() {
quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN"))
rsp, err := quranService.Summary(&quran.SummaryRequest{
Chapter: 1,
})
fmt.Println(rsp, err)
}
```
## Verses ## Verses
Lookup the verses (ayahs) for a chapter including Lookup the verses (ayahs) for a chapter including
@@ -64,59 +120,3 @@ func SearchTheQuran() {
} }
``` ```
## Chapters
List the Chapters (surahs) of the Quran
[https://m3o.com/quran/api#Chapters](https://m3o.com/quran/api#Chapters)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/quran"
)
// List the Chapters (surahs) of the Quran
func ListChapters() {
quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN"))
rsp, err := quranService.Chapters(&quran.ChaptersRequest{
Language: "en",
})
fmt.Println(rsp, err)
}
```
## Summary
Get a summary for a given chapter (surah)
[https://m3o.com/quran/api#Summary](https://m3o.com/quran/api#Summary)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/quran"
)
// Get a summary for a given chapter (surah)
func GetChapterSummary() {
quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN"))
rsp, err := quranService.Summary(&quran.SummaryRequest{
Chapter: 1,
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,42 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/search/api](ht
Endpoints: Endpoints:
## Index
Index a document i.e. insert a document to search for.
[https://m3o.com/search/api#Index](https://m3o.com/search/api#Index)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/search"
)
// Index a document i.e. insert a document to search for.
func IndexAdocument() {
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
rsp, err := searchService.Index(&search.IndexRequest{
Document: &search.Document{
Contents: map[string]interface{}{
"name": "John Doe",
"age": 37,
"starsign": "Leo",
},
Id: "1234",
},
Index: "customers",
})
fmt.Println(rsp, err)
}
```
## Search ## Search
Search for documents in a given in index Search for documents in a given in index
@@ -212,3 +176,39 @@ func DeleteAnIndex() {
} }
``` ```
## Index
Index a document i.e. insert a document to search for.
[https://m3o.com/search/api#Index](https://m3o.com/search/api#Index)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/search"
)
// Index a document i.e. insert a document to search for.
func IndexAdocument() {
searchService := search.NewSearchService(os.Getenv("M3O_API_TOKEN"))
rsp, err := searchService.Index(&search.IndexRequest{
Document: &search.Document{
Contents: map[string]interface{}{
"name": "John Doe",
"age": 37,
"starsign": "Leo",
},
Id: "1234",
},
Index: "customers",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,120 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/space/api](htt
Endpoints: Endpoints:
## Read
Read an object in space
[https://m3o.com/space/api#Read](https://m3o.com/space/api#Read)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/space"
)
// Read an object in space
func ReadAnObject() {
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
rsp, err := spaceService.Read(&space.ReadRequest{
Name: "images/file.jpg",
})
fmt.Println(rsp, err)
}
```
## Download
Download an object via a presigned url
[https://m3o.com/space/api#Download](https://m3o.com/space/api#Download)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/space"
)
// Download an object via a presigned url
func DownloadAnObject() {
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
rsp, err := spaceService.Download(&space.DownloadRequest{
Name: "images/file.jpg",
})
fmt.Println(rsp, err)
}
```
## 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
Update an object. If an object with this name does not exist, creates a new one. Update an object. If an object with this name does not exist, creates a new one.
@@ -232,3 +118,117 @@ func HeadAnObject() {
} }
``` ```
## Read
Read an object in space
[https://m3o.com/space/api#Read](https://m3o.com/space/api#Read)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/space"
)
// Read an object in space
func ReadAnObject() {
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
rsp, err := spaceService.Read(&space.ReadRequest{
Name: "images/file.jpg",
})
fmt.Println(rsp, err)
}
```
## Download
Download an object via a presigned url
[https://m3o.com/space/api#Download](https://m3o.com/space/api#Download)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/space"
)
// Download an object via a presigned url
func DownloadAnObject() {
spaceService := space.NewSpaceService(os.Getenv("M3O_API_TOKEN"))
rsp, err := spaceService.Download(&space.DownloadRequest{
Name: "images/file.jpg",
})
fmt.Println(rsp, err)
}
```
## 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)
}
```

View File

@@ -4,61 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/stream/api](ht
Endpoints: Endpoints:
## ListMessages
List messages for a given channel
[https://m3o.com/stream/api#ListMessages](https://m3o.com/stream/api#ListMessages)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/stream"
)
// List messages for a given channel
func ListMessages() {
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
rsp, err := streamService.ListMessages(&stream.ListMessagesRequest{
Channel: "general",
})
fmt.Println(rsp, err)
}
```
## ListChannels
List all the active channels
[https://m3o.com/stream/api#ListChannels](https://m3o.com/stream/api#ListChannels)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/stream"
)
// List all the active channels
func ListChannels() {
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
rsp, err := streamService.ListChannels(&stream.ListChannelsRequest{
})
fmt.Println(rsp, err)
}
```
## CreateChannel ## CreateChannel
Create a channel with a given name and description. Channels are created automatically but Create a channel with a given name and description. Channels are created automatically but
@@ -119,3 +64,58 @@ Text: "Hey checkout this tweet https://twitter.com/m3oservices/status/1455291054
} }
``` ```
## ListMessages
List messages for a given channel
[https://m3o.com/stream/api#ListMessages](https://m3o.com/stream/api#ListMessages)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/stream"
)
// List messages for a given channel
func ListMessages() {
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
rsp, err := streamService.ListMessages(&stream.ListMessagesRequest{
Channel: "general",
})
fmt.Println(rsp, err)
}
```
## ListChannels
List all the active channels
[https://m3o.com/stream/api#ListChannels](https://m3o.com/stream/api#ListChannels)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/stream"
)
// List all the active channels
func ListChannels() {
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
rsp, err := streamService.ListChannels(&stream.ListChannelsRequest{
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,37 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/sunnah/api](ht
Endpoints: Endpoints:
## Hadiths
Hadiths returns a list of hadiths and their corresponding text for a
given book within a collection.
[https://m3o.com/sunnah/api#Hadiths](https://m3o.com/sunnah/api#Hadiths)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/sunnah"
)
// Hadiths returns a list of hadiths and their corresponding text for a
// given book within a collection.
func ListTheHadithsInAbook() {
sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN"))
rsp, err := sunnahService.Hadiths(&sunnah.HadithsRequest{
Book: 1,
Collection: "bukhari",
})
fmt.Println(rsp, err)
}
```
## Collections ## Collections
Get a list of available collections. A collection is Get a list of available collections. A collection is
@@ -92,34 +123,3 @@ Collection: "bukhari",
} }
``` ```
## Hadiths
Hadiths returns a list of hadiths and their corresponding text for a
given book within a collection.
[https://m3o.com/sunnah/api#Hadiths](https://m3o.com/sunnah/api#Hadiths)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/sunnah"
)
// Hadiths returns a list of hadiths and their corresponding text for a
// given book within a collection.
func ListTheHadithsInAbook() {
sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN"))
rsp, err := sunnahService.Hadiths(&sunnah.HadithsRequest{
Book: 1,
Collection: "bukhari",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,37 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/user/api](http
Endpoints: Endpoints:
## 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)
}
```
## UpdatePassword ## UpdatePassword
Update the account password Update the account password
@@ -66,13 +35,12 @@ UserId: "user-1",
} }
``` ```
## SendPasswordResetEmail ## ResetPassword
Send an email with a verification code to reset password. Reset password with the code sent by the "SendPasswordResetEmail" endpoint.
Call "ResetPassword" endpoint once user provides the code.
[https://m3o.com/user/api#SendPasswordResetEmail](https://m3o.com/user/api#SendPasswordResetEmail) [https://m3o.com/user/api#ResetPassword](https://m3o.com/user/api#ResetPassword)
```go ```go
package example package example
@@ -84,75 +52,14 @@ import(
"go.m3o.com/user" "go.m3o.com/user"
) )
// Send an email with a verification code to reset password. // Reset password with the code sent by the "SendPasswordResetEmail" endpoint.
// Call "ResetPassword" endpoint once user provides the code. func ResetPassword() {
func SendPasswordResetEmail() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.SendPasswordResetEmail(&user.SendPasswordResetEmailRequest{ rsp, err := userService.ResetPassword(&user.ResetPasswordRequest{
Email: "joe@example.com", Code: "012345",
FromName: "Awesome Dot Com", ConfirmPassword: "NewPassword1",
Subject: "Password reset", Email: "joe@example.com",
TextContent: `Hi there, NewPassword: "NewPassword1",
click here to reset your password: myapp.com/reset/code?=$code`,
})
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) fmt.Println(rsp, err)
@@ -186,41 +93,6 @@ Offset: 0,
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
}
```
## SendMagicLink
Login using email only - Passwordless
[https://m3o.com/user/api#SendMagicLink](https://m3o.com/user/api#SendMagicLink)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Login using email only - Passwordless
func SendAmagicLink() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.SendMagicLink(&user.SendMagicLinkRequest{
Address: "www.example.com",
Email: "joe@example.com",
Endpoint: "verifytoken",
FromName: "Awesome Dot Com",
Subject: "MagicLink to access your account",
TextContent: `Hi there,
Click here to access your account $micro_verification_link`,
})
fmt.Println(rsp, err)
} }
``` ```
## VerifyToken ## VerifyToken
@@ -255,36 +127,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
@@ -369,121 +211,6 @@ func ReadAccountByEmail() {
}) })
fmt.Println(rsp, err) 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)
}
```
## Logout
Logout a user account
[https://m3o.com/user/api#Logout](https://m3o.com/user/api#Logout)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Logout a user account
func LogAuserOut() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.Logout(&user.LogoutRequest{
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
})
fmt.Println(rsp, err)
}
```
## 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)
} }
``` ```
## SendVerificationEmail ## SendVerificationEmail
@@ -533,3 +260,276 @@ Please verify your email by clicking this link: $micro_verification_link`,
} }
``` ```
## Logout
Logout a user account
[https://m3o.com/user/api#Logout](https://m3o.com/user/api#Logout)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Logout a user account
func LogAuserOut() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.Logout(&user.LogoutRequest{
SessionId: "df91a612-5b24-4634-99ff-240220ab8f55",
})
fmt.Println(rsp, err)
}
```
## ReadSession
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)
}
```
## 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)
}
```
## 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)
}
```
## 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)
}
```
## 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)
}
```
## 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)
}
```

View File

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

3
m3o.go
View File

@@ -31,6 +31,7 @@ import (
"go.m3o.com/joke" "go.m3o.com/joke"
"go.m3o.com/lists" "go.m3o.com/lists"
"go.m3o.com/location" "go.m3o.com/location"
"go.m3o.com/meme"
"go.m3o.com/minecraft" "go.m3o.com/minecraft"
"go.m3o.com/movie" "go.m3o.com/movie"
"go.m3o.com/mq" "go.m3o.com/mq"
@@ -99,6 +100,7 @@ func NewClient(token string) *Client {
JokeService: joke.NewJokeService(token), JokeService: joke.NewJokeService(token),
ListsService: lists.NewListsService(token), ListsService: lists.NewListsService(token),
LocationService: location.NewLocationService(token), LocationService: location.NewLocationService(token),
MemeService: meme.NewMemeService(token),
MinecraftService: minecraft.NewMinecraftService(token), MinecraftService: minecraft.NewMinecraftService(token),
MovieService: movie.NewMovieService(token), MovieService: movie.NewMovieService(token),
MqService: mq.NewMqService(token), MqService: mq.NewMqService(token),
@@ -167,6 +169,7 @@ type Client struct {
JokeService *joke.JokeService JokeService *joke.JokeService
ListsService *lists.ListsService ListsService *lists.ListsService
LocationService *location.LocationService LocationService *location.LocationService
MemeService *meme.MemeService
MinecraftService *minecraft.MinecraftService MinecraftService *minecraft.MinecraftService
MovieService *movie.MovieService MovieService *movie.MovieService
MqService *mq.MqService MqService *mq.MqService

95
meme/meme.go Executable file
View File

@@ -0,0 +1,95 @@
package meme
import (
"go.m3o.com/client"
)
type Meme interface {
Generate(*GenerateRequest) (*GenerateResponse, error)
Templates(*TemplatesRequest) (*TemplatesResponse, error)
}
func NewMemeService(token string) *MemeService {
return &MemeService{
client: client.NewClient(&client.Options{
Token: token,
}),
}
}
type MemeService struct {
client *client.Client
}
//
func (t *MemeService) Generate(request *GenerateRequest) (*GenerateResponse, error) {
rsp := &GenerateResponse{}
return rsp, t.client.Call("meme", "Generate", request, rsp)
}
// List the available templates
func (t *MemeService) Templates(request *TemplatesRequest) (*TemplatesResponse, error) {
rsp := &TemplatesResponse{}
return rsp, t.client.Call("meme", "Templates", request, rsp)
}
type Box struct {
// colour hex code
Color string `json:"color"`
// height in pixels
Height int32 `json:"height"`
// outline color hex code
Outline string `json:"outline"`
// text to display
Text string `json:"text"`
// width in pixels
Width int32 `json:"width"`
// x axis position
X int32 `json:"x"`
// y axis position
Y int32 `json:"y"`
}
type GenerateRequest struct {
// bottom text
BottomText string `json:"bottom_text"`
// font: arial or impact
Font string `json:"font"`
// the template id to use
Id string `json:"id"`
// font size; defaults to 50px
MaxFontSize string `json:"max_font_size"`
// top text
TopText string `json:"top_text"`
}
type GenerateResponse struct {
// url of the meme
Url string `json:"url"`
}
type Template struct {
// number of boxes used
BoxCount int32 `json:"box_count"`
// height in pixels
Height int32 `json:"height"`
// id of the meme
Id string `json:"id"`
// name of the meme
Name string `json:"name"`
// url of the meme
Url string `json:"url"`
// width in pixels
Width int32 `json:"width"`
}
type TemplatesRequest struct {
}
type TemplatesResponse struct {
Templates []Template `json:"templates"`
}