This library serves as a simple SDK for the Amazon Dash Replenishment Service. While trying to integrate with DRS, no official SDK existed. Given the small footprint of the API, a quick SDK was started until an official SDK is released.
Unfortunately, this repository is no longer being maintained. If you would like to take over maintenance of the repository, please open up an issue in this repository or otherwise contact us. We apologize if this is an inconvenience at all. We are going to freeze this archive. Feel free to fork it as you desire. Best of luck!
You can simply install the package:
go get github.com/getwagz/drs-sdk
Or if you are using dep
:
dep ensure -add github.com/getwagz/drs-sdk
First, there are some optional environment variables (with hopefully sane defaults):
DRS_SDK_ENV
is the environment the SDK is running in; defaults to development
which turns on logging
DRS_SDK_ROOT_URL
is the root URL for the DRS service, defaults to https://dash-replenishment-service-na.amazon.com/
Most calls require at a minimum the deviceToken
which is the access token for the device obtained from Login With Amazon / DRS. The scope needed is dash:replenish
. Refreshing this token is not the responsibility of this library.
Testing can be tricky, as you don't want to make actual network calls with user data. Therefore, in the endpoints.go
file where we setup the supported endpoints, we also have a MockGood
field which holds JSON of what the call should return based upon the V2 docs found here.
When testing, if the auth token is set to TEST
, the mock data will be used instead.
Since we are mocking the calls, some of the code is tougher to test, so code coverage will likely never be 100%.
To run the tests, run
go test
For coverage in HTML format, run
go test -coverprofile=coverage.out && go tool cover -html=coverage.out
The coverage is notably lower than ideal, which may cause concerns. However, most of the uncovered calls would be calls directly to Amazon, which we cannot easily mock in success conditions, that are malformed. Feel free to check the results of the coverage report to see what exactly isn't covered and make a determination if that is acceptable to you. This library is currently being used in production.
Pull Requests are welcome! See our CONTRIBUTING.md
file for more information.
The following libraries are used in this project. We thank the creators and maintainers for making our lives easier!
Subscription Info API Docs
Deregistration API Docs
Device Status API Docs
Slot Status API Docs
Get Order Info API Docs
Replenish API Docs
Cancel Test Order API Docs
[ ] Convert to modules
[ ] Document examples of the code
[ ] Build out API integration example application