Class: InstantQuote::Adapter

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

Constant Summary collapse

DEFAULT_ADDITIONAL_FIELDS =

This is one additional field that we always want to ask, since we’re using it for phone validating the applicant.

[
  {
    name: 'applicant_phone_number',
    label: 'Applicant mobile phone',
    required: true
  }
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.accept_offer(application_id, connection, offer_id) ⇒ Object



43
44
45
# File 'lib/instant_quote/adapter.rb', line 43

def self.accept_offer(application_id, connection, offer_id)
  new.accept_offer(application_id, connection, offer_id)
end

.additional_fields(fields = []) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/instant_quote/adapter.rb', line 15

def self.additional_fields(fields = [])
  return (@additional_fields || DEFAULT_ADDITIONAL_FIELDS) if fields.empty?

  @additional_fields ||= DEFAULT_ADDITIONAL_FIELDS
  @additional_fields += fields
  @additional_fields.uniq! { |f| f[:name] }
end

.get_approval(application_id, connection) ⇒ Object



39
40
41
# File 'lib/instant_quote/adapter.rb', line 39

def self.get_approval(application_id, connection)
  new.get_approval(application_id, connection)
end


23
24
25
# File 'lib/instant_quote/adapter.rb', line 23

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

.get_preapproval(params, connection) ⇒ Object



35
36
37
# File 'lib/instant_quote/adapter.rb', line 35

def self.get_preapproval(params, connection)
  new.get_preapproval(params, connection)
end

.get_quote(params, connection) ⇒ Object



27
28
29
# File 'lib/instant_quote/adapter.rb', line 27

def self.get_quote(params, connection)
  new.get_quote(params, connection)
end

.get_status(application_id, connection) ⇒ Object



31
32
33
# File 'lib/instant_quote/adapter.rb', line 31

def self.get_status(application_id, connection)
  new.get_status(application_id, connection)
end

Instance Method Details

#accept_offer(_application_id, _connection, _offer_id) ⇒ Object



69
70
71
# File 'lib/instant_quote/adapter.rb', line 69

def accept_offer(_application_id, _connection, _offer_id)
  true
end

#get_approval(_application_id, _connection) ⇒ Object

Default for approval will be success, override it in the adapter class if needed.



65
66
67
# File 'lib/instant_quote/adapter.rb', line 65

def get_approval(_application_id, _connection)
  OpenStruct.new(success?: true)
end

Raises:

  • (NotImplementedError)


47
48
49
# File 'lib/instant_quote/adapter.rb', line 47

def get_link(_connection)
  raise NotImplementedError, "You must implement '#{self.class.name}#get_link'"
end

#get_preapproval(_params, _connection) ⇒ Object

Default for pre approval will be success, override it in the adapter class if needed.



60
61
62
# File 'lib/instant_quote/adapter.rb', line 60

def get_preapproval(_params, _connection)
  OpenStruct.new(success?: true)
end

#get_quote(_params, _connection) ⇒ Object

Raises:

  • (NotImplementedError)


51
52
53
# File 'lib/instant_quote/adapter.rb', line 51

def get_quote(_params, _connection)
  raise NotImplementedError, "You must implement '#{self.class.name}#get_quote'"
end

#get_status(_application_id, _connection) ⇒ Object

Raises:

  • (NotImplementedError)


55
56
57
# File 'lib/instant_quote/adapter.rb', line 55

def get_status(_application_id, _connection)
  raise NotImplementedError, "You must implement '#{self.class.name}#get_status'"
end