Class: ExperianAddressValidation::Operation

Inherits:
Object
  • Object
show all
Defined in:
lib/experian_address_validation/operation.rb

Overview

Base class for API operations

Constant Summary collapse

DEFAULT_HEADERS =
{
  content_type: "application/json"
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Operation

Returns a new instance of Operation.



10
11
12
# File 'lib/experian_address_validation/operation.rb', line 10

def initialize(options = {})
  @options = options
end

Instance Method Details

#executeObject



14
15
16
17
18
19
20
21
22
# File 'lib/experian_address_validation/operation.rb', line 14

def execute
  http_client.headers["Auth-Token"] = auth_token

  response = http_client.run_request(http_method, endpoint, json_payload, headers)

  return json_response(response) if response.success?

  raise ExperianAddressValidation::Errors::ResponseError.new(body: response.body, status: response.status)
end

#http_methodObject



24
25
26
# File 'lib/experian_address_validation/operation.rb', line 24

def http_method
  :post
end