mirror of
https://github.com/kevin-DL/m3o-go.git
synced 2026-01-11 18:44:26 +00:00
Commit from m3o/m3o action
This commit is contained in:
@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Currency/api](
|
||||
|
||||
Endpoints:
|
||||
|
||||
## History
|
||||
|
||||
Returns the historic rates for a currency on a given date
|
||||
|
||||
|
||||
[https://m3o.com/currency/api#History](https://m3o.com/currency/api#History)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/currency"
|
||||
)
|
||||
|
||||
// Returns the historic rates for a currency on a given date
|
||||
func HistoricRatesForAcurrency() {
|
||||
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := currencyService.History(¤cy.HistoryRequest{
|
||||
Code: "USD",
|
||||
Date: "2021-05-30",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Codes
|
||||
|
||||
Codes returns the supported currency codes for the API
|
||||
@@ -114,31 +142,3 @@ To: "GBP",
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## History
|
||||
|
||||
Returns the historic rates for a currency on a given date
|
||||
|
||||
|
||||
[https://m3o.com/currency/api#History](https://m3o.com/currency/api#History)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/currency"
|
||||
)
|
||||
|
||||
// Returns the historic rates for a currency on a given date
|
||||
func HistoricRatesForAcurrency() {
|
||||
currencyService := currency.NewCurrencyService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := currencyService.History(¤cy.HistoryRequest{
|
||||
Code: "USD",
|
||||
Date: "2021-05-30",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,98 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Db/api](https:
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Create
|
||||
|
||||
Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||
func CreateArecord() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Create(&db.CreateRequest{
|
||||
Record: map[string]interface{}{
|
||||
"isActive": true,
|
||||
"id": "1",
|
||||
"name": "Jane",
|
||||
"age": 42,
|
||||
},
|
||||
Table: "users",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Update
|
||||
|
||||
Update a record in the database. Include an "id" in the record to update.
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Update a record in the database. Include an "id" in the record to update.
|
||||
func UpdateArecord() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Update(&db.UpdateRequest{
|
||||
Record: map[string]interface{}{
|
||||
"id": "1",
|
||||
"age": 43,
|
||||
},
|
||||
Table: "users",
|
||||
|
||||
})
|
||||
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: "users",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
|
||||
Delete a record in the database by id.
|
||||
@@ -178,3 +86,95 @@ func CountEntriesInAtable() {
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Create
|
||||
|
||||
Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Create](https://m3o.com/db/api#Create)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||
func CreateArecord() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Create(&db.CreateRequest{
|
||||
Record: map[string]interface{}{
|
||||
"id": "1",
|
||||
"name": "Jane",
|
||||
"age": 42,
|
||||
"isActive": true,
|
||||
},
|
||||
Table: "users",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Update
|
||||
|
||||
Update a record in the database. Include an "id" in the record to update.
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Update](https://m3o.com/db/api#Update)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Update a record in the database. Include an "id" in the record to update.
|
||||
func UpdateArecord() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Update(&db.UpdateRequest{
|
||||
Record: map[string]interface{}{
|
||||
"age": 43,
|
||||
"id": "1",
|
||||
},
|
||||
Table: "users",
|
||||
|
||||
})
|
||||
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: "users",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
|
||||
@@ -12,8 +12,8 @@ func UpdateArecord() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Update(&db.UpdateRequest{
|
||||
Record: map[string]interface{}{
|
||||
"id": "1",
|
||||
"age": 43,
|
||||
"id": "1",
|
||||
},
|
||||
Table: "users",
|
||||
})
|
||||
|
||||
@@ -4,6 +4,35 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Emoji/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Send
|
||||
|
||||
Send an emoji to anyone via SMS. Messages are sent in the form '<message> Sent from <from>'
|
||||
|
||||
|
||||
[https://m3o.com/emoji/api#Send](https://m3o.com/emoji/api#Send)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/emoji"
|
||||
)
|
||||
|
||||
// Send an emoji to anyone via SMS. Messages are sent in the form '<message> Sent from <from>'
|
||||
func SendAtextContainingAnEmojiToAnyoneViaSms() {
|
||||
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := emojiService.Send(&emoji.SendRequest{
|
||||
From: "Alice",
|
||||
Message: "let's grab a :beer:",
|
||||
To: "+44782669123",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Find
|
||||
|
||||
Find an emoji by its alias e.g :beer:
|
||||
@@ -86,32 +115,3 @@ func PrintTextIncludingEmoji() {
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Send
|
||||
|
||||
Send an emoji to anyone via SMS. Messages are sent in the form '<message> Sent from <from>'
|
||||
|
||||
|
||||
[https://m3o.com/emoji/api#Send](https://m3o.com/emoji/api#Send)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/emoji"
|
||||
)
|
||||
|
||||
// Send an emoji to anyone via SMS. Messages are sent in the form '<message> Sent from <from>'
|
||||
func SendAtextContainingAnEmojiToAnyoneViaSms() {
|
||||
emojiService := emoji.NewEmojiService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := emojiService.Send(&emoji.SendRequest{
|
||||
From: "Alice",
|
||||
Message: "let's grab a :beer:",
|
||||
To: "+44782669123",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/File/api](http
|
||||
|
||||
Endpoints:
|
||||
|
||||
## 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)
|
||||
}
|
||||
```
|
||||
## Save
|
||||
|
||||
Save a file
|
||||
@@ -118,3 +90,31 @@ 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)
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,34 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Geocoding/api]
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Reverse
|
||||
|
||||
Reverse lookup an address from gps coordinates
|
||||
|
||||
|
||||
[https://m3o.com/geocoding/api#Reverse](https://m3o.com/geocoding/api#Reverse)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/geocoding"
|
||||
)
|
||||
|
||||
// Reverse lookup an address from gps coordinates
|
||||
func ReverseGeocodeLocation() {
|
||||
geocodingService := geocoding.NewGeocodingService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := geocodingService.Reverse(&geocoding.ReverseRequest{
|
||||
Latitude: 51.5123064,
|
||||
Longitude: -0.1216235,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Lookup
|
||||
|
||||
Lookup returns a geocoded address including normalized address and gps coordinates. All fields are optional, provide more to get more accurate results
|
||||
@@ -34,31 +62,3 @@ Postcode: "wc2b",
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Reverse
|
||||
|
||||
Reverse lookup an address from gps coordinates
|
||||
|
||||
|
||||
[https://m3o.com/geocoding/api#Reverse](https://m3o.com/geocoding/api#Reverse)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/geocoding"
|
||||
)
|
||||
|
||||
// Reverse lookup an address from gps coordinates
|
||||
func ReverseGeocodeLocation() {
|
||||
geocodingService := geocoding.NewGeocodingService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := geocodingService.Reverse(&geocoding.ReverseRequest{
|
||||
Latitude: 51.5123064,
|
||||
Longitude: -0.1216235,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
|
||||
@@ -6,7 +6,7 @@ Endpoints:
|
||||
|
||||
## Publish
|
||||
|
||||
Publish a message to the mq. Specify a topic to group messages for a specific topic.
|
||||
Publish a message. Specify a topic to group messages for a specific topic.
|
||||
|
||||
|
||||
[https://m3o.com/mq/api#Publish](https://m3o.com/mq/api#Publish)
|
||||
@@ -21,7 +21,7 @@ import(
|
||||
"go.m3o.com/mq"
|
||||
)
|
||||
|
||||
// Publish a message to the mq. Specify a topic to group messages for a specific topic.
|
||||
// Publish a message. Specify a topic to group messages for a specific topic.
|
||||
func PublishAmessage() {
|
||||
mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := mqService.Publish(&mq.PublishRequest{
|
||||
|
||||
@@ -7,14 +7,14 @@ import (
|
||||
"go.m3o.com/mq"
|
||||
)
|
||||
|
||||
// Publish a message to the mq. Specify a topic to group messages for a specific topic.
|
||||
// Publish a message. Specify a topic to group messages for a specific topic.
|
||||
func PublishAmessage() {
|
||||
mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := mqService.Publish(&mq.PublishRequest{
|
||||
Message: map[string]interface{}{
|
||||
"user": "john",
|
||||
"id": "1",
|
||||
"type": "signup",
|
||||
"user": "john",
|
||||
},
|
||||
Topic: "events",
|
||||
})
|
||||
|
||||
@@ -4,88 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Notes/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Events
|
||||
|
||||
Subscribe to notes events
|
||||
|
||||
|
||||
[https://m3o.com/notes/api#Events](https://m3o.com/notes/api#Events)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/notes"
|
||||
)
|
||||
|
||||
// Subscribe to notes events
|
||||
func SubscribeToEvents() {
|
||||
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := notesService.Events(¬es.EventsRequest{
|
||||
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## 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(¬es.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(¬es.ReadRequest{
|
||||
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## List
|
||||
|
||||
List all the notes
|
||||
@@ -170,3 +88,85 @@ func DeleteAnote() {
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Events
|
||||
|
||||
Subscribe to notes events
|
||||
|
||||
|
||||
[https://m3o.com/notes/api#Events](https://m3o.com/notes/api#Events)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/notes"
|
||||
)
|
||||
|
||||
// Subscribe to notes events
|
||||
func SubscribeToEvents() {
|
||||
notesService := notes.NewNotesService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := notesService.Events(¬es.EventsRequest{
|
||||
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## 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(¬es.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(¬es.ReadRequest{
|
||||
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Otp/api](https
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Generate
|
||||
|
||||
Generate an OTP (one time pass) code
|
||||
|
||||
|
||||
[https://m3o.com/otp/api#Generate](https://m3o.com/otp/api#Generate)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/otp"
|
||||
)
|
||||
|
||||
// Generate an OTP (one time pass) code
|
||||
func GenerateOtp() {
|
||||
otpService := otp.NewOtpService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := otpService.Generate(&otp.GenerateRequest{
|
||||
Id: "asim@example.com",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Validate
|
||||
|
||||
Validate the OTP code
|
||||
@@ -59,3 +32,30 @@ Id: "asim@example.com",
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Generate
|
||||
|
||||
Generate an OTP (one time pass) code
|
||||
|
||||
|
||||
[https://m3o.com/otp/api#Generate](https://m3o.com/otp/api#Generate)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/otp"
|
||||
)
|
||||
|
||||
// Generate an OTP (one time pass) code
|
||||
func GenerateOtp() {
|
||||
otpService := otp.NewOtpService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := otpService.Generate(&otp.GenerateRequest{
|
||||
Id: "asim@example.com",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,33 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Quran/api](htt
|
||||
|
||||
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)
|
||||
@@ -89,30 +116,3 @@ func SearchTheQuran() {
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,6 +4,40 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Routing/api](h
|
||||
|
||||
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
|
||||
|
||||
Turn by turn directions from a start point to an end point including maneuvers and bearings
|
||||
@@ -72,37 +106,3 @@ Origin: &routing.Point{
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Sunnah/api](ht
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Collections
|
||||
|
||||
Get a list of available collections. A collection is
|
||||
a compilation of hadiths collected and written by an author.
|
||||
|
||||
|
||||
[https://m3o.com/sunnah/api#Collections](https://m3o.com/sunnah/api#Collections)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/sunnah"
|
||||
)
|
||||
|
||||
// Get a list of available collections. A collection is
|
||||
// a compilation of hadiths collected and written by an author.
|
||||
func ListAvailableCollections() {
|
||||
sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := sunnahService.Collections(&sunnah.CollectionsRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Books
|
||||
|
||||
Get a list of books from within a collection. A book can contain many chapters
|
||||
@@ -119,3 +91,31 @@ Collection: "bukhari",
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Collections
|
||||
|
||||
Get a list of available collections. A collection is
|
||||
a compilation of hadiths collected and written by an author.
|
||||
|
||||
|
||||
[https://m3o.com/sunnah/api#Collections](https://m3o.com/sunnah/api#Collections)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/sunnah"
|
||||
)
|
||||
|
||||
// Get a list of available collections. A collection is
|
||||
// a compilation of hadiths collected and written by an author.
|
||||
func ListAvailableCollections() {
|
||||
sunnahService := sunnah.NewSunnahService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := sunnahService.Collections(&sunnah.CollectionsRequest{
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,12 +4,12 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/User/api](http
|
||||
|
||||
Endpoints:
|
||||
|
||||
## UpdatePassword
|
||||
## Update
|
||||
|
||||
Update the account password
|
||||
Update the account username or email
|
||||
|
||||
|
||||
[https://m3o.com/user/api#UpdatePassword](https://m3o.com/user/api#UpdatePassword)
|
||||
[https://m3o.com/user/api#Update](https://m3o.com/user/api#Update)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -21,13 +21,12 @@ import(
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Update the account password
|
||||
func UpdateTheAccountPassword() {
|
||||
// Update the account username or email
|
||||
func UpdateAnAccount() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.UpdatePassword(&user.UpdatePasswordRequest{
|
||||
ConfirmPassword: "myEvenMoreSecretPass123",
|
||||
NewPassword: "myEvenMoreSecretPass123",
|
||||
OldPassword: "mySecretPass123",
|
||||
rsp, err := userService.Update(&user.UpdateRequest{
|
||||
Email: "joeotheremail@example.com",
|
||||
Id: "usrid-1",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
@@ -117,33 +116,6 @@ Password: "mySecretPass123",
|
||||
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: "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.
|
||||
@@ -174,34 +146,6 @@ Username: "usrname-1",
|
||||
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: "joeotheremail@example.com",
|
||||
Id: "usrid-1",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Read
|
||||
|
||||
Read an account by id, username or email. Only one need to be specified.
|
||||
@@ -329,6 +273,33 @@ Please verify your email by clicking this link: $micro_verification_link`,
|
||||
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: "sds34s34s34-s34s34-s43s43s34-s4s34s",
|
||||
|
||||
})
|
||||
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.
|
||||
@@ -356,3 +327,32 @@ func ReadAsessionByTheSessionId() {
|
||||
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)
|
||||
}
|
||||
```
|
||||
|
||||
3
m3o.go
3
m3o.go
@@ -35,7 +35,6 @@ import (
|
||||
"go.m3o.com/sentiment"
|
||||
"go.m3o.com/sms"
|
||||
"go.m3o.com/stock"
|
||||
"go.m3o.com/stream"
|
||||
"go.m3o.com/sunnah"
|
||||
"go.m3o.com/thumbnail"
|
||||
"go.m3o.com/time"
|
||||
@@ -85,7 +84,6 @@ func NewClient(token string) *Client {
|
||||
SentimentService: sentiment.NewSentimentService(token),
|
||||
SmsService: sms.NewSmsService(token),
|
||||
StockService: stock.NewStockService(token),
|
||||
StreamService: stream.NewStreamService(token),
|
||||
SunnahService: sunnah.NewSunnahService(token),
|
||||
ThumbnailService: thumbnail.NewThumbnailService(token),
|
||||
TimeService: time.NewTimeService(token),
|
||||
@@ -135,7 +133,6 @@ type Client struct {
|
||||
SentimentService *sentiment.SentimentService
|
||||
SmsService *sms.SmsService
|
||||
StockService *stock.StockService
|
||||
StreamService *stream.StreamService
|
||||
SunnahService *sunnah.SunnahService
|
||||
ThumbnailService *thumbnail.ThumbnailService
|
||||
TimeService *time.TimeService
|
||||
|
||||
2
mq/mq.go
2
mq/mq.go
@@ -16,7 +16,7 @@ type MqService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Publish a message to the mq. Specify a topic to group messages for a specific topic.
|
||||
// Publish a message. Specify a topic to group messages for a specific topic.
|
||||
func (t *MqService) Publish(request *PublishRequest) (*PublishResponse, error) {
|
||||
rsp := &PublishResponse{}
|
||||
return rsp, t.client.Call("mq", "Publish", request, rsp)
|
||||
|
||||
Reference in New Issue
Block a user