Class: InstantQuote::ConnectionTranslator

Inherits:
Object
  • Object
show all
Defined in:
lib/instant_quote/connection_translator.rb

Overview

Inherit from this class to create the translation from Finpoint’s app to the JSON that needs to be sent to the service you’re integrating. You’ll have access to ‘application` and `extra_info` from the application’s record.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection) ⇒ ConnectionTranslator

Returns a new instance of ConnectionTranslator.



16
17
18
19
20
# File 'lib/instant_quote/connection_translator.rb', line 16

def initialize(connection)
  @connection = connection
  @application = connection.finance_application
  @extra_info = ActiveSupport::HashWithIndifferentAccess.new(connection.extra_info)
end

Instance Attribute Details

#applicationObject

Returns the value of attribute application.



10
11
12
# File 'lib/instant_quote/connection_translator.rb', line 10

def application
  @application
end

#connectionObject

Returns the value of attribute connection.



10
11
12
# File 'lib/instant_quote/connection_translator.rb', line 10

def connection
  @connection
end

#extra_infoObject

Returns the value of attribute extra_info.



10
11
12
# File 'lib/instant_quote/connection_translator.rb', line 10

def extra_info
  @extra_info
end

Class Method Details

.translate(connection) ⇒ Object



12
13
14
# File 'lib/instant_quote/connection_translator.rb', line 12

def self.translate(connection)
  new(connection).translate
end

Instance Method Details

#translateObject

Raises:

  • (NotImplementedError)


22
23
24
# File 'lib/instant_quote/connection_translator.rb', line 22

def translate
  raise NotImplementedError, "You must implement '#{self.class.name}#translate'"
end