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:
8
cache/cache.go
vendored
8
cache/cache.go
vendored
@@ -16,25 +16,25 @@ type CacheService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Decrement a value (if it's a number)
|
||||
// Decrement a value (if it's a number). If key not found it is equivalent to set.
|
||||
func (t *CacheService) Decrement(request *DecrementRequest) (*DecrementResponse, error) {
|
||||
rsp := &DecrementResponse{}
|
||||
return rsp, t.client.Call("cache", "Decrement", request, rsp)
|
||||
}
|
||||
|
||||
// Delete a value from the cache
|
||||
// Delete a value from the cache. If key not found a success response is returned.
|
||||
func (t *CacheService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
||||
rsp := &DeleteResponse{}
|
||||
return rsp, t.client.Call("cache", "Delete", request, rsp)
|
||||
}
|
||||
|
||||
// Get an item from the cache by key
|
||||
// Get an item from the cache by key. If key is not found, an empty response is returned.
|
||||
func (t *CacheService) Get(request *GetRequest) (*GetResponse, error) {
|
||||
rsp := &GetResponse{}
|
||||
return rsp, t.client.Call("cache", "Get", request, rsp)
|
||||
}
|
||||
|
||||
// Increment a value (if it's a number)
|
||||
// Increment a value (if it's a number). If key not found it is equivalent to set.
|
||||
func (t *CacheService) Increment(request *IncrementRequest) (*IncrementResponse, error) {
|
||||
rsp := &IncrementResponse{}
|
||||
return rsp, t.client.Call("cache", "Increment", request, rsp)
|
||||
|
||||
68
examples/cache/README.md
vendored
68
examples/cache/README.md
vendored
@@ -4,34 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Cache/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Decrement
|
||||
|
||||
Decrement a value (if it's a number)
|
||||
|
||||
|
||||
[https://m3o.com/cache/api#Decrement](https://m3o.com/cache/api#Decrement)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// Decrement a value (if it's a number)
|
||||
func DecrementAvalue() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.Decrement(&cache.DecrementRequest{
|
||||
Key: "counter",
|
||||
Value: 2,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Set
|
||||
|
||||
Set an item in the cache. Overwrites any existing value already set.
|
||||
@@ -62,7 +34,7 @@ Value: "bar",
|
||||
```
|
||||
## Get
|
||||
|
||||
Get an item from the cache by key
|
||||
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)
|
||||
@@ -77,7 +49,7 @@ import(
|
||||
"go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// Get an item from the cache by key
|
||||
// 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{
|
||||
@@ -89,7 +61,7 @@ func GetAvalue() {
|
||||
```
|
||||
## Delete
|
||||
|
||||
Delete a value from the cache
|
||||
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)
|
||||
@@ -104,7 +76,7 @@ import(
|
||||
"go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// Delete a value from the 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{
|
||||
@@ -116,7 +88,7 @@ func DeleteAvalue() {
|
||||
```
|
||||
## Increment
|
||||
|
||||
Increment a value (if it's a number)
|
||||
Increment a value (if it's a number). If key not found it is equivalent to set.
|
||||
|
||||
|
||||
[https://m3o.com/cache/api#Increment](https://m3o.com/cache/api#Increment)
|
||||
@@ -131,7 +103,7 @@ import(
|
||||
"go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// Increment a value (if it's a number)
|
||||
// Increment a value (if it's a number). If key not found it is equivalent to set.
|
||||
func IncrementAvalue() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.Increment(&cache.IncrementRequest{
|
||||
@@ -142,3 +114,31 @@ Value: 2,
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Decrement
|
||||
|
||||
Decrement a value (if it's a number). If key not found it is equivalent to set.
|
||||
|
||||
|
||||
[https://m3o.com/cache/api#Decrement](https://m3o.com/cache/api#Decrement)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// Decrement a value (if it's a number). If key not found it is equivalent to set.
|
||||
func DecrementAvalue() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.Decrement(&cache.DecrementRequest{
|
||||
Key: "counter",
|
||||
Value: 2,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
|
||||
2
examples/cache/decrement/decrementAValue.go
vendored
2
examples/cache/decrement/decrementAValue.go
vendored
@@ -7,7 +7,7 @@ import (
|
||||
"go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// Decrement a value (if it's a number)
|
||||
// Decrement a value (if it's a number). If key not found it is equivalent to set.
|
||||
func DecrementAvalue() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.Decrement(&cache.DecrementRequest{
|
||||
|
||||
2
examples/cache/delete/deleteAValue.go
vendored
2
examples/cache/delete/deleteAValue.go
vendored
@@ -7,7 +7,7 @@ import (
|
||||
"go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// Delete a value from the 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{
|
||||
|
||||
2
examples/cache/get/getAValue.go
vendored
2
examples/cache/get/getAValue.go
vendored
@@ -7,7 +7,7 @@ import (
|
||||
"go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// Get an item from the cache by key
|
||||
// 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{
|
||||
|
||||
2
examples/cache/increment/incrementAValue.go
vendored
2
examples/cache/increment/incrementAValue.go
vendored
@@ -7,7 +7,7 @@ import (
|
||||
"go.m3o.com/cache"
|
||||
)
|
||||
|
||||
// Increment a value (if it's a number)
|
||||
// Increment a value (if it's a number). If key not found it is equivalent to set.
|
||||
func IncrementAvalue() {
|
||||
cacheService := cache.NewCacheService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := cacheService.Increment(&cache.IncrementRequest{
|
||||
|
||||
@@ -4,6 +4,88 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Db/api](https:
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Delete
|
||||
|
||||
Delete a record in the database by id.
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Delete a record in the database by id.
|
||||
func DeleteArecord() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Delete(&db.DeleteRequest{
|
||||
Id: "1",
|
||||
Table: "users",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## 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 a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||
@@ -96,85 +178,3 @@ Table: "users",
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
|
||||
Delete a record in the database by id.
|
||||
|
||||
|
||||
[https://m3o.com/db/api#Delete](https://m3o.com/db/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/db"
|
||||
)
|
||||
|
||||
// Delete a record in the database by id.
|
||||
func DeleteArecord() {
|
||||
dbService := db.NewDbService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := dbService.Delete(&db.DeleteRequest{
|
||||
Id: "1",
|
||||
Table: "users",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
}
|
||||
```
|
||||
|
||||
@@ -12,9 +12,9 @@ func PublishAnEvent() {
|
||||
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := eventService.Publish(&event.PublishRequest{
|
||||
Message: map[string]interface{}{
|
||||
"user": "john",
|
||||
"id": "1",
|
||||
"type": "signup",
|
||||
"user": "john",
|
||||
},
|
||||
Topic: "user",
|
||||
})
|
||||
|
||||
@@ -4,62 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/File/api](http
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Delete
|
||||
|
||||
Delete a file by project name/path
|
||||
|
||||
|
||||
[https://m3o.com/file/api#Delete](https://m3o.com/file/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/file"
|
||||
)
|
||||
|
||||
// Delete a file by project name/path
|
||||
func DeleteFile() {
|
||||
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := fileService.Delete(&file.DeleteRequest{
|
||||
Path: "/document/text-files/file.txt",
|
||||
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)
|
||||
}
|
||||
```
|
||||
## Save
|
||||
|
||||
Save a file
|
||||
@@ -118,3 +62,59 @@ func ListFiles() {
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
|
||||
Delete a file by project name/path
|
||||
|
||||
|
||||
[https://m3o.com/file/api#Delete](https://m3o.com/file/api#Delete)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/file"
|
||||
)
|
||||
|
||||
// Delete a file by project name/path
|
||||
func DeleteFile() {
|
||||
fileService := file.NewFileService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := fileService.Delete(&file.DeleteRequest{
|
||||
Path: "/document/text-files/file.txt",
|
||||
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,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Helloworld/api
|
||||
|
||||
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 returns a stream of "Hello $name" responses
|
||||
@@ -58,3 +31,30 @@ func StreamsAreCurrentlyTemporarilyNotSupportedInClients() {
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## 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)
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,41 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Location/api](
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Save
|
||||
|
||||
Save an entity's current position
|
||||
|
||||
|
||||
[https://m3o.com/location/api#Save](https://m3o.com/location/api#Save)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/location"
|
||||
)
|
||||
|
||||
// Save an entity's current position
|
||||
func SaveAnEntity() {
|
||||
locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := locationService.Save(&location.SaveRequest{
|
||||
Entity: &location.Entity{
|
||||
Id: "1",
|
||||
Location: &location.Point{
|
||||
Latitude: 51.511061,
|
||||
Longitude: -0.120022,
|
||||
Timestamp: 1622802761,
|
||||
},
|
||||
Type: "bike",
|
||||
},
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Read
|
||||
|
||||
Read an entity by its ID
|
||||
@@ -99,3 +64,38 @@ Type: "bike",
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Save
|
||||
|
||||
Save an entity's current position
|
||||
|
||||
|
||||
[https://m3o.com/location/api#Save](https://m3o.com/location/api#Save)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/location"
|
||||
)
|
||||
|
||||
// Save an entity's current position
|
||||
func SaveAnEntity() {
|
||||
locationService := location.NewLocationService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := locationService.Save(&location.SaveRequest{
|
||||
Entity: &location.Entity{
|
||||
Id: "1",
|
||||
Location: &location.Point{
|
||||
Latitude: 51.511061,
|
||||
Longitude: -0.120022,
|
||||
Timestamp: 1622802761,
|
||||
},
|
||||
Type: "bike",
|
||||
},
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
|
||||
@@ -12,9 +12,9 @@ func PublishAmessage() {
|
||||
mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := mqService.Publish(&mq.PublishRequest{
|
||||
Message: map[string]interface{}{
|
||||
"id": "1",
|
||||
"type": "signup",
|
||||
"user": "john",
|
||||
"id": "1",
|
||||
},
|
||||
Topic: "events",
|
||||
})
|
||||
|
||||
@@ -4,40 +4,6 @@ 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
|
||||
@@ -106,3 +72,37 @@ 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,33 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Stock/api](htt
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Price
|
||||
|
||||
Get the last price for a given stock ticker
|
||||
|
||||
|
||||
[https://m3o.com/stock/api#Price](https://m3o.com/stock/api#Price)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/stock"
|
||||
)
|
||||
|
||||
// Get the last price for a given stock ticker
|
||||
func GetAstockPrice() {
|
||||
stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := stockService.Price(&stock.PriceRequest{
|
||||
Symbol: "AAPL",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Quote
|
||||
|
||||
Get the last quote for the stock
|
||||
@@ -117,3 +90,30 @@ Stock: "AAPL",
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Price
|
||||
|
||||
Get the last price for a given stock ticker
|
||||
|
||||
|
||||
[https://m3o.com/stock/api#Price](https://m3o.com/stock/api#Price)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/stock"
|
||||
)
|
||||
|
||||
// Get the last price for a given stock ticker
|
||||
func GetAstockPrice() {
|
||||
stockService := stock.NewStockService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := stockService.Price(&stock.PriceRequest{
|
||||
Symbol: "AAPL",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,12 +4,12 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Stream/api](ht
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Publish
|
||||
## SendMessage
|
||||
|
||||
Publish a message to the stream. Specify a topic to group messages for a specific topic.
|
||||
SendMessage a message to the stream.
|
||||
|
||||
|
||||
[https://m3o.com/stream/api#Publish](https://m3o.com/stream/api#Publish)
|
||||
[https://m3o.com/stream/api#SendMessage](https://m3o.com/stream/api#SendMessage)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -21,27 +21,23 @@ import(
|
||||
"go.m3o.com/stream"
|
||||
)
|
||||
|
||||
// Publish a message to the stream. Specify a topic to group messages for a specific topic.
|
||||
func PublishAmessage() {
|
||||
// SendMessage a message to the stream.
|
||||
func SendAmessage() {
|
||||
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := streamService.Publish(&stream.PublishRequest{
|
||||
Message: map[string]interface{}{
|
||||
"user": "john",
|
||||
"id": "1",
|
||||
"type": "signup",
|
||||
},
|
||||
Topic: "events",
|
||||
rsp, err := streamService.SendMessage(&stream.SendMessageRequest{
|
||||
Channel: "general",
|
||||
Text: "Hey checkout this tweet https://twitter.com/m3oservices/status/1455291054295498752",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Subscribe
|
||||
## ListMessages
|
||||
|
||||
Subscribe to messages for a given topic.
|
||||
List messages for a given channel
|
||||
|
||||
|
||||
[https://m3o.com/stream/api#Subscribe](https://m3o.com/stream/api#Subscribe)
|
||||
[https://m3o.com/stream/api#ListMessages](https://m3o.com/stream/api#ListMessages)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -53,13 +49,39 @@ import(
|
||||
"go.m3o.com/stream"
|
||||
)
|
||||
|
||||
// Subscribe to messages for a given topic.
|
||||
func SubscribeToAtopic() {
|
||||
// List messages for a given channel
|
||||
func ListMessages() {
|
||||
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := streamService.Subscribe(&stream.SubscribeRequest{
|
||||
Topic: "events",
|
||||
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)
|
||||
}
|
||||
```
|
||||
|
||||
15
examples/stream/listChannels/listChannels.go
Executable file
15
examples/stream/listChannels/listChannels.go
Executable file
@@ -0,0 +1,15 @@
|
||||
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)
|
||||
}
|
||||
17
examples/stream/listMessages/listMessages.go
Executable file
17
examples/stream/listMessages/listMessages.go
Executable file
@@ -0,0 +1,17 @@
|
||||
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)
|
||||
}
|
||||
18
examples/stream/sendMessage/sendAMessage.go
Executable file
18
examples/stream/sendMessage/sendAMessage.go
Executable file
@@ -0,0 +1,18 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/stream"
|
||||
)
|
||||
|
||||
// SendMessage a message to the stream.
|
||||
func SendAmessage() {
|
||||
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := streamService.SendMessage(&stream.SendMessageRequest{
|
||||
Channel: "general",
|
||||
Text: "Hey checkout this tweet https://twitter.com/m3oservices/status/1455291054295498752",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
@@ -4,6 +4,36 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/User/api](http
|
||||
|
||||
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: "usrid-1",
|
||||
Password: "mySecretPass123",
|
||||
Username: "usrname-1",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Update
|
||||
|
||||
Update the account username or email
|
||||
@@ -32,12 +62,18 @@ Id: "usrid-1",
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## UpdatePassword
|
||||
## SendVerificationEmail
|
||||
|
||||
Update the account password
|
||||
Send a verification email
|
||||
to the user being signed up. Email from will be from 'support@m3o.com',
|
||||
but you can provide the title and contents.
|
||||
The verification link will be injected in to the email as a template variable, $micro_verification_link.
|
||||
Example: 'Hi there, welcome onboard! Use the link below to verify your email: $micro_verification_link'
|
||||
The variable will be replaced with an actual url that will look similar to this:
|
||||
'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url'
|
||||
|
||||
|
||||
[https://m3o.com/user/api#UpdatePassword](https://m3o.com/user/api#UpdatePassword)
|
||||
[https://m3o.com/user/api#SendVerificationEmail](https://m3o.com/user/api#SendVerificationEmail)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -49,13 +85,51 @@ import(
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Update the account password
|
||||
func UpdateTheAccountPassword() {
|
||||
// Send a verification email
|
||||
// to the user being signed up. Email from will be from 'support@m3o.com',
|
||||
// but you can provide the title and contents.
|
||||
// The verification link will be injected in to the email as a template variable, $micro_verification_link.
|
||||
// Example: 'Hi there, welcome onboard! Use the link below to verify your email: $micro_verification_link'
|
||||
// The variable will be replaced with an actual url that will look similar to this:
|
||||
// 'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url'
|
||||
func SendVerificationEmail() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.UpdatePassword(&user.UpdatePasswordRequest{
|
||||
ConfirmPassword: "myEvenMoreSecretPass123",
|
||||
NewPassword: "myEvenMoreSecretPass123",
|
||||
OldPassword: "mySecretPass123",
|
||||
rsp, err := userService.SendVerificationEmail(&user.SendVerificationEmailRequest{
|
||||
Email: "joe@example.com",
|
||||
FailureRedirectUrl: "https://m3o.com/verification-failed",
|
||||
FromName: "Awesome Dot Com",
|
||||
RedirectUrl: "https://m3o.com",
|
||||
Subject: "Email verification",
|
||||
TextContent: `Hi there,
|
||||
|
||||
Please verify your email by clicking this link: $micro_verification_link`,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## 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: "t2323t232t",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
@@ -91,12 +165,12 @@ Password: "mySecretPass123",
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Create
|
||||
## UpdatePassword
|
||||
|
||||
Create a new user account. The email address and username for the account must be unique.
|
||||
Update the account password
|
||||
|
||||
|
||||
[https://m3o.com/user/api#Create](https://m3o.com/user/api#Create)
|
||||
[https://m3o.com/user/api#UpdatePassword](https://m3o.com/user/api#UpdatePassword)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -108,14 +182,13 @@ import(
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Create a new user account. The email address and username for the account must be unique.
|
||||
func CreateAnAccount() {
|
||||
// Update the account password
|
||||
func UpdateTheAccountPassword() {
|
||||
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",
|
||||
rsp, err := userService.UpdatePassword(&user.UpdatePasswordRequest{
|
||||
ConfirmPassword: "myEvenMoreSecretPass123",
|
||||
NewPassword: "myEvenMoreSecretPass123",
|
||||
OldPassword: "mySecretPass123",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
@@ -202,79 +275,6 @@ func ReadAccountByEmail() {
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## SendVerificationEmail
|
||||
|
||||
Send a verification email
|
||||
to the user being signed up. Email from will be from 'support@m3o.com',
|
||||
but you can provide the title and contents.
|
||||
The verification link will be injected in to the email as a template variable, $micro_verification_link.
|
||||
Example: 'Hi there, welcome onboard! Use the link below to verify your email: $micro_verification_link'
|
||||
The variable will be replaced with an actual url that will look similar to this:
|
||||
'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url'
|
||||
|
||||
|
||||
[https://m3o.com/user/api#SendVerificationEmail](https://m3o.com/user/api#SendVerificationEmail)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/user"
|
||||
)
|
||||
|
||||
// Send a verification email
|
||||
// to the user being signed up. Email from will be from 'support@m3o.com',
|
||||
// but you can provide the title and contents.
|
||||
// The verification link will be injected in to the email as a template variable, $micro_verification_link.
|
||||
// Example: 'Hi there, welcome onboard! Use the link below to verify your email: $micro_verification_link'
|
||||
// The variable will be replaced with an actual url that will look similar to this:
|
||||
// 'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url'
|
||||
func SendVerificationEmail() {
|
||||
userService := user.NewUserService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := userService.SendVerificationEmail(&user.SendVerificationEmailRequest{
|
||||
Email: "joe@example.com",
|
||||
FailureRedirectUrl: "https://m3o.com/verification-failed",
|
||||
FromName: "Awesome Dot Com",
|
||||
RedirectUrl: "https://m3o.com",
|
||||
Subject: "Email verification",
|
||||
TextContent: `Hi there,
|
||||
|
||||
Please verify your email by clicking this link: $micro_verification_link`,
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## 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: "t2323t232t",
|
||||
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Delete
|
||||
|
||||
Delete an account by id
|
||||
|
||||
133
m3o.go
133
m3o.go
@@ -1,19 +1,148 @@
|
||||
package m3o
|
||||
|
||||
import (
|
||||
"go.m3o.com/address"
|
||||
"go.m3o.com/answer"
|
||||
"go.m3o.com/cache"
|
||||
"go.m3o.com/crypto"
|
||||
"go.m3o.com/currency"
|
||||
"go.m3o.com/db"
|
||||
"go.m3o.com/email"
|
||||
"go.m3o.com/emoji"
|
||||
"go.m3o.com/evchargers"
|
||||
"go.m3o.com/event"
|
||||
"go.m3o.com/file"
|
||||
"go.m3o.com/forex"
|
||||
"go.m3o.com/function"
|
||||
"go.m3o.com/geocoding"
|
||||
"go.m3o.com/gifs"
|
||||
"go.m3o.com/google"
|
||||
"go.m3o.com/helloworld"
|
||||
"go.m3o.com/holidays"
|
||||
"go.m3o.com/id"
|
||||
"go.m3o.com/image"
|
||||
"go.m3o.com/ip"
|
||||
"go.m3o.com/location"
|
||||
"go.m3o.com/mq"
|
||||
"go.m3o.com/notes"
|
||||
"go.m3o.com/otp"
|
||||
"go.m3o.com/postcode"
|
||||
"go.m3o.com/prayer"
|
||||
"go.m3o.com/qr"
|
||||
"go.m3o.com/quran"
|
||||
"go.m3o.com/routing"
|
||||
"go.m3o.com/rss"
|
||||
"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"
|
||||
"go.m3o.com/twitter"
|
||||
"go.m3o.com/url"
|
||||
"go.m3o.com/user"
|
||||
"go.m3o.com/vehicle"
|
||||
"go.m3o.com/weather"
|
||||
"go.m3o.com/youtube"
|
||||
)
|
||||
|
||||
func NewClient(token string) *Client {
|
||||
return &Client{
|
||||
token: token,
|
||||
|
||||
NotesService: notes.NewNotesService(token),
|
||||
AddressService: address.NewAddressService(token),
|
||||
AnswerService: answer.NewAnswerService(token),
|
||||
CacheService: cache.NewCacheService(token),
|
||||
CryptoService: crypto.NewCryptoService(token),
|
||||
CurrencyService: currency.NewCurrencyService(token),
|
||||
DbService: db.NewDbService(token),
|
||||
EmailService: email.NewEmailService(token),
|
||||
EmojiService: emoji.NewEmojiService(token),
|
||||
EvchargersService: evchargers.NewEvchargersService(token),
|
||||
EventService: event.NewEventService(token),
|
||||
FileService: file.NewFileService(token),
|
||||
ForexService: forex.NewForexService(token),
|
||||
FunctionService: function.NewFunctionService(token),
|
||||
GeocodingService: geocoding.NewGeocodingService(token),
|
||||
GifsService: gifs.NewGifsService(token),
|
||||
GoogleService: google.NewGoogleService(token),
|
||||
HelloworldService: helloworld.NewHelloworldService(token),
|
||||
HolidaysService: holidays.NewHolidaysService(token),
|
||||
IdService: id.NewIdService(token),
|
||||
ImageService: image.NewImageService(token),
|
||||
IpService: ip.NewIpService(token),
|
||||
LocationService: location.NewLocationService(token),
|
||||
MqService: mq.NewMqService(token),
|
||||
NotesService: notes.NewNotesService(token),
|
||||
OtpService: otp.NewOtpService(token),
|
||||
PostcodeService: postcode.NewPostcodeService(token),
|
||||
PrayerService: prayer.NewPrayerService(token),
|
||||
QrService: qr.NewQrService(token),
|
||||
QuranService: quran.NewQuranService(token),
|
||||
RoutingService: routing.NewRoutingService(token),
|
||||
RssService: rss.NewRssService(token),
|
||||
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),
|
||||
TwitterService: twitter.NewTwitterService(token),
|
||||
UrlService: url.NewUrlService(token),
|
||||
UserService: user.NewUserService(token),
|
||||
VehicleService: vehicle.NewVehicleService(token),
|
||||
WeatherService: weather.NewWeatherService(token),
|
||||
YoutubeService: youtube.NewYoutubeService(token),
|
||||
}
|
||||
}
|
||||
|
||||
type Client struct {
|
||||
token string
|
||||
|
||||
NotesService *notes.NotesService
|
||||
AddressService *address.AddressService
|
||||
AnswerService *answer.AnswerService
|
||||
CacheService *cache.CacheService
|
||||
CryptoService *crypto.CryptoService
|
||||
CurrencyService *currency.CurrencyService
|
||||
DbService *db.DbService
|
||||
EmailService *email.EmailService
|
||||
EmojiService *emoji.EmojiService
|
||||
EvchargersService *evchargers.EvchargersService
|
||||
EventService *event.EventService
|
||||
FileService *file.FileService
|
||||
ForexService *forex.ForexService
|
||||
FunctionService *function.FunctionService
|
||||
GeocodingService *geocoding.GeocodingService
|
||||
GifsService *gifs.GifsService
|
||||
GoogleService *google.GoogleService
|
||||
HelloworldService *helloworld.HelloworldService
|
||||
HolidaysService *holidays.HolidaysService
|
||||
IdService *id.IdService
|
||||
ImageService *image.ImageService
|
||||
IpService *ip.IpService
|
||||
LocationService *location.LocationService
|
||||
MqService *mq.MqService
|
||||
NotesService *notes.NotesService
|
||||
OtpService *otp.OtpService
|
||||
PostcodeService *postcode.PostcodeService
|
||||
PrayerService *prayer.PrayerService
|
||||
QrService *qr.QrService
|
||||
QuranService *quran.QuranService
|
||||
RoutingService *routing.RoutingService
|
||||
RssService *rss.RssService
|
||||
SentimentService *sentiment.SentimentService
|
||||
SmsService *sms.SmsService
|
||||
StockService *stock.StockService
|
||||
StreamService *stream.StreamService
|
||||
SunnahService *sunnah.SunnahService
|
||||
ThumbnailService *thumbnail.ThumbnailService
|
||||
TimeService *time.TimeService
|
||||
TwitterService *twitter.TwitterService
|
||||
UrlService *url.UrlService
|
||||
UserService *user.UserService
|
||||
VehicleService *vehicle.VehicleService
|
||||
WeatherService *weather.WeatherService
|
||||
YoutubeService *youtube.YoutubeService
|
||||
}
|
||||
|
||||
@@ -18,66 +18,38 @@ type NotesService struct {
|
||||
|
||||
// Create a new note
|
||||
func (t *NotesService) Create(request *CreateRequest) (*CreateResponse, error) {
|
||||
|
||||
rsp := &CreateResponse{}
|
||||
return rsp, t.client.Call("notes", "Create", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Delete a note
|
||||
func (t *NotesService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
||||
|
||||
rsp := &DeleteResponse{}
|
||||
return rsp, t.client.Call("notes", "Delete", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Subscribe to notes events
|
||||
func (t *NotesService) Events(request *EventsRequest) (*EventsResponseStream, error) {
|
||||
stream, err := t.client.Stream("notes", "Events", request)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &EventsResponseStream{
|
||||
stream: stream,
|
||||
}, nil
|
||||
|
||||
}
|
||||
|
||||
type EventsResponseStream struct {
|
||||
stream *client.Stream
|
||||
}
|
||||
|
||||
func (t *EventsResponseStream) Recv() (*EventsResponse, error) {
|
||||
var rsp EventsResponse
|
||||
if err := t.stream.Recv(&rsp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &rsp, nil
|
||||
func (t *NotesService) Events(request *EventsRequest) (*EventsResponse, error) {
|
||||
rsp := &EventsResponse{}
|
||||
return rsp, t.client.Call("notes", "Events", request, rsp)
|
||||
}
|
||||
|
||||
// List all the notes
|
||||
func (t *NotesService) List(request *ListRequest) (*ListResponse, error) {
|
||||
|
||||
rsp := &ListResponse{}
|
||||
return rsp, t.client.Call("notes", "List", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Read a note
|
||||
func (t *NotesService) Read(request *ReadRequest) (*ReadResponse, error) {
|
||||
|
||||
rsp := &ReadResponse{}
|
||||
return rsp, t.client.Call("notes", "Read", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Update a note
|
||||
func (t *NotesService) Update(request *UpdateRequest) (*UpdateResponse, error) {
|
||||
|
||||
rsp := &UpdateResponse{}
|
||||
return rsp, t.client.Call("notes", "Update", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type CreateRequest struct {
|
||||
|
||||
@@ -16,36 +16,71 @@ type StreamService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Publish a message to the stream. Specify a topic to group messages for a specific topic.
|
||||
func (t *StreamService) Publish(request *PublishRequest) (*PublishResponse, error) {
|
||||
rsp := &PublishResponse{}
|
||||
return rsp, t.client.Call("stream", "Publish", request, rsp)
|
||||
// List all the active channels
|
||||
func (t *StreamService) ListChannels(request *ListChannelsRequest) (*ListChannelsResponse, error) {
|
||||
rsp := &ListChannelsResponse{}
|
||||
return rsp, t.client.Call("stream", "ListChannels", request, rsp)
|
||||
}
|
||||
|
||||
// Subscribe to messages for a given topic.
|
||||
func (t *StreamService) Subscribe(request *SubscribeRequest) (*SubscribeResponse, error) {
|
||||
rsp := &SubscribeResponse{}
|
||||
return rsp, t.client.Call("stream", "Subscribe", request, rsp)
|
||||
// List messages for a given channel
|
||||
func (t *StreamService) ListMessages(request *ListMessagesRequest) (*ListMessagesResponse, error) {
|
||||
rsp := &ListMessagesResponse{}
|
||||
return rsp, t.client.Call("stream", "ListMessages", request, rsp)
|
||||
}
|
||||
|
||||
type PublishRequest struct {
|
||||
// The json message to publish
|
||||
Message map[string]interface{} `json:"message"`
|
||||
// The topic to publish to
|
||||
Topic string `json:"topic"`
|
||||
// SendMessage a message to the stream.
|
||||
func (t *StreamService) SendMessage(request *SendMessageRequest) (*SendMessageResponse, error) {
|
||||
rsp := &SendMessageResponse{}
|
||||
return rsp, t.client.Call("stream", "SendMessage", request, rsp)
|
||||
}
|
||||
|
||||
type PublishResponse struct {
|
||||
type Channel struct {
|
||||
// last activity time
|
||||
LastActive string `json:"lastActive"`
|
||||
// name of the channel
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type SubscribeRequest struct {
|
||||
// The topic to subscribe to
|
||||
Topic string `json:"topic"`
|
||||
type ListChannelsRequest struct {
|
||||
}
|
||||
|
||||
type SubscribeResponse struct {
|
||||
// The next json message on the topic
|
||||
Message map[string]interface{} `json:"message"`
|
||||
// The topic subscribed to
|
||||
Topic string `json:"topic"`
|
||||
type ListChannelsResponse struct {
|
||||
Channels []Channel `json:"channels"`
|
||||
}
|
||||
|
||||
type ListMessagesRequest struct {
|
||||
// The channel to subscribe to
|
||||
Channel string `json:"channel"`
|
||||
// number of message to return
|
||||
Limit int32 `json:"limit"`
|
||||
}
|
||||
|
||||
type ListMessagesResponse struct {
|
||||
// The channel subscribed to
|
||||
Channel string `json:"channel"`
|
||||
// Messages are chronological order
|
||||
Messages []Message `json:"messages"`
|
||||
}
|
||||
|
||||
type Message struct {
|
||||
// the channel name
|
||||
Channel string `json:"channel"`
|
||||
// id of the message
|
||||
Id string `json:"id"`
|
||||
// the associated metadata
|
||||
Metadata map[string]string `json:"metadata"`
|
||||
// text of the message
|
||||
Text string `json:"text"`
|
||||
// time of message creation
|
||||
Timestamp string `json:"timestamp"`
|
||||
}
|
||||
|
||||
type SendMessageRequest struct {
|
||||
// The channel to send to
|
||||
Channel string `json:"channel"`
|
||||
// The message text to send
|
||||
Text string `json:"text"`
|
||||
}
|
||||
|
||||
type SendMessageResponse struct {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user