03 - Required API Operations

03 - Required API Operations

Each data type that Universal Migrator will load to your system must support four operations:
  1. Create
  2. Search (list)
  3. Sparse Update
  4. Delete

All Four Operations are Required

Before our team can write the code to push a data type to your application, your API must support all four operations for that data type.

Required Operations

Create

This operation will be used to create new records in your system.  The invocation for Create should be something like this:

  1. POST /api/v1/contacts/create
  2. { 
  3.    “data”: { 
  4.      “type”: “person”, 
  5.      “first_name”: “John”, 
  6.      “last_name”: “Smith” 
  7.    } 
  8. } 

On success, it should return JSON bodies similar to this:

  1. { 
  2.    “data”: { 
  3.      “id”: “12345”, 
  4.      “type”: “person”, 
  5.      “first_name”: “John”, 
  6.      “last_name”: “Smith”, 
  7.      “created_at”: “2017-05-11T16:28:24-05:00”, 
  8.      “updated_at”: “2017-05-11T16:28:24-05:00”, 
  9.    }
  10. } 

On error, it should return JSON bodies similar to this:

  1. { 
  2.    “error”: { 
  3.      “type”: “validation_exception”, 
  4.      “message”: “something went wrong” 
  5.    } 
  6. } 


Search (List)

This operation will be used to find, filter, and/or page through records that have already been created.  The invocation for Search should be something like this:


  1. POST /api/v1/contacts/search
  2. { 
  3.    "filter": { 
  4.      "ids": [ "12345", "12346", "12347"], 
  5.      "type": "person", 
  6.      "created_after": "2017-05-11T16:28:24-05:00", 
  7.      "updated_after": "2017-05-11T16:28:24-05:00", 
  8.      "skip": 1000, 
  9.      "take": 50
  10.    } 
  11. } 

On success, it should return JSON bodies similar to this:

  1. { 
  2.    “data”: [
  3.       { 
  4.        “id”: “12345”, 
  5.        “type”: “person”, 
  6.        “first_name”: “John”, 
  7.        “last_name”: “Smith”, 
  8.        “created_at”: “2017-05-11T16:28:24-05:00”, 
  9.        “updated_at”: “2017-05-11T16:28:24-05:00”, 
  10.      },
  11.       { 
  12.        “id”: “12346”, 
  13.        “type”: “person”, 
  14.        “first_name”: “Jane”, 
  15.        “last_name”: “Doe”, 
  16.        “created_at”: “2017-05-11T16:28:24-05:00”, 
  17.        “updated_at”: “2017-05-11T16:28:24-05:00”, 
  18.      },
  19.     ]
  20. } 

On error, it should return JSON bodies similar to this:

  1. { 
  2.    “error”: { 
  3.      “type”: “validation_exception”, 
  4.      “message”: “something went wrong” 
  5.    } 
  6. } 


The Search API must support the following filters:
id_before
id_after

The Search API must support ordering items by Id.

Sparse Update

Info
A sparse update is an update API that only updates the provided fields and does not change any other fields.
 
This operation will be used to find records that have already been created.  The URL for Sparse Update should be something like this:

  1. PATCH /api/v1/contacts/12345
  2. { 
  3.    “data”: { 
  4.      “last_name”: “doe” 
  5.    } 
  6. } 

The responses should be identical to that of the Create operation.

Delete

This operation will be used to delete records that have already been created.  The URL for Delete should be something like this:

  1. DELETE /api/v1/contacts/12345
  2. { 

  3. } 

On success, it should return JSON bodies similar to this:

  1. { 
  2.    “status”: { 
  3.      “type”: “record_deleted”, 
  4.      “message”: “The record was successfully deleted”
  5.    }
  6. } 

On error, it should return JSON bodies similar to this:

  1. { 
  2.    “error”: { 
  3.      “type”: “validation_exception”, 
  4.      “message”: “something went wrong” 
  5.    } 
  6. } 


Other Requirements

Your API should have an endpoint which can identify the currently authenticated user.  Something like:
/api/v1/users/who_am_i