Class: Vantiv::MockedSandbox::ApiRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/vantiv/mocked_sandbox/api_request.rb

Defined Under Namespace

Classes: FixtureNotFound

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(endpoint, request_body) ⇒ ApiRequest

Returns a new instance of ApiRequest.



10
11
12
13
# File 'lib/vantiv/mocked_sandbox/api_request.rb', line 10

def initialize(endpoint, request_body)
  self.endpoint = endpoint
  self.request_body = JSON.parse(request_body)
end

Class Method Details

.run(endpoint:, body:) ⇒ Object



6
7
8
# File 'lib/vantiv/mocked_sandbox/api_request.rb', line 6

def self.run(endpoint:, body:)
  new(endpoint, body).run
end

Instance Method Details

#runObject



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/vantiv/mocked_sandbox/api_request.rb', line 15

def run
  if endpoint == Api::Endpoints::TOKENIZATION
    if direct_post?
      load_fixture("tokenize_by_direct_post", card_number)
    end
  end
  {
    httpok: fixture["httpok"],
    http_response_code: fixture["http_response_code"],
    body: JSON.parse(ERB.new(fixture["response_body"]).result(binding))
  }
end