Module: StripeMock::RequestHandlers::CountrySpec

Included in:
Instance
Defined in:
lib/stripe_mock/request_handlers/country_spec.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



5
6
7
# File 'lib/stripe_mock/request_handlers/country_spec.rb', line 5

def CountrySpec.included(klass)
  klass.add_handler 'get /v1/country_specs/(.*)', :retrieve_country_spec
end

Instance Method Details

#retrieve_country_spec(route, method_url, params, headers) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/stripe_mock/request_handlers/country_spec.rb', line 9

def retrieve_country_spec(route, method_url, params, headers)
  route =~ method_url

  unless ["AT", "AU", "BE", "CA", "DE", "DK", "ES", "FI", "FR", "GB", "IE", "IT", "JP", "LU", "NL", "NO", "SE", "SG", "US"].include?($1)
    raise Stripe::InvalidRequestError.new("#{$1} is not currently supported by Stripe.", $1.to_s)
  end

  country_spec[$1] ||= Data.mock_country_spec($1)

  assert_existence :country_spec, $1, country_spec[$1]
end