GoPuff::TaxService
GoPuff Rails library to handle interaction with Tax Service
Installation
Add the gem to your project's Gemfile:
source 'https://rubygems.pkg.github.com/gopuff' do
gem 'go_puff-tax_service'
end
And then execute:
$ bundle install
Or install it yourself as:
gem install go_puff-tax_service --source "https://rubygems.pkg.github.com/gopuff"
Configuration example
GoPuff::TaxService.configure do |config|
config.logger = GoPuff::Logger
config.base_url = ENV['GOPUFF_TAX_SERVICE_BASE_URL']
config.requests.max_retries = 3
config.requests.retry_wait_time = 0.5
config.requests.retryable_exceptions = [EOFError, Errno::ECONNRESET]
config.user_agent_header = 'your header'
config.authentication.token_provider = -> { Apis::TaxService::Authentication.get_token }
config.authentication.on_unauthorized = -> { Apis::TaxService::Authentication.get_token(fresh: true) }
end
Gopuff::TaxService = GoPuff::TaxService
Usage
There are 3 main actions you can use: Get
, Commit
, Cancel
Get
. It is used for fee calculation:
order = ...
purchases = ...
fees_kind = 'all' || 'non_alcohol' || 'alcohol' || 'none'
GoPuff::TaxService::Actions::Get.new(order, purchases: purchases, fees_kind: 'all').call
Commit
It is used for confirming fee when order is finished:
order = ...
GoPuff::TaxService::Actions::Commit.new(order).call
Cancel
It is used for refund:
order = ...
GoPuff::TaxService::Actions::Cancel.new(order).call
Local development with docker
docker-compose run --rm go_puff-tax_service bash
Contributing
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Clone the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request