Skip to content

Adapter to translate Sensus EMR Meter Reading CSVs to mWater Accounting Transactions

License

Notifications You must be signed in to change notification settings

fffinkel/sensus-mwater-adapter

Repository files navigation

Sensus-mWater Adapter

Go Tests Go Coverage Badge Go Report Card

The Sensus-mWater Adapter is a program that is able to translate Sensus EMR meter reading CSVs to mWater meter reading accounting transactions.

It receives CSVs through HTTP POST requests, translates each line in the CSV to an mWater transaction, and assembles a final POST request to mWater's API.

Authentication

Sending clients must use Basic authentication.

The adapter authenticates with the mWater API using a username and password that are POSTed in exchange for a Client ID.

Usage

Process a Sensus CSV:

$ sensus-mwater-adapter input.csv

Process a Sensus CSV, but do not send the mWater HTTP requests.

$ sensus-mwater-adapter \
    --to-account abcd0123efgh4567ijkl8910 \
    --from-account abcd0123efgh4567ijkl8910 \
    --username mwateruser \
    --password hunter2 \
    --dry-run \
    input.csv

Configuration

  • username: mWater API username
  • password: mWater API password
  • to-account: Accounts receivable ID
  • from-account: Water sales ID
  • dry-run: Run the program but do not POST to mWater

Error Handling

For each CSV the adapter receives, the adapter attempts to parse as much of the CSV as possible, and constructs a request with all rows it was able to successfully parse. It logs all rows that it was unable to parse.

Logging

Diagnosis

Replay CSVs

Testing

From the root of the sensus-mwater-adapter checkout:

go test -v ./...

Go tests currently run in a GitHub Action on all pushes to main. Pass/fail status and coverage percentage are shown in badges on this README.

Contributing

Pull requests are always welcome. Please make sure to update tests as appropriate.

If you have any questions or comments, please feel free to open a GitHub issue to discuss.

Useful Documentation

mWater API

License

See LICENSE

About

Adapter to translate Sensus EMR Meter Reading CSVs to mWater Accounting Transactions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published