Skip to content

Commit

Permalink
Implements PriceQuote adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
alxberardi committed Apr 17, 2016
1 parent fbba68d commit a413aea
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
This changelog adheres to [Keep a CHANGELOG](http://keepachangelog.com/).

## [2.2.0] - Unreleased
### Added
- PriceQuote adapter

## [2.1.0] - 2016-04-13
### Added
- Resource categories
Expand Down
12 changes: 12 additions & 0 deletions lib/quick_travel/price_quote.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require 'quick_travel/adapter'

module QuickTravel
class PriceQuote < Adapter
self.api_base = '/api/price_quotes'

def self.calculate(params)
response = post_and_validate("#{api_base}/calculate", params)
new(response)
end
end
end
24 changes: 24 additions & 0 deletions spec/price_quote_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require 'spec_helper'

require 'quick_travel/price_quote'

describe QuickTravel::PriceQuote do
context 'when calculating' do
let(:reservation_params) {
{ resource_id: 805, quantity: 3, first_travel_date: '2016-04-15'}
}
let(:params) {
{ reservations: [reservation_params] }
}
let(:price_quote) { QuickTravel::PriceQuote.calculate(params) }

before do
VCR.use_cassette('price_quote') do
price_quote
end
end

specify { expect(price_quote.quoted_booking_gross.cents).to eq 7680 }
specify { expect(price_quote.applied_rules).to eq ['Special Offer'] }
end
end
61 changes: 61 additions & 0 deletions spec/support/cassettes/price_quote.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a413aea

Please sign in to comment.