mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-22 15:25:19 +00:00
add notes (#218)
* add notes * fix build * Commit from GitHub Actions (Publish APIs & Clients) Co-authored-by: asim <asim@users.noreply.github.com>
This commit is contained in:
@@ -18,6 +18,7 @@ import (
|
||||
"github.com/micro/services/clients/go/image"
|
||||
"github.com/micro/services/clients/go/ip"
|
||||
"github.com/micro/services/clients/go/location"
|
||||
"github.com/micro/services/clients/go/notes"
|
||||
"github.com/micro/services/clients/go/otp"
|
||||
"github.com/micro/services/clients/go/postcode"
|
||||
"github.com/micro/services/clients/go/prayer"
|
||||
@@ -59,6 +60,7 @@ func NewClient(token string) *Client {
|
||||
ImageService: image.NewImageService(token),
|
||||
IpService: ip.NewIpService(token),
|
||||
LocationService: location.NewLocationService(token),
|
||||
NotesService: notes.NewNotesService(token),
|
||||
OtpService: otp.NewOtpService(token),
|
||||
PostcodeService: postcode.NewPostcodeService(token),
|
||||
PrayerService: prayer.NewPrayerService(token),
|
||||
@@ -100,6 +102,7 @@ type Client struct {
|
||||
ImageService *image.ImageService
|
||||
IpService *ip.IpService
|
||||
LocationService *location.LocationService
|
||||
NotesService *notes.NotesService
|
||||
OtpService *otp.OtpService
|
||||
PostcodeService *postcode.PostcodeService
|
||||
PrayerService *prayer.PrayerService
|
||||
|
||||
125
clients/go/notes/notes.go
Executable file
125
clients/go/notes/notes.go
Executable file
@@ -0,0 +1,125 @@
|
||||
package notes
|
||||
|
||||
import (
|
||||
"github.com/m3o/m3o-go/client"
|
||||
)
|
||||
|
||||
func NewNotesService(token string) *NotesService {
|
||||
return &NotesService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type NotesService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
// 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
|
||||
func (t *NotesService) Update(request *UpdateRequest) (*UpdateResponse, error) {
|
||||
rsp := &UpdateResponse{}
|
||||
return rsp, t.client.Call("notes", "Update", request, rsp)
|
||||
}
|
||||
|
||||
type CreateRequest struct {
|
||||
// note text
|
||||
Text string `json:"text"`
|
||||
// note title
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
type CreateResponse struct {
|
||||
// The created note
|
||||
Note *Note `json:"note"`
|
||||
}
|
||||
|
||||
type DeleteRequest struct {
|
||||
// specify the id of the note
|
||||
Id string `json:"id"`
|
||||
}
|
||||
|
||||
type DeleteResponse struct {
|
||||
Note *Note `json:"note"`
|
||||
}
|
||||
|
||||
type ListRequest struct {
|
||||
}
|
||||
|
||||
type ListResponse struct {
|
||||
// the list of notes
|
||||
Notes []Note `json:"notes"`
|
||||
}
|
||||
|
||||
type Note struct {
|
||||
// time at which the note was created
|
||||
Created string `json:"created"`
|
||||
// unique id for the note, generated if not specified
|
||||
Id string `json:"id"`
|
||||
// text within the note
|
||||
Text string `json:"text"`
|
||||
// title of the note
|
||||
Title string `json:"title"`
|
||||
// time at which the note was updated
|
||||
Updated string `json:"updated"`
|
||||
}
|
||||
|
||||
type ReadRequest struct {
|
||||
// the note id
|
||||
Id string `json:"id"`
|
||||
}
|
||||
|
||||
type ReadResponse struct {
|
||||
// The note
|
||||
Note *Note `json:"note"`
|
||||
}
|
||||
|
||||
type SubscribeRequest struct {
|
||||
// optionally specify a note id
|
||||
Id string `json:"id"`
|
||||
}
|
||||
|
||||
type SubscribeResponse struct {
|
||||
// the event which occured; created, deleted, updated
|
||||
Event string `json:"event"`
|
||||
// the note which the operation occured on
|
||||
Note *Note `json:"note"`
|
||||
}
|
||||
|
||||
type UpdateRequest struct {
|
||||
Note *Note `json:"note"`
|
||||
}
|
||||
|
||||
type UpdateResponse struct {
|
||||
Note *Note `json:"note"`
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import * as id from "./id";
|
||||
import * as image from "./image";
|
||||
import * as ip from "./ip";
|
||||
import * as location from "./location";
|
||||
import * as notes from "./notes";
|
||||
import * as otp from "./otp";
|
||||
import * as postcode from "./postcode";
|
||||
import * as prayer from "./prayer";
|
||||
@@ -53,6 +54,7 @@ export class Client {
|
||||
this.imageService = new image.ImageService(token);
|
||||
this.ipService = new ip.IpService(token);
|
||||
this.locationService = new location.LocationService(token);
|
||||
this.notesService = new notes.NotesService(token);
|
||||
this.otpService = new otp.OtpService(token);
|
||||
this.postcodeService = new postcode.PostcodeService(token);
|
||||
this.prayerService = new prayer.PrayerService(token);
|
||||
@@ -90,6 +92,7 @@ export class Client {
|
||||
imageService: image.ImageService;
|
||||
ipService: ip.IpService;
|
||||
locationService: location.LocationService;
|
||||
notesService: notes.NotesService;
|
||||
otpService: otp.OtpService;
|
||||
postcodeService: postcode.PostcodeService;
|
||||
prayerService: prayer.PrayerService;
|
||||
|
||||
120
clients/ts/notes/index.ts
Executable file
120
clients/ts/notes/index.ts
Executable file
@@ -0,0 +1,120 @@
|
||||
import * as m3o from "@m3o/m3o-node";
|
||||
|
||||
export class NotesService {
|
||||
private client: m3o.Client;
|
||||
|
||||
constructor(token: string) {
|
||||
this.client = new m3o.Client({ token: token });
|
||||
}
|
||||
// Create a new note
|
||||
create(request: CreateRequest): Promise<CreateResponse> {
|
||||
return this.client.call(
|
||||
"notes",
|
||||
"Create",
|
||||
request
|
||||
) as Promise<CreateResponse>;
|
||||
}
|
||||
// Delete a note
|
||||
delete(request: DeleteRequest): Promise<DeleteResponse> {
|
||||
return this.client.call(
|
||||
"notes",
|
||||
"Delete",
|
||||
request
|
||||
) as Promise<DeleteResponse>;
|
||||
}
|
||||
// List all the notes
|
||||
list(request: ListRequest): Promise<ListResponse> {
|
||||
return this.client.call("notes", "List", request) as Promise<ListResponse>;
|
||||
}
|
||||
// Read a note
|
||||
read(request: ReadRequest): Promise<ReadResponse> {
|
||||
return this.client.call("notes", "Read", request) as Promise<ReadResponse>;
|
||||
}
|
||||
// Specify the note to events
|
||||
subscribe(request: SubscribeRequest): Promise<SubscribeResponse> {
|
||||
return this.client.call(
|
||||
"notes",
|
||||
"Subscribe",
|
||||
request
|
||||
) as Promise<SubscribeResponse>;
|
||||
}
|
||||
// Update a note
|
||||
update(request: UpdateRequest): Promise<UpdateResponse> {
|
||||
return this.client.call(
|
||||
"notes",
|
||||
"Update",
|
||||
request
|
||||
) as Promise<UpdateResponse>;
|
||||
}
|
||||
}
|
||||
|
||||
export interface CreateRequest {
|
||||
// note text
|
||||
text?: string;
|
||||
// note title
|
||||
title?: string;
|
||||
}
|
||||
|
||||
export interface CreateResponse {
|
||||
// The created note
|
||||
note?: { [key: string]: any };
|
||||
}
|
||||
|
||||
export interface DeleteRequest {
|
||||
// specify the id of the note
|
||||
id?: string;
|
||||
}
|
||||
|
||||
export interface DeleteResponse {
|
||||
note?: { [key: string]: any };
|
||||
}
|
||||
|
||||
export interface ListRequest {}
|
||||
|
||||
export interface ListResponse {
|
||||
// the list of notes
|
||||
notes?: Note[];
|
||||
}
|
||||
|
||||
export interface Note {
|
||||
// time at which the note was created
|
||||
created?: string;
|
||||
// unique id for the note, generated if not specified
|
||||
id?: string;
|
||||
// text within the note
|
||||
text?: string;
|
||||
// title of the note
|
||||
title?: string;
|
||||
// time at which the note was updated
|
||||
updated?: string;
|
||||
}
|
||||
|
||||
export interface ReadRequest {
|
||||
// the note id
|
||||
id?: string;
|
||||
}
|
||||
|
||||
export interface ReadResponse {
|
||||
// The note
|
||||
note?: { [key: string]: any };
|
||||
}
|
||||
|
||||
export interface SubscribeRequest {
|
||||
// optionally specify a note id
|
||||
id?: string;
|
||||
}
|
||||
|
||||
export interface SubscribeResponse {
|
||||
// the event which occured; created, deleted, updated
|
||||
event?: string;
|
||||
// the note which the operation occured on
|
||||
note?: { [key: string]: any };
|
||||
}
|
||||
|
||||
export interface UpdateRequest {
|
||||
note?: { [key: string]: any };
|
||||
}
|
||||
|
||||
export interface UpdateResponse {
|
||||
note?: { [key: string]: any };
|
||||
}
|
||||
@@ -26,6 +26,7 @@
|
||||
"./image": "./dist/image/index.js",
|
||||
"./ip": "./dist/ip/index.js",
|
||||
"./location": "./dist/location/index.js",
|
||||
"./notes": "./dist/notes/index.js",
|
||||
"./otp": "./dist/otp/index.js",
|
||||
"./pkg": "./dist/pkg/index.js",
|
||||
"./postcode": "./dist/postcode/index.js",
|
||||
@@ -61,5 +62,5 @@
|
||||
},
|
||||
"type": "module",
|
||||
"types": "dist/index.d.ts",
|
||||
"version": "1.0.530"
|
||||
"version": "1.0.531"
|
||||
}
|
||||
Reference in New Issue
Block a user