LandRegistry/charges-case-api

Name: charges-case-api

Owner: HM Land Registry

Description: null

Created: 2015-06-05 08:35:33.0

Updated: 2015-10-20 08:33:01.0

Pushed: 2015-11-02 15:10:39.0

Homepage: null

Size: 1044

Language: Python

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Case API

The Case API is a JSON API which stores case objects.

This API holds the functionality for creating the migrating tables, getting data from the database, converting to JSON and returns as an endpoint.

Contents
Usage
    /                           # automatically redirects to helloworld for app test
    /helloworld                 # test endpoint for the application
    /case                       # get all cases
    /case/<id_>                 # get a cases with an id in the URL
    /case/<case_id>/property    # Get property for case id
    /case/<case_id>/borrowers   # Get borrowers for case id
te  /case/<id_>                 # delete a case with an id in the URL
    /case                       # Create a case by posting a json object reflecting the model
    /case/<deed_id>/status      # Updates the status of the case
    /case/<case_id>/application # Submits deed for registration
    /case/<case_id>/deed        # Adds deed id to case
    /case/<case_id>/borrowers   # Add borrowers to borrower table
    /case/<case_id>/property    # Add property to case

model for post

Getting Started
  1. Clone the repo

  2. In the directory enter the command

    install -r requirements.txt
    
  3. Export your database URI

    rt DATABASE_URI=postgresql://username:password@localhost/database
    
  4. To run the migration run the command

    on run.py db upgrade head
    
  5. To run the application run the command

    on run.py runserver
    
Changing the migration

All you have to do is change/create the related model and run the command

on run.py db revision --autogenerate

For some helpful documentation on using alembic go here

Current Model
Case Model

d": Integer(Primary Key),
tatus": String,
reated_on": ISO Format DateTime,
ast_updated": ISO Format DateTime,
eed_id": Integer,
onveyancer_id": Integer

e.g.


d": 865604,
eed_id": 1,
onveyancer_id": 1,
tatus": "the status",
ast_updated": "2015-06-23T23:37:08.156342",
reated_on": "2015-06-23T23:37:08.156356"

Borrower model

Borrowers are slightly different as you add an array of borrowers


orrowers": [
{
    "first_name": String,
    "middle_names": String,
    "last_name": String,
    "case_id": Integer(foreign key),
    "mobile_no": String,
    "email_address": String,
    "address": Array(String)
}


e.g.


orrowers": [
{
  "first_name": "John",
  "middle_names": "Oliver",
  "last_name": "Smith",
  "case_id": 1,
  "mobile_no": "0777777171",
  "email_address": "maddog@thegoogle.com",
  "address": [
      "kennel"
  ]
}


Note: Because of the foreign key relationship, it will fail if the id of the case does not exist in the table

Property Model

ase_id": Integer(Primary Key)
itle_number": String,
treet": String,
enure": String,
ocality": String,
ostcode": String,

e.g.


ase_id": 123456
itle_number": "DN100",
treet": "a Street",
enure": "Freehold",
ocality": "A Locality",
ostcode": "PL6 WDS",


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.