Commit Graph

160 Commits

Author SHA1 Message Date
Imdad Ahad
fa3f4f3c20 Add dao to store letter contacts and upsert 2017-09-25 12:26:29 +01:00
Rebecca Law
795bd4271c New endpoint to fetch a single reply-to email address by id 2017-09-21 17:02:58 +01:00
Rebecca Law
c6bf38e869 - is_default is required on the add_service_email_reply_to_request schema
- Added check that the service exists for the POST reply-to methods.
- Added tests
2017-09-20 11:58:18 +01:00
Rebecca Law
6b2c2962c9 New endpoint to insert new service reply to email address and update existing one. 2017-09-14 17:54:38 +01:00
Katie Smith
72760550bd Add endpoint to get the email reply to addresses for a service
- Changed the dao_get_reply_to_by_service_id method to return a list of
results.
- Added a GET /service/<service_id>/email-reply-to endpoint
2017-09-13 16:58:36 +01:00
Rebecca Law
f624f4f033 Insert and update methods for service_sms_sender 2017-09-11 17:40:37 +01:00
Imdad Ahad
6d0ad75a60 Upsert to new email reply to table when updating a service 2017-09-08 14:56:05 +01:00
Imdad Ahad
e1ef0e85c6 Remove monthly usage dao methods 2017-08-30 14:40:54 +01:00
Imdad Ahad
9478af0941 Remove get yearly usage endpoint 2017-08-30 14:37:27 +01:00
Rebecca Law
17f62723fa Removed unused endpoint and dao methods. 2017-08-24 16:09:48 +01:00
Leo Hemsted
c2152f9cb8 remove billable-units endpoint
it wasn't used anywhere, and the return value changed when flask was upgraded
2017-08-21 10:57:15 +01:00
Imdad Ahad
f40889e6e0 This adds new endpoints to retrieve billing data from the new table:
1. Create a separate billing blueprint to house these endpoints

2. Return monthly breakdown in same format as we did before

3. Return yearly breakdown but only return {billing units, rate,
notification_type}. Admin only makes use of these.
2017-08-17 11:10:42 +01:00
Imdad Ahad
94605d31fa Change how we populate and retrieve MonthlyBilling totals:
1. For both email and sms, store [] in monthly_totals if
there is no billing data (no notifications sent etc.) and
return this via the API

2. General refactoring of indentation
2017-08-15 16:09:42 +01:00
Rebecca Law
b227ed450a Got rid of an if 2017-08-09 15:42:40 +01:00
Rebecca Law
1ec6a3b73d Created a new service endpoint that checks if the service name or email_from is unique.
Why is this needed?
When a user updates a service name they enter the new name in a form, are then asked to confirm the change by entering their password. Then the API call to update_service is called. If we let the update serivce API call fail with the integrity constraint it will be ackward for the user.
2017-08-09 15:12:52 +01:00
Rebecca Law
9400988d72 Monthly billing - part 1
This is still a work in progress but it would be good to get some eyes on it.
This commit includes creating and updating a row in the monthly billing table and a method to fetch the results.
There is a command to populate the monthly billing for a service and month so we can try it out.
The total cost at the moment are wrong, they do not take into account the free allowance - see notes below about adding that to the table.
Left to do:
create a nightly task to run to update the monthly totals.
create an endpoint to return the yearly billing, the current day will need to be calculated on the fly and added to the totals.
Add the free allowance into the total costs.
2017-07-18 18:21:35 +01:00
Ken Tsang
b04d01ba27 Refactored code to use new service permissions only 2017-07-06 12:27:55 +01:00
Imdad Ahad
4d41da22a4 Use correct schema for dumping a notification with personalisation 2017-07-06 12:27:55 +01:00
Leo Hemsted
729faf579d block one-off sms with long content counts 2017-06-20 12:06:47 +01:00
Leo Hemsted
10b851b456 add send_notification file for handling sending one off messages
currently, they're made by creating a one-line job, but we want to
reduce task/csv file noise so we're moving them to persist in the
same vein as API usage. However, we can't just call through to that
since there are some differences:

* no api keys
* tighter control over API format
* no scheduling
* no client references

etc.

So, re-using as much of the v2 validation stuff as possible, I've
created this file that just does basic validation, and then calls
through to persist_notification and schedules a task. Woo.
2017-06-20 11:51:36 +01:00
Rebecca Law
3a66027d6a Refactor ApiKeys.secret and ServiceInboundApi.bearer_token to use the same encryption method and get rid of the duplicate code. 2017-06-19 14:32:22 +01:00
Rebecca Law
6202da7dea Update model to remove the string length restriction.
Moved logic to the dao from the endpoint.
2017-06-19 12:25:05 +01:00
Rebecca Law
effb99dca8 Add fetch request for service inbound api.
Add unique constraint on service_id for service_inbound_api.
2017-06-15 16:19:12 +01:00
Rebecca Law
828d5cd493 New table to store the inbound api information for a service. The table is versioned.
There is a new endpoint to create the inbound api and one to update it.
2017-06-15 11:32:51 +01:00
Rebecca Law
3fdd180515 New endpoint to set ServiceInboundApi data. 2017-06-13 18:00:25 +01:00
Imdad Ahad
dfeda93bc5 Merge pull request #1015 from alphagov/imdad-feat-return-content-outbound
Return notification content for outbound messages
2017-06-13 12:27:16 +01:00
Chris Hill-Scott
635fb8fe44 Add private endpoint to get notification by ID
We need this for the two way stuff in the admin app.

We already have this as a public endpoint, but the admin app can’t use
it, because the admin app auths with its own key, not that of the
service it’s acting on behalf of.

This endpoint makes sure that a request originating from one service
can’t be used to see notifications belonging to another service.
2017-06-06 16:21:57 +01:00
Imdad Ahad
3177a6ddc4 Return personalisation dump of notifications + small refactor 2017-06-05 15:54:40 +01:00
Martyn Inglis
7f65aa3eef Merge branch 'master' into remove-nasty-query-from-dashboard
Conflicts:
	app/service/rest.py
	tests/app/service/test_rest.py
2017-06-01 13:11:54 +01:00
kentsanggds
263adac805 Merge pull request #984 from alphagov/ken-update-api-service-permissions-handling
Ken update api service permissions handling
2017-05-26 14:39:27 +01:00
Imdad Ahad
77b82305f4 Search normalised in get_notifications_for_service:
* Use dao method to search against normalised(recipient)
* Add filter to accept one or more statuses
2017-05-26 11:58:50 +01:00
Ken Tsang
1375bbe400 Refactor schema to improve error response 2017-05-25 17:55:24 +01:00
Ken Tsang
54d85fd8df Add tests for services with no permissions 2017-05-25 17:48:09 +01:00
Ken Tsang
2f626fa6fc Add permissions validation in service schema 2017-05-25 17:47:21 +01:00
Ken Tsang
8e3e31faaf Updated service DAO and API end points 2017-05-25 17:47:21 +01:00
Leo Hemsted
554a193cff separate service deserialization from validation
Marshmallow validates and deserialises - BUT, when it deserialises,
it explicitly sets `sms_sender=None`, even when you haven't passed
sms_sender in. This is problematic, because we wanted to take advantage
of sqlalchemy's default value to set sms_sender to `GOVUK` when the
actual DB commit happens.

Instead, still use marshmallow for validating, but manually carry out
the json deserialisation in the model class.

This fixes a bug that only manifested when the database was upgraded,
but the code hadn't updated. 🎉
2017-05-24 16:27:12 +01:00
Martyn Inglis
03346f467f updated cache to store map not single value, to accommodate the billable units and the total cost. 2017-05-24 09:59:37 +01:00
Martyn Inglis
78a55bafe0 Added new cost field to yearly billable sms endpoint. 2017-05-24 08:57:41 +01:00
Martyn Inglis
119f0532ab Renamed the API method/url 2017-05-22 10:06:34 +01:00
Martyn Inglis
f0395e7496 New endpoint to get the count of billable SMS units. 2017-05-19 16:43:05 +01:00
Chris Hill-Scott
2d4f10bd22 Comma-format number when emailing live services
250,000 is easier to read than 250000.
2017-05-16 12:33:01 +01:00
Imdad Ahad
d993e1a43e Don't send notification if other service attrs changed 2017-05-15 15:02:01 +01:00
Imdad Ahad
5eb02a45a5 Send go live email when service goes live 2017-05-12 14:07:06 +01:00
Rebecca Law
a564b9aeb0 Update /service/{}/notifications to look for a "to" query string, if it exists call the search notifications_by_to_field method. 2017-05-08 17:20:21 +01:00
Rebecca Law
d252dc8976 New endpoint to search by "to" field of the notification.
The query ignores case and spaces.
2017-05-05 14:12:50 +01:00
Rebecca Law
1a64509186 Change the resultset from the yearly and monthly billing data queries.
Fix some formatting of the return objects.
2017-04-28 10:10:49 +01:00
Rebecca Law
a186fc95be Added new endpoints to return the yearly-usage and monthly-usage for a given financial year and service id.
Since the response has changed I have created new endpoints so that the deployments for Admin are more managable.

Removed print statements from some tests.
2017-04-28 10:10:48 +01:00
Ken Tsang
5f945ab30e Refactored code, changed now to utcnow in test 2017-03-29 11:47:41 +01:00
Ken Tsang
c94b4f1b46 Removed unused import 2017-03-29 11:05:31 +01:00
Ken Tsang
af78efd137 Fix get_detailed_services BST 2017-03-29 11:03:28 +01:00