From 70f11c9a4eca60b70d73f9c7cc00fe9766f42db4 Mon Sep 17 00:00:00 2001 From: Thomas Millward Wright Date: Thu, 13 Feb 2025 14:18:27 +0000 Subject: [PATCH 1/2] [LA-25777] Add documentation for new endpoint --- source/includes/_communities.md | 97 +++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 source/includes/_communities.md diff --git a/source/includes/_communities.md b/source/includes/_communities.md new file mode 100644 index 00000000000..8343d3ef376 --- /dev/null +++ b/source/includes/_communities.md @@ -0,0 +1,97 @@ +# Communities + +## View All Community Posts + +> For a given community, view all posts + +```shell +curl --location --request GET 'https://api.learnamp.com/v1/communities/123/posts' \ +--header 'Authorization: Bearer YOUR-ACCESS-TOKEN' +``` + +```ruby +module Learnamp + class CommunityPosts + include HTTParty + base_uri "#{ENV['BASE_URL']}#{ENV['API_PATH']}" + + attr_accessor :token + + def initialize(token) + @token = token + end + + def all(community_id, filters) + filters_query = URI.encode_www_form(filters) + response = self.class.get("/communities/#{community_id}/posts?#{filters_query}", { headers: headers }) + response.parsed_response + end + + private + + def headers + { + 'Authorization' => "Bearer #{token}" + } + end + end +end + +filters = { + "filters[name][created_at][from]": DateTime.now.to_s +} +teams = Learnamp::CommunityPosts.new(token).all(filters) +``` + +View all community posts + +`GET https://{API_BASE_URL}/v1/communities/:id/posts` + +Response will be paginated [see pagination](#pagination) + + +### Optional Filters in URL Params + +The following URL params by be included, to filter the result set: + +`GET https://{API_BASE_URL}/v1/communities/:id/posts?filters[created_at][from]=2022-01-01` + +URL Param | Value | Description +--------- | ------- | ----------- +filters[created_at][from] | "2021-12-31" | Assigned date range FROM date/time in ISO 8601 format +filters[created_at][to] | "2022-01-01 15:00:00" | Assigned date range TO date/time in ISO 8601 format + +> 200 OK - successful response: + +```json +[ + { + "id": 1, + "content": "

Hi guys @Mr Inactive McGoo @new guy @taylor williams 

", + "pinned": false, + "created_at_words": "Feb 07, 2025", + "user": { + "name": "Thomas Millward Wright" + }, + "likes": { + "count": 0, + "liked_by": [] + }, + "mentions": [ + { + "mentioned": { + "id": 1, + "name": "taylor williams", + "email": "taylor.williams@learnamp.com" + }, + "mentioned_by": { + "id": 1, + "name": "Thomas Millward Wright", + "email": "thomas.millwardwright@learnamp.com" + } + } + ], + "comments": [] + } +] +``` From d4bd7d96498a6d2ccd7fe400b19e1cda007145ae Mon Sep 17 00:00:00 2001 From: Thomas Millward Wright Date: Thu, 13 Feb 2025 16:21:11 +0000 Subject: [PATCH 2/2] [LA-25777] Do not use real people names --- source/includes/_communities.md | 83 ++++++++++++++++++++++++++++++--- 1 file changed, 76 insertions(+), 7 deletions(-) diff --git a/source/includes/_communities.md b/source/includes/_communities.md index 8343d3ef376..c9efcbd9004 100644 --- a/source/includes/_communities.md +++ b/source/includes/_communities.md @@ -67,11 +67,24 @@ filters[created_at][to] | "2022-01-01 15:00:00" | Assigned date range TO date/ti [ { "id": 1, - "content": "

Hi guys @Mr Inactive McGoo @new guy @taylor williams 

", + "content": "

shout out to all my friends @new guy @Max Absurdity 

", "pinned": false, - "created_at_words": "Feb 07, 2025", + "createdAt": "2025-02-07T10:31:46.812Z", "user": { - "name": "Thomas Millward Wright" + "id": 1, + "firstName": "Henry", + "lastName": "Dorsett Case", + "jobTitle": null, + "email": "henry.dorsettcase@learnamp.com", + "timeZone": "International Date Line West", + "language": "en", + "role": "super_admin", + "hireDate": null, + "profileUrl": "http://sawmill.lvh.me:3000/en/users/1", + "status": { + "status": "Confirmed", + "time": "On 20 Jun 23" + } }, "likes": { "count": 0, @@ -80,14 +93,70 @@ filters[created_at][to] | "2022-01-01 15:00:00" | Assigned date range TO date/ti "mentions": [ { "mentioned": { + "id": 198990, + "firstName": "new", + "lastName": "guy", + "jobTitle": "", + "email": "new.guy@guy.guy", + "timeZone": "International Date Line West", + "language": "en", + "role": "viewer", + "hireDate": null, + "profileUrl": "http://sawmill.lvh.me:3000/en/users/198990", + "status": { + "status": "Confirmed", + "time": "On 12 Aug 24" + } + }, + "mentioned_by": { "id": 1, - "name": "taylor williams", - "email": "taylor.williams@learnamp.com" + "firstName": "Henry", + "lastName": "Dorsett Case", + "jobTitle": null, + "email": "henry.dorsettcase@learnamp.com", + "timeZone": "International Date Line West", + "language": "en", + "role": "super_admin", + "hireDate": null, + "profileUrl": "http://sawmill.lvh.me:3000/en/users/1", + "status": { + "status": "Confirmed", + "time": "On 20 Jun 23" + } + } + }, + { + "mentioned": { + "id": 3, + "firstName": "Max", + "lastName": "Absurdity", + "jobTitle": null, + "email": "max.absurdity@learnamp.com", + "timeZone": "International Date Line West", + "language": "en", + "role": "super_admin", + "hireDate": null, + "profileUrl": "http://sawmill.lvh.me:3000/en/users/1", + "status": { + "status": "Confirmed", + "time": "On 20 Jun 23" + } }, "mentioned_by": { "id": 1, - "name": "Thomas Millward Wright", - "email": "thomas.millwardwright@learnamp.com" + "firstName": "Henry", + "lastName": "Dorsett Case", + "jobTitle": null, + "email": "henry.dorsettcase@learnamp.com", + "timeZone": "International Date Line West", + "language": "en", + "role": "super_admin", + "hireDate": null, + "profileUrl": "http://sawmill.lvh.me:3000/en/users/3", + "status": { + "status": "Confirmed", + "time": "On 20 Jun 23" + } } } ],