Class: PayjpMock::Request
- Inherits:
-
Object
- Object
- PayjpMock::Request
- Includes:
- WebMock::API
- Defined in:
- lib/payjp_mock/request.rb
Constant Summary collapse
- API_HOST =
'api.pay.jp'.freeze
- API_VERSION =
'v1'.freeze
- API_BASE =
"https://#{API_HOST}/#{API_VERSION}".freeze
Instance Method Summary collapse
-
#initialize(method, path_pattern, params, response) ⇒ Request
constructor
A new instance of Request.
- #stub ⇒ Object
Constructor Details
#initialize(method, path_pattern, params, response) ⇒ Request
Returns a new instance of Request.
12 13 14 15 16 17 |
# File 'lib/payjp_mock/request.rb', line 12 def initialize(method, path_pattern, params, response) @method = method @url = Addressable::Template.new(API_BASE + path_pattern) @params = params.deep_transform_values(&:to_s) @response = response end |
Instance Method Details
#stub ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/payjp_mock/request.rb', line 19 def stub stub_request(@method, @url) .with(body: @params) .to_return(body: @response.body, status: @response.status, exception: @response.exception) JSON.parse(@response.body || '{}').symbolize_keys end |