GoPuff::TaxService

Coverage Status

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

# config/initializers/tax_service.rb

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.

  1. Clone the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request