Commit from m3o/m3o action

This commit is contained in:
m3o-actions
2021-11-10 11:05:04 +00:00
parent 1305ec64f5
commit 2deeb0ca70
26 changed files with 784 additions and 736 deletions

View File

@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Cache/api](htt
Endpoints: Endpoints:
## 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.
@@ -147,3 +119,31 @@ func GetAvalue() {
} }
``` ```
## 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

@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Crypto/api](ht
Endpoints: Endpoints:
## News
Get news related to a currency
[https://m3o.com/crypto/api#News](https://m3o.com/crypto/api#News)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/crypto"
)
// Get news related to a currency
func GetCryptocurrencyNews() {
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cryptoService.News(&crypto.NewsRequest{
Symbol: "BTCUSD",
})
fmt.Println(rsp, err)
}
```
## Price ## Price
Get the last price for a given crypto ticker Get the last price for a given crypto ticker
@@ -116,3 +88,31 @@ func GetPreviousClose() {
} }
``` ```
## News
Get news related to a currency
[https://m3o.com/crypto/api#News](https://m3o.com/crypto/api#News)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/crypto"
)
// Get news related to a currency
func GetCryptocurrencyNews() {
cryptoService := crypto.NewCryptoService(os.Getenv("M3O_API_TOKEN"))
rsp, err := cryptoService.News(&crypto.NewsRequest{
Symbol: "BTCUSD",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,65 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Currency/api](
Endpoints: Endpoints:
## Convert
Convert returns the currency conversion rate between two pairs e.g USD/GBP
[https://m3o.com/currency/api#Convert](https://m3o.com/currency/api#Convert)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/currency"
)
// Convert returns the currency conversion rate between two pairs e.g USD/GBP
func ConvertUsdToGbp() {
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
rsp, err := currencyService.Convert(&currency.ConvertRequest{
From: "USD",
To: "GBP",
})
fmt.Println(rsp, err)
}
```
## Convert
Convert returns the currency conversion rate between two pairs e.g USD/GBP
[https://m3o.com/currency/api#Convert](https://m3o.com/currency/api#Convert)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/currency"
)
// Convert returns the currency conversion rate between two pairs e.g USD/GBP
func Convert10usdToGbp() {
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
rsp, err := currencyService.Convert(&currency.ConvertRequest{
Amount: 10,
From: "USD",
To: "GBP",
})
fmt.Println(rsp, err)
}
```
## History ## History
Returns the historic rates for a currency on a given date Returns the historic rates for a currency on a given date
@@ -147,3 +88,62 @@ func GetRatesForUsd() {
} }
``` ```
## Convert
Convert returns the currency conversion rate between two pairs e.g USD/GBP
[https://m3o.com/currency/api#Convert](https://m3o.com/currency/api#Convert)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/currency"
)
// Convert returns the currency conversion rate between two pairs e.g USD/GBP
func ConvertUsdToGbp() {
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
rsp, err := currencyService.Convert(&currency.ConvertRequest{
From: "USD",
To: "GBP",
})
fmt.Println(rsp, err)
}
```
## Convert
Convert returns the currency conversion rate between two pairs e.g USD/GBP
[https://m3o.com/currency/api#Convert](https://m3o.com/currency/api#Convert)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/currency"
)
// Convert returns the currency conversion rate between two pairs e.g USD/GBP
func Convert10usdToGbp() {
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
rsp, err := currencyService.Convert(&currency.ConvertRequest{
Amount: 10,
From: "USD",
To: "GBP",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,62 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Db/api](https:
Endpoints: Endpoints:
## Truncate
Truncate the records in a table
[https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Truncate the records in a table
func TruncateTable() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Truncate(&db.TruncateRequest{
Table: "users",
})
fmt.Println(rsp, err)
}
```
## Count
Count records in a table
[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Count records in a table
func CountEntriesInAtable() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Count(&db.CountRequest{
Table: "users",
})
fmt.Println(rsp, err)
}
```
## Create ## Create
Create a record in the database. Optionally include an "id" field otherwise it's set automatically. Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
@@ -184,3 +128,59 @@ Table: "users",
} }
``` ```
## Truncate
Truncate the records in a table
[https://m3o.com/db/api#Truncate](https://m3o.com/db/api#Truncate)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Truncate the records in a table
func TruncateTable() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Truncate(&db.TruncateRequest{
Table: "users",
})
fmt.Println(rsp, err)
}
```
## Count
Count records in a table
[https://m3o.com/db/api#Count](https://m3o.com/db/api#Count)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/db"
)
// Count records in a table
func CountEntriesInAtable() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Count(&db.CountRequest{
Table: "users",
})
fmt.Println(rsp, err)
}
```

View File

@@ -12,10 +12,10 @@ func main() {
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN")) dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
rsp, err := dbService.Create(&db.CreateRequest{ rsp, err := dbService.Create(&db.CreateRequest{
Record: map[string]interface{}{ Record: map[string]interface{}{
"id": "1",
"name": "Jane", "name": "Jane",
"age": 42, "age": 42,
"isActive": true, "isActive": true,
"id": "1",
}, },
Table: "users", Table: "users",
}) })

View File

@@ -4,6 +4,63 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Emoji/api](htt
Endpoints: Endpoints:
## Flag
Get the flag for a country. Requires country code e.g GB for great britain
[https://m3o.com/emoji/api#Flag](https://m3o.com/emoji/api#Flag)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/emoji"
)
// Get the flag for a country. Requires country code e.g GB for great britain
func GetFlagByCountryCode() {
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
rsp, err := emojiService.Flag(&emoji.FlagRequest{
})
fmt.Println(rsp, err)
}
```
## 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)
}
```
## Send ## Send
Send an emoji to anyone via SMS. Messages are sent in the form '<message> Sent from <from>' Send an emoji to anyone via SMS. Messages are sent in the form '<message> Sent from <from>'
@@ -62,60 +119,3 @@ func FindEmoji() {
} }
``` ```
## Flag
Get the flag for a country. Requires country code e.g GB for great britain
[https://m3o.com/emoji/api#Flag](https://m3o.com/emoji/api#Flag)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/emoji"
)
// Get the flag for a country. Requires country code e.g GB for great britain
func GetFlagByCountryCode() {
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
rsp, err := emojiService.Flag(&emoji.FlagRequest{
})
fmt.Println(rsp, err)
}
```
## 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

@@ -4,6 +4,33 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Evchargers/api
Endpoints: Endpoints:
## ReferenceData
Retrieve reference data as used by this API and in conjunction with the Search endpoint
[https://m3o.com/evchargers/api#ReferenceData](https://m3o.com/evchargers/api#ReferenceData)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/evchargers"
)
// Retrieve reference data as used by this API and in conjunction with the Search endpoint
func GetReferenceData() {
evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN"))
rsp, err := evchargersService.ReferenceData(&evchargers.ReferenceDataRequest{
})
fmt.Println(rsp, err)
}
```
## Search ## Search
Search by giving a coordinate and a max distance, or bounding box and optional filters Search by giving a coordinate and a max distance, or bounding box and optional filters
@@ -98,30 +125,3 @@ Location: &evchargers.Coordinates{
} }
``` ```
## ReferenceData
Retrieve reference data as used by this API and in conjunction with the Search endpoint
[https://m3o.com/evchargers/api#ReferenceData](https://m3o.com/evchargers/api#ReferenceData)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/evchargers"
)
// Retrieve reference data as used by this API and in conjunction with the Search endpoint
func GetReferenceData() {
evchargersService := evchargers.NewEvchargersService(os.Getenv("M3O_API_TOKEN"))
rsp, err := evchargersService.ReferenceData(&evchargers.ReferenceDataRequest{
})
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,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/File/api](http
Endpoints: Endpoints:
## List
List files by their project and optionally a path.
[https://m3o.com/file/api#List](https://m3o.com/file/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/file"
)
// List files by their project and optionally a path.
func ListFiles() {
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
rsp, err := fileService.List(&file.ListRequest{
Project: "examples",
})
fmt.Println(rsp, err)
}
```
## Delete ## Delete
Delete a file by project name/path Delete a file by project name/path
@@ -94,31 +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)
}
```

View File

@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Helloworld/api
Endpoints: Endpoints:
## Call
Call returns a personalised "Hello $name" response
[https://m3o.com/helloworld/api#Call](https://m3o.com/helloworld/api#Call)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/helloworld"
)
// Call returns a personalised "Hello $name" response
func CallTheHelloworldService() {
helloworldService := helloworld.NewHelloworldService(os.Getenv("M3O_API_TOKEN"))
rsp, err := helloworldService.Call(&helloworld.CallRequest{
Name: "John",
})
fmt.Println(rsp, err)
}
```
## Stream ## Stream
Stream returns a stream of "Hello $name" responses Stream returns a stream of "Hello $name" responses
@@ -46,31 +74,3 @@ Name: "John",
} }
} }
``` ```
## Call
Call returns a personalised "Hello $name" response
[https://m3o.com/helloworld/api#Call](https://m3o.com/helloworld/api#Call)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/helloworld"
)
// Call returns a personalised "Hello $name" response
func CallTheHelloworldService() {
helloworldService := helloworld.NewHelloworldService(os.Getenv("M3O_API_TOKEN"))
rsp, err := helloworldService.Call(&helloworld.CallRequest{
Name: "John",
})
fmt.Println(rsp, err)
}
```

View File

@@ -9,6 +9,8 @@ Endpoints:
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.
If one of width or height is 0, the image aspect ratio is preserved. If one of width or height is 0, the image aspect ratio is preserved.
Optional cropping. Optional cropping.
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#Resize](https://m3o.com/image/api#Resize) [https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize)
@@ -26,6 +28,8 @@ import(
// 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.
// If one of width or height is 0, the image aspect ratio is preserved. // If one of width or height is 0, the image aspect ratio is preserved.
// Optional cropping. // Optional cropping.
// 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 Base64toHostedImage() { func Base64toHostedImage() {
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
rsp, err := imageService.Resize(&image.ResizeRequest{ rsp, err := imageService.Resize(&image.ResizeRequest{
@@ -44,6 +48,8 @@ Width: 100,
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.
If one of width or height is 0, the image aspect ratio is preserved. If one of width or height is 0, the image aspect ratio is preserved.
Optional cropping. Optional cropping.
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#Resize](https://m3o.com/image/api#Resize) [https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize)
@@ -61,6 +67,8 @@ import(
// 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.
// If one of width or height is 0, the image aspect ratio is preserved. // If one of width or height is 0, the image aspect ratio is preserved.
// Optional cropping. // Optional cropping.
// 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 Base64toBase64image() { func Base64toBase64image() {
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
rsp, err := imageService.Resize(&image.ResizeRequest{ rsp, err := imageService.Resize(&image.ResizeRequest{
@@ -78,6 +86,8 @@ Width: 100,
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.
If one of width or height is 0, the image aspect ratio is preserved. If one of width or height is 0, the image aspect ratio is preserved.
Optional cropping. Optional cropping.
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#Resize](https://m3o.com/image/api#Resize) [https://m3o.com/image/api#Resize](https://m3o.com/image/api#Resize)
@@ -95,6 +105,8 @@ import(
// 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.
// If one of width or height is 0, the image aspect ratio is preserved. // If one of width or height is 0, the image aspect ratio is preserved.
// Optional cropping. // Optional cropping.
// 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 Base64toBase64imageWithCropping() { func Base64toBase64imageWithCropping() {
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
rsp, err := imageService.Resize(&image.ResizeRequest{ rsp, err := imageService.Resize(&image.ResizeRequest{
@@ -115,6 +127,8 @@ Width: 100,
Convert an image from one format (jpeg, png etc.) to an other either on the fly (from base64 to base64), Convert an image from one format (jpeg, png etc.) to an other either on the fly (from base64 to base64),
or by uploading the conversion result. or by uploading the conversion result.
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#Convert](https://m3o.com/image/api#Convert) [https://m3o.com/image/api#Convert](https://m3o.com/image/api#Convert)
@@ -131,6 +145,8 @@ import(
// Convert an image from one format (jpeg, png etc.) to an other either on the fly (from base64 to base64), // Convert an image from one format (jpeg, png etc.) to an other either on the fly (from base64 to base64),
// or by uploading the conversion result. // or by uploading the conversion result.
// 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 ConvertApngImageToAjpegTakenFromAurlAndSavedToAurlOnMicrosCdn() { func ConvertApngImageToAjpegTakenFromAurlAndSavedToAurlOnMicrosCdn() {
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
rsp, err := imageService.Convert(&image.ConvertRequest{ rsp, err := imageService.Convert(&image.ConvertRequest{
@@ -146,6 +162,8 @@ Url: "somewebsite.com/cat.png",
Upload an image by either sending a base64 encoded image to this endpoint or a URL. 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 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) [https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload)
@@ -162,6 +180,8 @@ import(
// Upload an image by either sending a base64 encoded image to this endpoint or a URL. // 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 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() { func UploadAbase64imageToMicrosCdn() {
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
rsp, err := imageService.Upload(&image.UploadRequest{ rsp, err := imageService.Upload(&image.UploadRequest{
@@ -177,6 +197,8 @@ Name: "cat.jpeg",
Upload an image by either sending a base64 encoded image to this endpoint or a URL. 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 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) [https://m3o.com/image/api#Upload](https://m3o.com/image/api#Upload)
@@ -193,6 +215,8 @@ import(
// Upload an image by either sending a base64 encoded image to this endpoint or a URL. // 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 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() { func UploadAnImageFromAurlToMicrosCdn() {
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
rsp, err := imageService.Upload(&image.UploadRequest{ rsp, err := imageService.Upload(&image.UploadRequest{

View File

@@ -9,6 +9,8 @@ import (
// Convert an image from one format (jpeg, png etc.) to an other either on the fly (from base64 to base64), // Convert an image from one format (jpeg, png etc.) to an other either on the fly (from base64 to base64),
// or by uploading the conversion result. // or by uploading the conversion result.
// 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 main() { func main() {
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
rsp, err := imageService.Convert(&image.ConvertRequest{ rsp, err := imageService.Convert(&image.ConvertRequest{

View File

@@ -10,6 +10,8 @@ import (
// 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.
// If one of width or height is 0, the image aspect ratio is preserved. // If one of width or height is 0, the image aspect ratio is preserved.
// Optional cropping. // Optional cropping.
// 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 main() { func main() {
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
rsp, err := imageService.Resize(&image.ResizeRequest{ rsp, err := imageService.Resize(&image.ResizeRequest{

View File

@@ -10,6 +10,8 @@ import (
// 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.
// If one of width or height is 0, the image aspect ratio is preserved. // If one of width or height is 0, the image aspect ratio is preserved.
// Optional cropping. // Optional cropping.
// 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 main() { func main() {
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
rsp, err := imageService.Resize(&image.ResizeRequest{ rsp, err := imageService.Resize(&image.ResizeRequest{

View File

@@ -10,6 +10,8 @@ import (
// 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.
// If one of width or height is 0, the image aspect ratio is preserved. // If one of width or height is 0, the image aspect ratio is preserved.
// Optional cropping. // Optional cropping.
// 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 main() { func main() {
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
rsp, err := imageService.Resize(&image.ResizeRequest{ rsp, err := imageService.Resize(&image.ResizeRequest{

View File

@@ -9,6 +9,8 @@ import (
// Upload an image by either sending a base64 encoded image to this endpoint or a URL. // 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 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 main() { func main() {
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
rsp, err := imageService.Upload(&image.UploadRequest{ rsp, err := imageService.Upload(&image.UploadRequest{

View File

@@ -9,6 +9,8 @@ import (
// Upload an image by either sending a base64 encoded image to this endpoint or a URL. // 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 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 main() { func main() {
imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN")) imageService := image.NewImageService(os.Getenv("M3O_API_TOKEN"))
rsp, err := imageService.Upload(&image.UploadRequest{ rsp, err := imageService.Upload(&image.UploadRequest{

View File

@@ -12,9 +12,9 @@ func main() {
mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN")) mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN"))
rsp, err := mqService.Publish(&mq.PublishRequest{ rsp, err := mqService.Publish(&mq.PublishRequest{
Message: map[string]interface{}{ Message: map[string]interface{}{
"id": "1",
"type": "signup", "type": "signup",
"user": "john", "user": "john",
"id": "1",
}, },
Topic: "events", Topic: "events",
}) })

View File

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

View File

@@ -4,62 +4,6 @@ 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
@@ -120,3 +64,59 @@ 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,6 +4,41 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Routing/api](h
Endpoints: Endpoints:
## Eta
Get the eta for a route from origin to destination. The eta is an estimated time based on car routes
[https://m3o.com/routing/api#Eta](https://m3o.com/routing/api#Eta)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/routing"
)
// Get the eta for a route from origin to destination. The eta is an estimated time based on car routes
func EtaFromPointAtoPointB() {
routingService := routing.NewRoutingService(os.Getenv("M3O_API_TOKEN"))
rsp, err := routingService.Eta(&routing.EtaRequest{
Destination: &routing.Point{
Latitude: 52.529407,
Longitude: 13.397634,
},
Origin: &routing.Point{
Latitude: 52.517037,
Longitude: 13.38886,
},
})
fmt.Println(rsp, err)
}
```
## Directions ## Directions
Turn by turn directions from a start point to an end point including maneuvers and bearings Turn by turn directions from a start point to an end point including maneuvers and bearings
@@ -74,38 +109,3 @@ Origin: &routing.Point{
} }
``` ```
## Eta
Get the eta for a route from origin to destination. The eta is an estimated time based on car routes
[https://m3o.com/routing/api#Eta](https://m3o.com/routing/api#Eta)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/routing"
)
// Get the eta for a route from origin to destination. The eta is an estimated time based on car routes
func EtaFromPointAtoPointB() {
routingService := routing.NewRoutingService(os.Getenv("M3O_API_TOKEN"))
rsp, err := routingService.Eta(&routing.EtaRequest{
Destination: &routing.Point{
Latitude: 52.529407,
Longitude: 13.397634,
},
Origin: &routing.Point{
Latitude: 52.517037,
Longitude: 13.38886,
},
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,65 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Sunnah/api](ht
Endpoints: Endpoints:
## Collections
Get a list of available collections. A collection is
a compilation of hadiths collected and written by an author.
[https://m3o.com/sunnah/api#Collections](https://m3o.com/sunnah/api#Collections)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/sunnah"
)
// Get a list of available collections. A collection is
// a compilation of hadiths collected and written by an author.
func ListAvailableCollections() {
sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN"))
rsp, err := sunnahService.Collections(&sunnah.CollectionsRequest{
})
fmt.Println(rsp, err)
}
```
## Books
Get a list of books from within a collection. A book can contain many chapters
each with its own hadiths.
[https://m3o.com/sunnah/api#Books](https://m3o.com/sunnah/api#Books)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/sunnah"
)
// Get a list of books from within a collection. A book can contain many chapters
// each with its own hadiths.
func GetTheBooksWithinAcollection() {
sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN"))
rsp, err := sunnahService.Books(&sunnah.BooksRequest{
Collection: "bukhari",
})
fmt.Println(rsp, err)
}
```
## Chapters ## Chapters
Get all the chapters of a given book within a collection. Get all the chapters of a given book within a collection.
@@ -123,3 +64,62 @@ Collection: "bukhari",
} }
``` ```
## Collections
Get a list of available collections. A collection is
a compilation of hadiths collected and written by an author.
[https://m3o.com/sunnah/api#Collections](https://m3o.com/sunnah/api#Collections)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/sunnah"
)
// Get a list of available collections. A collection is
// a compilation of hadiths collected and written by an author.
func ListAvailableCollections() {
sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN"))
rsp, err := sunnahService.Collections(&sunnah.CollectionsRequest{
})
fmt.Println(rsp, err)
}
```
## Books
Get a list of books from within a collection. A book can contain many chapters
each with its own hadiths.
[https://m3o.com/sunnah/api#Books](https://m3o.com/sunnah/api#Books)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/sunnah"
)
// Get a list of books from within a collection. A book can contain many chapters
// each with its own hadiths.
func GetTheBooksWithinAcollection() {
sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN"))
rsp, err := sunnahService.Books(&sunnah.BooksRequest{
Collection: "bukhari",
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,6 +4,61 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Twitter/api](h
Endpoints: Endpoints:
## Search
Search for tweets with a simple query
[https://m3o.com/twitter/api#Search](https://m3o.com/twitter/api#Search)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/twitter"
)
// Search for tweets with a simple query
func SearchForTweets() {
twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN"))
rsp, err := twitterService.Search(&twitter.SearchRequest{
Query: "cats",
})
fmt.Println(rsp, err)
}
```
## 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 ## User
Get a user's twitter profile Get a user's twitter profile
@@ -61,58 +116,3 @@ Username: "m3oservices",
} }
``` ```
## Search
Search for tweets with a simple query
[https://m3o.com/twitter/api#Search](https://m3o.com/twitter/api#Search)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/twitter"
)
// Search for tweets with a simple query
func SearchForTweets() {
twitterService := twitter.NewTwitterService(os.Getenv("M3O_API_TOKEN"))
rsp, err := twitterService.Search(&twitter.SearchRequest{
Query: "cats",
})
fmt.Println(rsp, err)
}
```
## 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)
}
```

View File

@@ -4,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Url/api](https
Endpoints: Endpoints:
## List
List information on all the shortened URLs that you have created
[https://m3o.com/url/api#List](https://m3o.com/url/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/url"
)
// List information on all the shortened URLs that you have created
func ListYourShortenedUrls() {
urlService := url.NewUrlService(os.Getenv("M3O_API_TOKEN"))
rsp, err := urlService.List(&url.ListRequest{
})
fmt.Println(rsp, err)
}
```
## Shorten ## Shorten
Shortens a destination URL and returns a full short URL. Shortens a destination URL and returns a full short URL.
@@ -85,3 +58,30 @@ func ResolveAshortUrlToAlongDestinationUrl() {
} }
``` ```
## List
List information on all the shortened URLs that you have created
[https://m3o.com/url/api#List](https://m3o.com/url/api#List)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/url"
)
// List information on all the shortened URLs that you have created
func ListYourShortenedUrls() {
urlService := url.NewUrlService(os.Getenv("M3O_API_TOKEN"))
rsp, err := urlService.List(&url.ListRequest{
})
fmt.Println(rsp, err)
}
```

View File

@@ -4,12 +4,13 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/User/api](http
Endpoints: Endpoints:
## Read ## Login
Read an account by id, username or email. Only one need to be specified. 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#Read](https://m3o.com/user/api#Read) [https://m3o.com/user/api#Login](https://m3o.com/user/api#Login)
```go ```go
package example package example
@@ -21,67 +22,74 @@ import(
"go.m3o.com/user" "go.m3o.com/user"
) )
// Read an account by id, username or email. Only one need to be specified. // Login using username or email. The response will return a new session for successful login,
func ReadAnAccountById() { // 401 in the case of login failure and 500 for any other error
func LogAuserIn() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.Read(&user.ReadRequest{ rsp, err := userService.Login(&user.LoginRequest{
Id: "usrid-1",
})
fmt.Println(rsp, err)
}
```
## Read
Read an account by id, username or email. Only one need to be specified.
[https://m3o.com/user/api#Read](https://m3o.com/user/api#Read)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Read an account by id, username or email. Only one need to be specified.
func ReadAccountByUsernameOrEmail() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.Read(&user.ReadRequest{
Username: "usrname-1",
})
fmt.Println(rsp, err)
}
```
## Read
Read an account by id, username or email. Only one need to be specified.
[https://m3o.com/user/api#Read](https://m3o.com/user/api#Read)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Read an account by id, username or email. Only one need to be specified.
func ReadAccountByEmail() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.Read(&user.ReadRequest{
Email: "joe@example.com", Email: "joe@example.com",
Password: "mySecretPass123",
})
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: "usrid-1",
Password: "mySecretPass123",
Username: "usrname-1",
})
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: "myEvenMoreSecretPass123",
NewPassword: "myEvenMoreSecretPass123",
OldPassword: "mySecretPass123",
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
@@ -191,12 +199,12 @@ func LogAuserOut() {
} }
``` ```
## UpdatePassword ## ReadSession
Update the account password 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#UpdatePassword](https://m3o.com/user/api#UpdatePassword) [https://m3o.com/user/api#ReadSession](https://m3o.com/user/api#ReadSession)
```go ```go
package example package example
@@ -208,13 +216,11 @@ import(
"go.m3o.com/user" "go.m3o.com/user"
) )
// Update the account password // Read a session by the session id. In the event it has expired or is not found and error is returned.
func UpdateTheAccountPassword() { func ReadAsessionByTheSessionId() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN")) userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.UpdatePassword(&user.UpdatePasswordRequest{ rsp, err := userService.ReadSession(&user.ReadSessionRequest{
ConfirmPassword: "myEvenMoreSecretPass123", SessionId: "sds34s34s34-s34s34-s43s43s34-s4s34s",
NewPassword: "myEvenMoreSecretPass123",
OldPassword: "mySecretPass123",
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
@@ -248,6 +254,90 @@ Id: "usrid-1",
}) })
fmt.Println(rsp, err) fmt.Println(rsp, err)
}
```
## Read
Read an account by id, username or email. Only one need to be specified.
[https://m3o.com/user/api#Read](https://m3o.com/user/api#Read)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Read an account by id, username or email. Only one need to be specified.
func ReadAnAccountById() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.Read(&user.ReadRequest{
Id: "usrid-1",
})
fmt.Println(rsp, err)
}
```
## Read
Read an account by id, username or email. Only one need to be specified.
[https://m3o.com/user/api#Read](https://m3o.com/user/api#Read)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Read an account by id, username or email. Only one need to be specified.
func ReadAccountByUsernameOrEmail() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.Read(&user.ReadRequest{
Username: "usrname-1",
})
fmt.Println(rsp, err)
}
```
## Read
Read an account by id, username or email. Only one need to be specified.
[https://m3o.com/user/api#Read](https://m3o.com/user/api#Read)
```go
package example
import(
"fmt"
"os"
"go.m3o.com/user"
)
// Read an account by id, username or email. Only one need to be specified.
func ReadAccountByEmail() {
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
rsp, err := userService.Read(&user.ReadRequest{
Email: "joe@example.com",
})
fmt.Println(rsp, err)
} }
``` ```
## VerifyEmail ## VerifyEmail
@@ -278,93 +368,3 @@ func VerifyEmail() {
} }
``` ```
## 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: "mySecretPass123",
})
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: "sds34s34s34-s34s34-s43s43s34-s4s34s",
})
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: "usrid-1",
Password: "mySecretPass123",
Username: "usrname-1",
})
fmt.Println(rsp, err)
}
```

View File

@@ -18,6 +18,8 @@ type ImageService struct {
// Convert an image from one format (jpeg, png etc.) to an other either on the fly (from base64 to base64), // Convert an image from one format (jpeg, png etc.) to an other either on the fly (from base64 to base64),
// or by uploading the conversion result. // or by uploading the conversion result.
// 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 (t *ImageService) Convert(request *ConvertRequest) (*ConvertResponse, error) { func (t *ImageService) Convert(request *ConvertRequest) (*ConvertResponse, error) {
rsp := &ConvertResponse{} rsp := &ConvertResponse{}
@@ -36,6 +38,8 @@ func (t *ImageService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
// 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.
// If one of width or height is 0, the image aspect ratio is preserved. // If one of width or height is 0, the image aspect ratio is preserved.
// Optional cropping. // Optional cropping.
// 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 (t *ImageService) Resize(request *ResizeRequest) (*ResizeResponse, error) { func (t *ImageService) Resize(request *ResizeRequest) (*ResizeResponse, error) {
rsp := &ResizeResponse{} rsp := &ResizeResponse{}
@@ -45,6 +49,8 @@ func (t *ImageService) Resize(request *ResizeRequest) (*ResizeResponse, error) {
// Upload an image by either sending a base64 encoded image to this endpoint or a URL. // 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 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 (t *ImageService) Upload(request *UploadRequest) (*UploadResponse, error) { func (t *ImageService) Upload(request *UploadRequest) (*UploadResponse, error) {
rsp := &UploadResponse{} rsp := &UploadResponse{}
@@ -55,6 +61,8 @@ func (t *ImageService) Upload(request *UploadRequest) (*UploadResponse, error) {
type ConvertRequest struct { type ConvertRequest struct {
// base64 encoded image to resize, // base64 encoded image to resize,
Base64 string `json:"base64"` Base64 string `json:"base64"`
// The image file to convert
File string `json:"file"`
// output name of the image including extension, ie. "cat.png" // output name of the image including extension, ie. "cat.png"
Name string `json:"name"` Name string `json:"name"`
// make output a URL and not a base64 response // make output a URL and not a base64 response
@@ -105,7 +113,9 @@ type ResizeRequest struct {
// if provided, after resize, the image // if provided, after resize, the image
// will be cropped // will be cropped
CropOptions *CropOptions `json:"cropOptions"` CropOptions *CropOptions `json:"cropOptions"`
Height int64 `json:"height,string"` // The image file to resize
File string `json:"file"`
Height int64 `json:"height,string"`
// output name of the image including extension, ie. "cat.png" // output name of the image including extension, ie. "cat.png"
Name string `json:"name"` Name string `json:"name"`
// make output a URL and not a base64 response // make output a URL and not a base64 response
@@ -123,6 +133,8 @@ type ResizeResponse struct {
type UploadRequest struct { type UploadRequest struct {
// Base64 encoded image to upload, // Base64 encoded image to upload,
Base64 string `json:"base64"` Base64 string `json:"base64"`
// The image file to upload
File string `json:"file"`
// Output name of the image including extension, ie. "cat.png" // Output name of the image including extension, ie. "cat.png"
Name string `json:"name"` Name string `json:"name"`
// URL of the image to upload // URL of the image to upload