Skip to content

Commit

Permalink
Merge pull request #412 from roomorama/release/0.12.0
Browse files Browse the repository at this point in the history
Release/0.12.0
  • Loading branch information
keang authored Oct 5, 2016
2 parents b03b3d3 + ba21145 commit 0cf770f
Show file tree
Hide file tree
Showing 171 changed files with 7,705 additions and 299 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ ROOMORAMA_SECRET_ATLEISURE=xxx
ROOMORAMA_SECRET_POPLIDAYS=xxx
ROOMORAMA_SECRET_CIIRUS=xxx
ROOMORAMA_SECRET_SAW=xxx
ROOMORAMA_SECRET_RENTALS_UNITED=xxx
ROLLBAR_ACCESS_TOKEN=not_used_in_development
CONCIERGE_WEB_APP_SECRET=12345
SERVE_STATIC_ASSETS=true
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ This file summarises the most important changes that went live on each release
of Concierge. Please check the Wiki entry on the release process to understand
how this file is formatted and how the process works.

## [0.12.0] - 2016-10-05
### Added
- Rentals Untied sync, quote, book and cancel

### Changed
- Abstract host fee calculation from suppliers to entity level
- Return 404 for attempts to quote a property not in records

## [0.11.6] - 2016-10-03
### Fixed
- Proper order of table columns for sync_process/index page
Expand Down
1 change: 1 addition & 0 deletions apps/api/config/environment_variables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
- ROOMORAMA_SECRET_WAYTOSTAY
- ROOMORAMA_SECRET_CIIRUS
- ROOMORAMA_SECRET_SAW
- ROOMORAMA_SECRET_RENTALS_UNITED
- ZENDESK_NOTIFY_URL
17 changes: 9 additions & 8 deletions apps/api/config/initializers/validate_supplier_credentials.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

if enforce_on_envs.include?(Hanami.env)
Concierge::Credentials.validate_credentials!({
atleisure: %w(username password test_mode),
jtb: %w(id user password company url),
kigo: %w(subscription_key),
kigolegacy: %w(username password),
waytostay: %w(client_id client_secret url token_url),
ciirus: %w(url username password),
saw: %w(username password url),
poplidays: %w(url client_key passphrase)
atleisure: %w(username password test_mode),
jtb: %w(id user password company url),
kigo: %w(subscription_key),
kigolegacy: %w(username password),
waytostay: %w(client_id client_secret url token_url),
ciirus: %w(url username password),
saw: %w(username password url),
poplidays: %w(url client_key passphrase),
rentalsunited: %w(username password url)
})
end
49 changes: 26 additions & 23 deletions apps/api/config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
post '/atleisure/quote', to: 'at_leisure#quote'
post '/jtb/quote', to: 'j_t_b#quote'
post '/kigo/quote', to: 'kigo#quote'
post '/kigo/legacy/quote', to: 'kigo/legacy#quote'
post '/poplidays/quote', to: 'poplidays#quote'
post '/ciirus/quote', to: 'ciirus#quote'
post '/waytostay/quote', to: 'waytostay#quote'
post '/saw/quote', to: 's_a_w#quote'
post '/atleisure/quote', to: 'at_leisure#quote'
post '/jtb/quote', to: 'j_t_b#quote'
post '/kigo/quote', to: 'kigo#quote'
post '/kigo/legacy/quote', to: 'kigo/legacy#quote'
post '/poplidays/quote', to: 'poplidays#quote'
post '/ciirus/quote', to: 'ciirus#quote'
post '/waytostay/quote', to: 'waytostay#quote'
post '/saw/quote', to: 's_a_w#quote'
post '/rentalsunited/quote', to: 'rentals_united#quote'

post '/jtb/booking', to: 'j_t_b#booking'
post '/atleisure/booking', to: 'at_leisure#booking'
post '/waytostay/booking', to: 'waytostay#booking'
post '/ciirus/booking', to: 'ciirus#booking'
post '/kigo/booking', to: 'kigo#booking'
post '/kigo/legacy/booking', to: 'kigo/legacy#booking'
post '/saw/booking', to: 's_a_w#booking'
post '/poplidays/booking', to: 'poplidays#booking'
post '/jtb/booking', to: 'j_t_b#booking'
post '/atleisure/booking', to: 'at_leisure#booking'
post '/waytostay/booking', to: 'waytostay#booking'
post '/ciirus/booking', to: 'ciirus#booking'
post '/kigo/booking', to: 'kigo#booking'
post '/kigo/legacy/booking', to: 'kigo/legacy#booking'
post '/saw/booking', to: 's_a_w#booking'
post '/poplidays/booking', to: 'poplidays#booking'
post '/rentalsunited/booking', to: 'rentals_united#booking'

post '/waytostay/cancel', to: 'waytostay#cancel'
post '/ciirus/cancel', to: 'ciirus#cancel'
post '/saw/cancel', to: 's_a_w#cancel'
post '/kigo/cancel', to: 'kigo#cancel'
post '/kigo/legacy/cancel', to: 'kigo/legacy#cancel'
post '/poplidays/cancel', to: 'poplidays#cancel'
post '/atleisure/cancel', to: 'at_leisure#cancel'
post '/waytostay/cancel', to: 'waytostay#cancel'
post '/ciirus/cancel', to: 'ciirus#cancel'
post '/saw/cancel', to: 's_a_w#cancel'
post '/kigo/cancel', to: 'kigo#cancel'
post '/kigo/legacy/cancel', to: 'kigo/legacy#cancel'
post '/poplidays/cancel', to: 'poplidays#cancel'
post '/atleisure/cancel', to: 'at_leisure#cancel'
post '/rentalsunited/cancel', to: 'rentals_united#cancel'

post '/checkout', to: 'static#checkout'
get '/kigo/image/:property_id/:image_id', to: 'kigo#image'
23 changes: 18 additions & 5 deletions apps/api/controllers/quote.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ def self.included(base)

def call(params)
if params.valid?
return status 500, error_response("No supplier record in database.") unless supplier
return status 404, error_response("Property not found") unless property_exists?(params[:property_id])

quotation_result = quote_price(params)

if quotation_result.success?
Expand All @@ -54,16 +57,16 @@ def call(params)
else
announce_error(quotation_result)
error_message = quotation_result.error.data || { quote: GENERIC_ERROR }
status 503, invalid_request(error_message)
status 503, error_response(error_message)
end
else
status 422, invalid_request(params.error_messages)
status 422, error_response(params.error_messages)
end
end

private

def invalid_request(errors)
def error_response(errors)
response = { status: "error" }.merge!(errors: errors)
json_encode(response)
end
Expand All @@ -78,6 +81,15 @@ def announce_error(result)
})
end

def property_exists?(id)
! PropertyRepository.identified_by(id).
from_supplier(supplier).first.nil?
end

def supplier
@supplier ||= SupplierRepository.named supplier_name
end

# Get the quote result from client implementations.
#
# The +params+ argument given is an instance of +API::Controllers::Params::Quote+.
Expand All @@ -95,8 +107,9 @@ def quote_price(params)
raise NotImplementedError
end

# This is used when reporting errors from the supplier.
# Should return a string
# Should return a string.
# This is used when reporting error and
# searching for property
def supplier_name
raise NotImplementedError
end
Expand Down
31 changes: 31 additions & 0 deletions apps/api/controllers/rentals_united/booking.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
require_relative "../booking"
require_relative "../params/booking"

module API::Controllers::RentalsUnited

# +API::Controllers::RentalsUnited::Booking+
#
# Performs create booking for properties from RentalsUnited.
class Booking
include API::Controllers::Booking

params API::Controllers::Params::Booking

# Make property booking request
#
# Usage
#
# It returns a +Reservation+ object in both success and fail cases:
#
# API::Controllers::RentalsUnited::Booking.create_booking(selected_params)
# => Reservation(..)
def create_booking(params)
credentials = Concierge::Credentials.for(supplier_name)
RentalsUnited::Client.new(credentials).book(params)
end

def supplier_name
RentalsUnited::Client::SUPPLIER_NAME
end
end
end
21 changes: 21 additions & 0 deletions apps/api/controllers/rentals_united/cancel.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require_relative "../cancel"

module API::Controllers::RentalsUnited
# +API::Controllers::RentalsUnited::Cancel+
#
# Cancels reservation from RentalsUnited.
class Cancel
include API::Controllers::Cancel

params API::Controllers::Params::Cancel

def cancel_reservation(params)
credentials = Concierge::Credentials.for(supplier_name)
RentalsUnited::Client.new(credentials).cancel(params)
end

def supplier_name
RentalsUnited::Client::SUPPLIER_NAME
end
end
end
25 changes: 25 additions & 0 deletions apps/api/controllers/rentals_united/quote.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require_relative "../quote"

module API::Controllers::RentalsUnited
# API::Controllers::RentalsUnited::Quote
#
# Performs booking quotations for properties from RentalsUnited.
class Quote
include API::Controllers::Quote

params API::Controllers::Params::Quote

# Make price (property rate) request
#
# Returns a +Result+ wrapping a +Quotation+ when operation succeeds
# Returns a +Result+ with +Result::Error+ when operation fails
def quote_price(params)
credentials = Concierge::Credentials.for(supplier_name)
RentalsUnited::Client.new(credentials).quote(params)
end

def supplier_name
RentalsUnited::Client::SUPPLIER_NAME
end
end
end
17 changes: 9 additions & 8 deletions apps/api/middlewares/authentication.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,15 @@ class Authentication
# secrets.for(request_path) # => X32842I
class Secrets
APP_SECRETS = {
"/jtb" => ENV["ROOMORAMA_SECRET_JTB"],
"/kigo/legacy" => ENV["ROOMORAMA_SECRET_KIGO_LEGACY"],
"/kigo" => ENV["ROOMORAMA_SECRET_KIGO"],
"/atleisure" => ENV["ROOMORAMA_SECRET_ATLEISURE"],
"/poplidays" => ENV["ROOMORAMA_SECRET_POPLIDAYS"],
"/waytostay" => ENV["ROOMORAMA_SECRET_WAYTOSTAY"],
"/ciirus" => ENV["ROOMORAMA_SECRET_CIIRUS"],
"/saw" => ENV["ROOMORAMA_SECRET_SAW"]
"/jtb" => ENV["ROOMORAMA_SECRET_JTB"],
"/kigo/legacy" => ENV["ROOMORAMA_SECRET_KIGO_LEGACY"],
"/kigo" => ENV["ROOMORAMA_SECRET_KIGO"],
"/atleisure" => ENV["ROOMORAMA_SECRET_ATLEISURE"],
"/poplidays" => ENV["ROOMORAMA_SECRET_POPLIDAYS"],
"/waytostay" => ENV["ROOMORAMA_SECRET_WAYTOSTAY"],
"/ciirus" => ENV["ROOMORAMA_SECRET_CIIRUS"],
"/saw" => ENV["ROOMORAMA_SECRET_SAW"],
"/rentalsunited" => ENV["ROOMORAMA_SECRET_RENTALS_UNITED"]
}

attr_reader :mapping
Expand Down
Loading

0 comments on commit 0cf770f

Please sign in to comment.