class Bambora::ResponseAdapterFactory
Selects an adapter for parsing an HTTP response body
Public Class Methods
for(response)
click to toggle source
# File lib/bambora/factories/response_adapter_factory.rb, line 8 def for(response) content_type = response.headers['Content-Type'].split(';').first case content_type when 'application/json' Bambora::JSONResponse.new(response) when 'text/html' # Currently, the only endpoint that responds with text/html is /scripts/payment_profiles.asp Bambora::Bank::Adapters::PaymentProfileResponse.new(response) else raise Bambora::Client::Error, "Unknown Content Type: #{content_type}. Response Body: #{response.body}" end end