diff --git a/crm/docs/src/spec/field.json b/crm/docs/src/spec/field.json index 6bff0cf27..632a2e6b5 100644 --- a/crm/docs/src/spec/field.json +++ b/crm/docs/src/spec/field.json @@ -20,6 +20,7 @@ "name": "Field" } ], + "Parameters": null, "Protocol": "", "Authentication": [], "Path": "/field", diff --git a/crm/docs/src/spec/module.json b/crm/docs/src/spec/module.json index 96889eb28..6ef191b7f 100644 --- a/crm/docs/src/spec/module.json +++ b/crm/docs/src/spec/module.json @@ -42,6 +42,7 @@ "name": "ModuleContentRow" } ], + "Parameters": null, "Protocol": "", "Authentication": [], "Path": "/module", diff --git a/sam/docs/README.md b/sam/docs/README.md index 31b0a29d6..dba905b4b 100644 --- a/sam/docs/README.md +++ b/sam/docs/README.md @@ -8,7 +8,7 @@ Organisations represent a top-level grouping entity. There may be many organisat | URI | Protocol | Method | Authentication | | --- | -------- | ------ | -------------- | -| `/organisation/` | HTTP/S | GET | Client ID, Session ID | +| `/organisations/` | HTTP/S | GET | Client ID, Session ID | #### Request parameters @@ -22,7 +22,7 @@ Organisations represent a top-level grouping entity. There may be many organisat | URI | Protocol | Method | Authentication | | --- | -------- | ------ | -------------- | -| `/organisation/` | HTTP/S | PUT | Client ID, Session ID | +| `/organisations/` | HTTP/S | PUT | Client ID, Session ID | #### Request parameters @@ -36,7 +36,7 @@ Organisations represent a top-level grouping entity. There may be many organisat | URI | Protocol | Method | Authentication | | --- | -------- | ------ | -------------- | -| `/organisation/{id}` | HTTP/S | POST | Client ID, Session ID | +| `/organisations/{id}` | HTTP/S | POST | Client ID, Session ID | #### Request parameters @@ -51,7 +51,7 @@ Organisations represent a top-level grouping entity. There may be many organisat | URI | Protocol | Method | Authentication | | --- | -------- | ------ | -------------- | -| `/organisation/{id}` | HTTP/S | DELETE | Client ID, Session ID | +| `/organisations/{id}` | HTTP/S | DELETE | Client ID, Session ID | #### Request parameters @@ -65,7 +65,7 @@ Organisations represent a top-level grouping entity. There may be many organisat | URI | Protocol | Method | Authentication | | --- | -------- | ------ | -------------- | -| `/organisation/{id}` | HTTP/S | GET | Client ID, Session ID | +| `/organisations/{id}` | HTTP/S | GET | Client ID, Session ID | #### Request parameters @@ -79,7 +79,7 @@ Organisations represent a top-level grouping entity. There may be many organisat | URI | Protocol | Method | Authentication | | --- | -------- | ------ | -------------- | -| `/organisation/{id}/archive` | HTTP/S | POST | Client ID, Session ID | +| `/organisations/{id}/archive` | HTTP/S | POST | Client ID, Session ID | #### Request parameters @@ -100,7 +100,7 @@ An organisation may have many teams. Teams may have many channels available. Acc | URI | Protocol | Method | Authentication | | --- | -------- | ------ | -------------- | -| `/team/` | HTTP/S | GET | Client ID, Session ID | +| `/teams/` | HTTP/S | GET | Client ID, Session ID | #### Request parameters @@ -114,7 +114,7 @@ An organisation may have many teams. Teams may have many channels available. Acc | URI | Protocol | Method | Authentication | | --- | -------- | ------ | -------------- | -| `/team/` | HTTP/S | PUT | Client ID, Session ID | +| `/teams/` | HTTP/S | PUT | Client ID, Session ID | #### Request parameters @@ -129,7 +129,7 @@ An organisation may have many teams. Teams may have many channels available. Acc | URI | Protocol | Method | Authentication | | --- | -------- | ------ | -------------- | -| `/team/{id}` | HTTP/S | POST | Client ID, Session ID | +| `/teams/{id}` | HTTP/S | POST | Client ID, Session ID | #### Request parameters @@ -145,7 +145,7 @@ An organisation may have many teams. Teams may have many channels available. Acc | URI | Protocol | Method | Authentication | | --- | -------- | ------ | -------------- | -| `/team/{id}` | HTTP/S | GET | Client ID, Session ID | +| `/teams/{id}` | HTTP/S | GET | Client ID, Session ID | #### Request parameters @@ -159,7 +159,7 @@ An organisation may have many teams. Teams may have many channels available. Acc | URI | Protocol | Method | Authentication | | --- | -------- | ------ | -------------- | -| `/team/{id}` | HTTP/S | DELETE | Client ID, Session ID | +| `/teams/{id}` | HTTP/S | DELETE | Client ID, Session ID | #### Request parameters @@ -173,7 +173,7 @@ An organisation may have many teams. Teams may have many channels available. Acc | URI | Protocol | Method | Authentication | | --- | -------- | ------ | -------------- | -| `/team/{id}/archive` | HTTP/S | POST | Client ID, Session ID | +| `/teams/{id}/archive` | HTTP/S | POST | Client ID, Session ID | #### Request parameters @@ -187,7 +187,7 @@ An organisation may have many teams. Teams may have many channels available. Acc | URI | Protocol | Method | Authentication | | --- | -------- | ------ | -------------- | -| `/team/{id}/move` | HTTP/S | POST | Client ID, Session ID | +| `/teams/{id}/move` | HTTP/S | POST | Client ID, Session ID | #### Request parameters @@ -202,7 +202,7 @@ An organisation may have many teams. Teams may have many channels available. Acc | URI | Protocol | Method | Authentication | | --- | -------- | ------ | -------------- | -| `/team/{id}/merge` | HTTP/S | POST | Client ID, Session ID | +| `/teams/{id}/merge` | HTTP/S | POST | Client ID, Session ID | #### Request parameters @@ -224,7 +224,7 @@ A channel is a representation of a sequence of messages. It has meta data like c | URI | Protocol | Method | Authentication | | --- | -------- | ------ | -------------- | -| `/channel/` | HTTP/S | GET | Client ID, Session ID | +| `/channels/` | HTTP/S | GET | Client ID, Session ID | #### Request parameters @@ -238,7 +238,7 @@ A channel is a representation of a sequence of messages. It has meta data like c | URI | Protocol | Method | Authentication | | --- | -------- | ------ | -------------- | -| `/channel/` | HTTP/S | PUT | Client ID, Session ID | +| `/channels/` | HTTP/S | PUT | Client ID, Session ID | #### Request parameters @@ -253,7 +253,7 @@ A channel is a representation of a sequence of messages. It has meta data like c | URI | Protocol | Method | Authentication | | --- | -------- | ------ | -------------- | -| `/channel/{channelId}` | HTTP/S | POST | Client ID, Session ID | +| `/channels/{channelId}` | HTTP/S | POST | Client ID, Session ID | #### Request parameters @@ -271,7 +271,7 @@ A channel is a representation of a sequence of messages. It has meta data like c | URI | Protocol | Method | Authentication | | --- | -------- | ------ | -------------- | -| `/channel/{channelId}` | HTTP/S | GET | Client ID, Session ID | +| `/channels/{channelId}` | HTTP/S | GET | Client ID, Session ID | #### Request parameters @@ -285,7 +285,7 @@ A channel is a representation of a sequence of messages. It has meta data like c | URI | Protocol | Method | Authentication | | --- | -------- | ------ | -------------- | -| `/channel/{channelId}` | HTTP/S | DELETE | Client ID, Session ID | +| `/channels/{channelId}` | HTTP/S | DELETE | Client ID, Session ID | #### Request parameters @@ -324,7 +324,7 @@ The following event types may be sent with a message event: | URI | Protocol | Method | Authentication | | --- | -------- | ------ | -------------- | -| `/message/` | HTTP/S | POST | Client ID, Session ID | +| `/channels/{channelId}/messages/` | HTTP/S | POST | Client ID, Session ID | #### Request parameters @@ -338,7 +338,7 @@ The following event types may be sent with a message event: | URI | Protocol | Method | Authentication | | --- | -------- | ------ | -------------- | -| `/message/{messageId}` | HTTP/S | PUT | Client ID, Session ID | +| `/channels/{channelId}/messages/{messageId}` | HTTP/S | PUT | Client ID, Session ID | #### Request parameters @@ -353,7 +353,7 @@ The following event types may be sent with a message event: | URI | Protocol | Method | Authentication | | --- | -------- | ------ | -------------- | -| `/message/{messageId}` | HTTP/S | DELETE | Client ID, Session ID | +| `/channels/{channelId}/messages/{messageId}` | HTTP/S | DELETE | Client ID, Session ID | #### Request parameters @@ -367,7 +367,7 @@ The following event types may be sent with a message event: | URI | Protocol | Method | Authentication | | --- | -------- | ------ | -------------- | -| `/message/{messageId}/attach` | HTTP/S | PUT | Client ID, Session ID | +| `/channels/{channelId}/messages/{messageId}/attach` | HTTP/S | PUT | Client ID, Session ID | #### Request parameters @@ -380,7 +380,7 @@ The following event types may be sent with a message event: | URI | Protocol | Method | Authentication | | --- | -------- | ------ | -------------- | -| `/message/search` | HTTP/S | GET | Client ID, Session ID | +| `/channels/{channelId}/messages/search` | HTTP/S | GET | Client ID, Session ID | #### Request parameters @@ -395,7 +395,7 @@ The following event types may be sent with a message event: | URI | Protocol | Method | Authentication | | --- | -------- | ------ | -------------- | -| `/message/{messageId}/pin` | HTTP/S | POST | Client ID, Session ID | +| `/channels/{channelId}/messages/{messageId}/pin` | HTTP/S | POST | Client ID, Session ID | #### Request parameters @@ -409,7 +409,7 @@ The following event types may be sent with a message event: | URI | Protocol | Method | Authentication | | --- | -------- | ------ | -------------- | -| `/message/{messageId}/pin` | HTTP/S | DELETE | Client ID, Session ID | +| `/channels/{channelId}/messages/{messageId}/pin` | HTTP/S | DELETE | Client ID, Session ID | #### Request parameters @@ -423,7 +423,7 @@ The following event types may be sent with a message event: | URI | Protocol | Method | Authentication | | --- | -------- | ------ | -------------- | -| `/message/{messageId}/flag` | HTTP/S | POST | Client ID, Session ID | +| `/channels/{channelId}/messages/{messageId}/flag` | HTTP/S | POST | Client ID, Session ID | #### Request parameters @@ -437,7 +437,7 @@ The following event types may be sent with a message event: | URI | Protocol | Method | Authentication | | --- | -------- | ------ | -------------- | -| `/message/{messageId}/flag` | HTTP/S | DELETE | Client ID, Session ID | +| `/channels/{channelId}/messages/{messageId}/flag` | HTTP/S | DELETE | Client ID, Session ID | #### Request parameters @@ -451,7 +451,7 @@ The following event types may be sent with a message event: | URI | Protocol | Method | Authentication | | --- | -------- | ------ | -------------- | -| `/message/{messageId}/react` | HTTP/S | POST | Client ID, Session ID | +| `/channels/{channelId}/messages/{messageId}/react` | HTTP/S | POST | Client ID, Session ID | #### Request parameters @@ -466,7 +466,7 @@ The following event types may be sent with a message event: | URI | Protocol | Method | Authentication | | --- | -------- | ------ | -------------- | -| `/message/{messageId}/react/{reactionId}` | HTTP/S | DELETE | Client ID, Session ID | +| `/channels/{channelId}/messages/{messageId}/react/{reactionId}` | HTTP/S | DELETE | Client ID, Session ID | #### Request parameters @@ -486,7 +486,7 @@ The following event types may be sent with a message event: | URI | Protocol | Method | Authentication | | --- | -------- | ------ | -------------- | -| `/user/search` | HTTP/S | GET | Client ID, Session ID | +| `/users/search` | HTTP/S | GET | Client ID, Session ID | #### Request parameters diff --git a/sam/docs/src/spec/auth.json b/sam/docs/src/spec/auth.json index 2907904d5..2dde57e41 100644 --- a/sam/docs/src/spec/auth.json +++ b/sam/docs/src/spec/auth.json @@ -3,6 +3,7 @@ "Package": "sam", "Interface": "Auth", "Struct": [], + "Parameters": null, "Protocol": "", "Authentication": null, "Path": "/auth", diff --git a/sam/docs/src/spec/channel.json b/sam/docs/src/spec/channel.json index b8c4e08b2..3c553c6aa 100644 --- a/sam/docs/src/spec/channel.json +++ b/sam/docs/src/spec/channel.json @@ -50,12 +50,13 @@ "name": "Channel" } ], + "Parameters": null, "Protocol": "", "Authentication": [ "Client ID", "Session ID" ], - "Path": "/channel", + "Path": "/channels", "APIs": [ { "Name": "list", diff --git a/sam/docs/src/spec/message.json b/sam/docs/src/spec/message.json index 648444423..3460635e2 100644 --- a/sam/docs/src/spec/message.json +++ b/sam/docs/src/spec/message.json @@ -127,12 +127,22 @@ "name": "Attachment" } ], + "Parameters": { + "path": [ + { + "name": "channelId", + "required": true, + "title": "Channel ID", + "type": "uint64" + } + ] + }, "Protocol": "", "Authentication": [ "Client ID", "Session ID" ], - "Path": "/message", + "Path": "/channels/{channelId}/messages", "APIs": [ { "Name": "create", diff --git a/sam/docs/src/spec/organisation.json b/sam/docs/src/spec/organisation.json index ff805b3dd..84f4c216c 100644 --- a/sam/docs/src/spec/organisation.json +++ b/sam/docs/src/spec/organisation.json @@ -33,12 +33,13 @@ "name": "Organisation" } ], + "Parameters": null, "Protocol": "", "Authentication": [ "Client ID", "Session ID" ], - "Path": "/organisation", + "Path": "/organisations", "APIs": [ { "Name": "list", diff --git a/sam/docs/src/spec/team.json b/sam/docs/src/spec/team.json index b2ef8ba89..4615c42df 100644 --- a/sam/docs/src/spec/team.json +++ b/sam/docs/src/spec/team.json @@ -45,12 +45,13 @@ "name": "Team" } ], + "Parameters": null, "Protocol": "", "Authentication": [ "Client ID", "Session ID" ], - "Path": "/team", + "Path": "/teams", "APIs": [ { "Name": "list", diff --git a/sam/docs/src/spec/user.json b/sam/docs/src/spec/user.json index c8562f851..01901a347 100644 --- a/sam/docs/src/spec/user.json +++ b/sam/docs/src/spec/user.json @@ -48,12 +48,13 @@ "name": "User" } ], + "Parameters": null, "Protocol": "", "Authentication": [ "Client ID", "Session ID" ], - "Path": "/user", + "Path": "/users", "APIs": [ { "Name": "search", diff --git a/sam/rest/router.go b/sam/rest/router.go index ca1f34502..59c4f03c8 100644 --- a/sam/rest/router.go +++ b/sam/rest/router.go @@ -36,7 +36,7 @@ func MountRoutes(r chi.Router) { }) r.Group(func(r chi.Router) { r.Use(channel.Channel.Authenticator()) - r.Route("/channel", func(r chi.Router) { + r.Route("/channels", func(r chi.Router) { r.Get("/", channel.List) r.Put("/", channel.Create) r.Post("/{channelId}", channel.Edit) @@ -46,7 +46,7 @@ func MountRoutes(r chi.Router) { }) r.Group(func(r chi.Router) { r.Use(message.Message.Authenticator()) - r.Route("/message", func(r chi.Router) { + r.Route("/channels/{channelId}/messages", func(r chi.Router) { r.Post("/", message.Create) r.Put("/{messageId}", message.Edit) r.Delete("/{messageId}", message.Delete) @@ -62,7 +62,7 @@ func MountRoutes(r chi.Router) { }) r.Group(func(r chi.Router) { r.Use(organisation.Organisation.Authenticator()) - r.Route("/organisation", func(r chi.Router) { + r.Route("/organisations", func(r chi.Router) { r.Get("/", organisation.List) r.Put("/", organisation.Create) r.Post("/{id}", organisation.Edit) @@ -73,7 +73,7 @@ func MountRoutes(r chi.Router) { }) r.Group(func(r chi.Router) { r.Use(team.Team.Authenticator()) - r.Route("/team", func(r chi.Router) { + r.Route("/teams", func(r chi.Router) { r.Get("/", team.List) r.Put("/", team.Create) r.Post("/{id}", team.Edit) @@ -86,7 +86,7 @@ func MountRoutes(r chi.Router) { }) r.Group(func(r chi.Router) { r.Use(user.User.Authenticator()) - r.Route("/user", func(r chi.Router) { + r.Route("/users", func(r chi.Router) { r.Get("/search", user.Search) }) }) diff --git a/sam/rest/server/message_requests.go b/sam/rest/server/message_requests.go index 0950aad2e..49c9746fc 100644 --- a/sam/rest/server/message_requests.go +++ b/sam/rest/server/message_requests.go @@ -24,7 +24,8 @@ var _ = chi.URLParam // Message create request parameters type MessageCreateRequest struct { - Contents string + ChannelId uint64 + Contents string } func (MessageCreateRequest) new() *MessageCreateRequest { @@ -44,6 +45,8 @@ func (m *MessageCreateRequest) Fill(r *http.Request) error { post[name] = string(param[0]) } + m.ChannelId = parseUInt64(chi.URLParam(r, "channelId")) + m.Contents = post["contents"] return nil } @@ -111,6 +114,7 @@ var _ RequestFiller = MessageDeleteRequest{}.new() // Message attach request parameters type MessageAttachRequest struct { + ChannelId uint64 } func (MessageAttachRequest) new() *MessageAttachRequest { @@ -129,6 +133,8 @@ func (m *MessageAttachRequest) Fill(r *http.Request) error { for name, param := range postVars { post[name] = string(param[0]) } + + m.ChannelId = parseUInt64(chi.URLParam(r, "channelId")) return nil } @@ -136,6 +142,7 @@ var _ RequestFiller = MessageAttachRequest{}.new() // Message search request parameters type MessageSearchRequest struct { + ChannelId uint64 Query string Message_type string } @@ -157,6 +164,8 @@ func (m *MessageSearchRequest) Fill(r *http.Request) error { post[name] = string(param[0]) } + m.ChannelId = parseUInt64(chi.URLParam(r, "channelId")) + m.Query = get["query"] m.Message_type = get["message_type"]