mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-23 07:41:25 +00:00
Commit from GitHub Actions (Generate Clients & Examples)
This commit is contained in:
@@ -28,6 +28,12 @@ func (t *NotesService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
|||||||
return rsp, t.client.Call("notes", "Delete", request, rsp)
|
return rsp, t.client.Call("notes", "Delete", request, rsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Specify the note to events
|
||||||
|
func (t *NotesService) Events(request *EventsRequest) (*EventsResponse, error) {
|
||||||
|
rsp := &EventsResponse{}
|
||||||
|
return rsp, t.client.Call("notes", "Events", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
// List all the notes
|
// List all the notes
|
||||||
func (t *NotesService) List(request *ListRequest) (*ListResponse, error) {
|
func (t *NotesService) List(request *ListRequest) (*ListResponse, error) {
|
||||||
rsp := &ListResponse{}
|
rsp := &ListResponse{}
|
||||||
@@ -40,12 +46,6 @@ func (t *NotesService) Read(request *ReadRequest) (*ReadResponse, error) {
|
|||||||
return rsp, t.client.Call("notes", "Read", request, rsp)
|
return rsp, t.client.Call("notes", "Read", request, rsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Specify the note to events
|
|
||||||
func (t *NotesService) Subscribe(request *SubscribeRequest) (*SubscribeResponse, error) {
|
|
||||||
rsp := &SubscribeResponse{}
|
|
||||||
return rsp, t.client.Call("notes", "Subscribe", request, rsp)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update a note
|
// Update a note
|
||||||
func (t *NotesService) Update(request *UpdateRequest) (*UpdateResponse, error) {
|
func (t *NotesService) Update(request *UpdateRequest) (*UpdateResponse, error) {
|
||||||
rsp := &UpdateResponse{}
|
rsp := &UpdateResponse{}
|
||||||
@@ -73,6 +73,18 @@ type DeleteResponse struct {
|
|||||||
Note *Note `json:"note"`
|
Note *Note `json:"note"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type EventsRequest struct {
|
||||||
|
// optionally specify a note id
|
||||||
|
Id string `json:"id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type EventsResponse struct {
|
||||||
|
// the event which occured; create, delete, update
|
||||||
|
Event string `json:"event"`
|
||||||
|
// the note which the operation occured on
|
||||||
|
Note *Note `json:"note"`
|
||||||
|
}
|
||||||
|
|
||||||
type ListRequest struct {
|
type ListRequest struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,18 +116,6 @@ type ReadResponse struct {
|
|||||||
Note *Note `json:"note"`
|
Note *Note `json:"note"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SubscribeRequest struct {
|
|
||||||
// optionally specify a note id
|
|
||||||
Id string `json:"id"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type SubscribeResponse struct {
|
|
||||||
// the event which occured; create, delete, update
|
|
||||||
Event string `json:"event"`
|
|
||||||
// the note which the operation occured on
|
|
||||||
Note *Note `json:"note"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type UpdateRequest struct {
|
type UpdateRequest struct {
|
||||||
Note *Note `json:"note"`
|
Note *Note `json:"note"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,5 +76,5 @@
|
|||||||
"prepare": "npm run build"
|
"prepare": "npm run build"
|
||||||
},
|
},
|
||||||
"types": "index.d.ts",
|
"types": "index.d.ts",
|
||||||
"version": "1.0.594"
|
"version": "1.0.597"
|
||||||
}
|
}
|
||||||
6
examples/notes/events/curl/subscribeToEvents.sh
Executable file
6
examples/notes/events/curl/subscribeToEvents.sh
Executable file
@@ -0,0 +1,6 @@
|
|||||||
|
curl "https://api.m3o.com/v1/notes/Events" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||||
|
-d '{
|
||||||
|
"id": "63c0cdf8-2121-11ec-a881-0242e36f037a"
|
||||||
|
}'
|
||||||
17
examples/notes/events/go/subscribeToEvents.go
Executable file
17
examples/notes/events/go/subscribeToEvents.go
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
package example
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/micro/services/clients/go/notes"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Specify the note to events
|
||||||
|
func SubscribeToEvents() {
|
||||||
|
notesService := notes.NewNotesService(os.Getenv("MICRO_API_TOKEN"))
|
||||||
|
rsp, err := notesService.Events(¬es.EventsRequest{
|
||||||
|
Id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
}
|
||||||
12
examples/notes/events/node/subscribeToEvents.js
Executable file
12
examples/notes/events/node/subscribeToEvents.js
Executable file
@@ -0,0 +1,12 @@
|
|||||||
|
const { NotesService } = require("m3o/notes");
|
||||||
|
|
||||||
|
// Specify the note to events
|
||||||
|
async function subscribeToEvents() {
|
||||||
|
let notesService = new NotesService(process.env.MICRO_API_TOKEN);
|
||||||
|
let rsp = await notesService.events({
|
||||||
|
id: "63c0cdf8-2121-11ec-a881-0242e36f037a",
|
||||||
|
});
|
||||||
|
console.log(rsp);
|
||||||
|
}
|
||||||
|
|
||||||
|
subscribeToEvents();
|
||||||
@@ -12,9 +12,9 @@ func PublishAmessage() {
|
|||||||
streamService := stream.NewStreamService(os.Getenv("MICRO_API_TOKEN"))
|
streamService := stream.NewStreamService(os.Getenv("MICRO_API_TOKEN"))
|
||||||
rsp, err := streamService.Publish(&stream.PublishRequest{
|
rsp, err := streamService.Publish(&stream.PublishRequest{
|
||||||
Message: map[string]interface{}{
|
Message: map[string]interface{}{
|
||||||
"user": "john",
|
|
||||||
"id": "1",
|
"id": "1",
|
||||||
"type": "signup",
|
"type": "signup",
|
||||||
|
"user": "john",
|
||||||
},
|
},
|
||||||
Topic: "events",
|
Topic: "events",
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user