Comms API documentation

NETSTOCK comms server app

This app is a web service to manage the comms server

  • Create new customer, and add their public key
  • Notify when files are pushed to server, so that we can push it to the correct app server
  • Poll for updates files to be pulled to the on-premise ERP system
 

The following API calls are available

get / Welcome message
  • No form-data params
  • Returns
    • {'status': 'ok', 'message': 'NETSTOCK Comms API service'}
post /customer/:customer_id Adds a new customer to the comms server
  • form-data params:
    • public_key
  • Returns
    • {'status': 'ok', 'customer_id': :customer_id, 'server_url': :server_url}
post /customer/:customer_id/remove_csv_files Notifies the comms server that we need to clear all CSV files on the comms server and the app server
  • No form-data params
  • Returns
    • {'status': 'ok', 'customer_id': :customer_id, 'server_url': :server_url}
post /customer/:customer_id/file_deleted Notifies the comms server that we deleted a file
  • form-data params:
    • filename (string parameter)
    • subdir (sub directory name, either to_netstock or from_netstock)
  • Returns
    • {'status': 'ok', 'customer_id': :customer_id, 'server_url': :server_url, 'file_deleted': :filename}
post /customer/:customer_id/customer_deleted Notifies the comms server that we have archived a customer and this customer needs to be deleted from the comms server
  • No form-data params
  • Returns
    • {'status': 'ok', 'customer_id': :customer_id}
post /customer/:customer_id/files_uploaded Notifies the comms server that we uploaded files
  • form-data params:
    • file_list (in the standard file_list json format)
  • Returns
    • {'status': 'ok', 'customer_id': :customer_id, 'server_url': :server_url, 'files_sent': number of file sent}
post /customer/:customer_id/files_from_app_server Notifies the comms server that some files are ready to be sent to the ERP server from the App server
  • form-data params:
    • file_list (in the standard file_list json format)
    • delete_after_transfer (boolean value to tell the comms server to delete the file on the app server after transferring)
  • Returns
    • {'status': 'ok', 'customer_id': :customer_id, 'server_url': :server_url}
post /customer/:customer_id/files_uploaded_from_netstock Notifies the comms server that a file has been manually uploaded to the from_netstock folder
  • string parameter:
    • filename (string parameter)
  • Returns
    • {'status': 'ok', 'customer_id': :customer_id, 'server_url'}
get /customer/:customer_id/files_for_erp Lets the ERP polling app know if there are new files to download to the ERP server
  • No form-data params
  • Returns:
    • file_list (in the standard file_list json format)
post /customer/:customer_id/files_downloaded Lets the comms server know that the ERP has downloaded files successfully
  • form-data params:
    • file_list (in the standard file_list json format)
  • Returns
    • {'status': 'ok', 'customer_id': :customer_id, 'files_processed': number of files processed}
post /customer/:customer_id/files_failed_to_download Notification from the ERP server that it failed to downloaded files
  • form-data params:
    • file_list (in the standard file_list json format)
  • Returns
    • {'status': 'ok', 'customer_id': :customer_id, 'files_processed': number of files processed}
get /customer/:customer_id/start_extract Lets the ERP polling app know that it must start a data extract
  • No form-data params
  • Returns
    • {'start_extract': boolean, 'status': 'ok'}
put /customer/:customer_id/extract_started Lets the comms server know that the ERP has started the extract
  • No form-data params
  • Returns
    • {'status': 'ok', 'customer_id': :customer_id}
put /customer/:customer_id/start_extract Inform the comms server that we want to start an extract. The next time the ERP polls, it will be informed.
  • No form-data params
  • Returns
    • {'status': 'ok', 'customer_id': :customer_id}
 

Standard file_list json format

{
  "files": [
    "file1.csv.bz2",
    "file2.csv.bz2",
    "file3.csv.bz2"
  ]
}