Skip to content
This repository has been archived by the owner on Jun 16, 2023. It is now read-only.

Latest commit

 

History

History
90 lines (47 loc) · 4.17 KB

README.md

File metadata and controls

90 lines (47 loc) · 4.17 KB

Amazon Dash Replenishment Service SDK for Go

GoDoc Maintainability Build Status Test Coverage

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.

Deprecation and Maintenance

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!

Installing

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

Usage

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

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.

Contributing

Pull Requests are welcome! See our CONTRIBUTING.md file for more information.

Third-party Libraries

The following libraries are used in this project. We thank the creators and maintainers for making our lives easier!

Resty

Logrus

Testify

Mapstructure

Endpoints Implemented

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

Todos

[ ] Convert to modules

[ ] Document examples of the code

[ ] Build out API integration example application