We need changes in the API and Admin endpoint in order to serve content to CME clients. This content will be produced by an external app and stored on S3. A new endpoint is needed for this external app to notify when content has changed.
- Add two new fields Course model:
cme_article_url(string)cme_qa_url(string)
These will point to JSON files hosted on S3.
Source file: app/api/cme_api_v1.rb
Update endpoint GET courses/:course_name to serve new fields:
cme_article(JSON)cme_qa(JSON)
These fields should contain the actual JSON content located at cme_article_url and cme_qa_url URLs.
The JSON content should be fetched from S3 (two requests) when handling the API request, using standard Rails caching, with a duration of 1 hour.
Add new endpoint POST courses/:course_name/update_content. Call to this endpoint forces the cache mentioned in 2) to be refreshed.
This endpoint will be called from an external source, so it should require an api_key param which should match Rails.application.secrets.cme_external_api_key (to be put in secrets.yml).
(See authenticated_by_api_key in app/api/api_helpers.rb and app/api/api_v4.rb for example on how we use api_key).
- Show new editable fields
cme_article_urlandcme_qa_urlin Course edit form.