mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-18 13:39:57 -04:00
Get the docs rendering in the app
This commit replaces the old _API Documentation_ page with the Markdown version that Catherine has been working on. I’ve checked that there’s nothing obviously wrong or placeholder-y still in there, so I think we’re good to go.
This commit is contained in:
@@ -6,11 +6,6 @@ from app import api_key_api_client
|
||||
from app.utils import user_has_permissions
|
||||
|
||||
|
||||
@main.route("/documentation")
|
||||
def documentation():
|
||||
return render_template('views/documentation.html')
|
||||
|
||||
|
||||
@main.route("/services/<service_id>/api-keys")
|
||||
@login_required
|
||||
@user_has_permissions('manage_api_keys')
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
from flask import render_template, url_for, redirect, jsonify
|
||||
import markdown
|
||||
from flask import render_template, url_for, redirect, Markup
|
||||
from app.main import main
|
||||
from flask_login import login_required
|
||||
|
||||
from flask.ext.login import current_user
|
||||
from mdx_gfm import GithubFlavoredMarkdownExtension
|
||||
|
||||
|
||||
@main.route('/')
|
||||
@@ -36,3 +38,15 @@ def pricing():
|
||||
@main.route('/terms')
|
||||
def terms():
|
||||
return render_template('views/terms-of-use.html')
|
||||
|
||||
|
||||
@main.route('/documentation')
|
||||
def documentation():
|
||||
with open('docs/index.md') as source:
|
||||
return render_template(
|
||||
'views/documentation.html',
|
||||
body=Markup(markdown.markdown(
|
||||
source.read(),
|
||||
extensions=[GithubFlavoredMarkdownExtension()]
|
||||
))
|
||||
)
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
{% extends "withoutnav_template.html" %}
|
||||
{% from "components/page-footer.html" import page_footer %}
|
||||
{% from "components/api-key.html" import api_key %}
|
||||
|
||||
{% block page_title %}
|
||||
API documentation – GOV.UK Notify
|
||||
@@ -8,143 +6,10 @@
|
||||
|
||||
{% block maincolumn_content %}
|
||||
|
||||
<h1 class="heading-large">
|
||||
Developer documentation
|
||||
</h1>
|
||||
|
||||
<div class="grid-row">
|
||||
<div class="column-three-quarters">
|
||||
|
||||
<h2 class="heading-medium">
|
||||
How to integrate GOV.UK Notify into your service
|
||||
</h2>
|
||||
|
||||
<p>
|
||||
Notify provides an API that allows the creation of text notifications and the ability to get the status of a
|
||||
sent notification.
|
||||
</p>
|
||||
|
||||
<h3 class="heading-medium">
|
||||
API authentication
|
||||
</h3>
|
||||
|
||||
<p>
|
||||
Notify uses <a href="https://jwt.io/">JSON Web Tokens (JWT)</a> for authentication.
|
||||
JWT tokens have a series of claims, standard and application specific.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<p>Notify standard claims:</p>
|
||||
|
||||
{{'''
|
||||
{
|
||||
"typ": "JWT",
|
||||
"alg": "HS256"
|
||||
}
|
||||
'''|syntax_highlight_json}}
|
||||
|
||||
<p>Notify application specific:</p>
|
||||
{{"""
|
||||
{
|
||||
iss: 'string', // service id
|
||||
iat: 0, // creation time in epoch seconds (UTC)
|
||||
}
|
||||
"""|syntax_highlight_json}}
|
||||
<div class="grid-row">
|
||||
<div class="column-three-quarters">
|
||||
|
||||
<h3 class="heading-medium">
|
||||
API endpoints
|
||||
</h3>
|
||||
|
||||
<p>To create a text notification</p>
|
||||
</div>
|
||||
</div>
|
||||
{{ "POST /notifications/sms"|syntax_highlight_json }}
|
||||
|
||||
{{
|
||||
"""
|
||||
{
|
||||
'to': '+447700900404',
|
||||
'template': 1
|
||||
}
|
||||
"""|syntax_highlight_json
|
||||
}}
|
||||
<div class="grid-row">
|
||||
<div class="column-three-quarters">
|
||||
<p>
|
||||
Where ‘to’ is the phone number and ‘template’ is the template ID to send.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Response:
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
{{"""
|
||||
{
|
||||
'data':{
|
||||
'notification': {
|
||||
'id':1
|
||||
}
|
||||
}
|
||||
}
|
||||
"""|syntax_highlight_json }}
|
||||
|
||||
|
||||
<p>To get the status of a text notification</p>
|
||||
|
||||
{{ "GET /notifications/{id}"|syntax_highlight_json }}
|
||||
|
||||
{{"""
|
||||
{
|
||||
'data':{
|
||||
'notification': {
|
||||
'status':'sent',
|
||||
'createdAt':'2016-01-01T09:00:00.999999Z',
|
||||
'to':'+447827992607',
|
||||
'method':'sms',
|
||||
'sentAt':'2016-01-01T09:01:00.999999Z',
|
||||
'id':1,
|
||||
'message':'...',
|
||||
'jobId':1,
|
||||
'sender':'sms-partner'
|
||||
}
|
||||
}
|
||||
}
|
||||
"""|syntax_highlight_json }}
|
||||
|
||||
<div class="grid-row">
|
||||
<div class="column-three-quarters">
|
||||
<h2 class="heading-medium">
|
||||
API client libraries
|
||||
</h2>
|
||||
|
||||
<p>A python client library is support by the Notify team:</p>
|
||||
|
||||
<p>
|
||||
<a href="https://github.com/alphagov/notifications-python-client">GOV.UK Notify Python client</a>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
This provides example code for calling the API and for constructing the API tokens.
|
||||
</p>
|
||||
|
||||
<h2 class="heading-medium">API code</h2>
|
||||
|
||||
<p>Notify API code is open sourced at:</p>
|
||||
|
||||
<p>
|
||||
<a href="https://github.com/alphagov/notifications-api">GOV.UK Notify API</a>
|
||||
</p>
|
||||
|
||||
<h2 class="heading-medium">API endpoint</h2>
|
||||
|
||||
<p>
|
||||
https://api.notifications.service.gov.uk/
|
||||
</p>
|
||||
|
||||
</div>
|
||||
<div class="column-two-thirds">
|
||||
{{ body }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
@@ -11,6 +11,7 @@ Flask-Bcrypt==0.6.2
|
||||
credstash==1.8.0
|
||||
boto3==1.2.3
|
||||
Pygments==2.0.2
|
||||
py-gfm==0.1.2
|
||||
|
||||
git+https://github.com/alphagov/notifications-python-client.git@0.5.0#egg=notifications-python-client==0.5.0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user