Commit from m3o/m3o action

This commit is contained in:
m3o-actions
2022-02-24 16:11:57 +00:00
parent f478825008
commit a5c68cd8ab
24 changed files with 1208 additions and 1190 deletions

View File

@@ -5,6 +5,7 @@ import (
)
type Chat interface {
Create(*CreateRequest) (*CreateResponse, error)
Delete(*DeleteRequest) (*DeleteResponse, error)
History(*HistoryRequest) (*HistoryResponse, error)
Invite(*InviteRequest) (*InviteResponse, error)
@@ -12,7 +13,6 @@ type Chat interface {
Kick(*KickRequest) (*KickResponse, error)
Leave(*LeaveRequest) (*LeaveResponse, error)
List(*ListRequest) (*ListResponse, error)
New(*NewRequest) (*NewResponse, error)
Send(*SendRequest) (*SendResponse, error)
}
@@ -28,6 +28,14 @@ type ChatService struct {
client *client.Client
}
// Create a new chat room
func (t *ChatService) Create(request *CreateRequest) (*CreateResponse, error) {
rsp := &CreateResponse{}
return rsp, t.client.Call("chat", "Create", request, rsp)
}
// Delete a chat room
func (t *ChatService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
@@ -100,14 +108,6 @@ func (t *ChatService) List(request *ListRequest) (*ListResponse, error) {
}
// Create a new chat room
func (t *ChatService) New(request *NewRequest) (*NewResponse, error) {
rsp := &NewResponse{}
return rsp, t.client.Call("chat", "New", request, rsp)
}
// Connect to a chat to receive a stream of messages
// Send a message to a chat
func (t *ChatService) Send(request *SendRequest) (*SendResponse, error) {
@@ -117,6 +117,22 @@ func (t *ChatService) Send(request *SendRequest) (*SendResponse, error) {
}
type CreateRequest struct {
// chat description
Description string `json:"description"`
// name of the room
Name string `json:"name"`
// whether its a private room
Private bool `json:"private"`
// optional list of user ids
UserIds string `json:"user_ids"`
}
type CreateResponse struct {
// the unique chat room
Room *Room `json:"room"`
}
type DeleteRequest struct {
// the chat room id to delete
RoomId string `json:"room_id"`
@@ -206,22 +222,6 @@ type Message struct {
UserId string `json:"user_id"`
}
type NewRequest struct {
// chat description
Description string `json:"description"`
// name of the room
Name string `json:"name"`
// whether its a private room
Private bool `json:"private"`
// optional list of user ids
UserIds string `json:"user_ids"`
}
type NewResponse struct {
// the unique chat room
Room *Room `json:"room"`
}
type Room struct {
// time of creation
CreatedAt string `json:"created_at"`