Class: Vantiv::MockedSandbox::ApiRequest
- Inherits:
-
Object
- Object
- Vantiv::MockedSandbox::ApiRequest
- Defined in:
- lib/vantiv/mocked_sandbox/api_request.rb
Defined Under Namespace
Classes: EndpointNotMocked, FixtureNotFound
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(endpoint, request_body, response_object) ⇒ ApiRequest
constructor
A new instance of ApiRequest.
- #run ⇒ Object
Constructor Details
#initialize(endpoint, request_body, response_object) ⇒ ApiRequest
Returns a new instance of ApiRequest.
16 17 18 19 20 |
# File 'lib/vantiv/mocked_sandbox/api_request.rb', line 16 def initialize(endpoint, request_body, response_object) self.endpoint = endpoint self.request_body = request_body self.response_object = response_object end |
Class Method Details
.run(endpoint:, body:, response_object:) ⇒ Object
12 13 14 |
# File 'lib/vantiv/mocked_sandbox/api_request.rb', line 12 def self.run(endpoint:, body:, response_object:) new(endpoint, body, response_object).run end |
Instance Method Details
#run ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/vantiv/mocked_sandbox/api_request.rb', line 22 def run if endpoint == Api::Endpoints::TOKENIZATION if direct_post? load_fixture("tokenize_by_direct_post", card_number) else load_fixture("tokenize", temporary_token) end elsif endpoint == Api::Endpoints::SALE load_fixture("auth_capture", card_number_from_payment_account_id) elsif endpoint == Api::Endpoints::AUTHORIZATION load_fixture("auth", card_number_from_payment_account_id) elsif endpoint == Api::Endpoints::CAPTURE load_fixture("capture") elsif endpoint == Api::Endpoints::AUTH_REVERSAL load_fixture("auth_reversal") elsif endpoint == Api::Endpoints::CREDIT load_fixture("credit") elsif endpoint == Api::Endpoints::RETURN load_fixture("refund", card_number_from_payment_account_id) elsif endpoint == Api::Endpoints::VOID load_fixture("void") else raise EndpointNotMocked.new("#{endpoint} is not mocked!") end end |