Class: Speedway::RapidAPI

Inherits:
Object
  • Object
show all
Defined in:
lib/speedway/rapid_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(customer_id, user_name, password) ⇒ RapidAPI

Returns a new instance of RapidAPI.



8
9
10
11
12
13
14
# File 'lib/speedway/rapid_api.rb', line 8

def initialize(customer_id, user_name, password)
  @client = initialize_client

  @customer_id = customer_id
  @user_name = user_name
  @password = password
end

Instance Attribute Details

#customer_idObject (readonly)

Returns the value of attribute customer_id.



6
7
8
# File 'lib/speedway/rapid_api.rb', line 6

def customer_id
  @customer_id
end

#passwordObject (readonly)

Returns the value of attribute password.



6
7
8
# File 'lib/speedway/rapid_api.rb', line 6

def password
  @password
end

#user_nameObject (readonly)

Returns the value of attribute user_name.



6
7
8
# File 'lib/speedway/rapid_api.rb', line 6

def user_name
  @user_name
end

Instance Method Details

#create_access_code(customer, custom_fields, payment, redirect_url) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/speedway/rapid_api.rb', line 17

def create_access_code(customer, custom_fields, payment, redirect_url)
  @client.request :create_access_code do
    soap.body = {
      'request' => {
        'Authentication' => credentials,
        'Customer' => {
          'FirstName'   => customer[:first_name],
          'LastName'    => customer[:last_name],
          'Street1'     => customer[:street_address_1],
          'City'        => customer[:suburb],
          'State'       => customer[:state],
          'PostalCode'  => customer[:postcode],
          'Mobile'      => customer[:mobile],
          'Email'       => customer[:email] 
        },
        'CustomFields' => {
          'Option1' => "System: #{custom_fields[:system]}",
          'Option2' => "Quote or Policy no.: #{custom_fields[:quote_number] || custom_fields[:policy_number]}"
        },
        'Payment' => {
          'TotalAmount' => (payment[:total_amount] * 100).to_i
        },
        'RedirectUrl' => redirect_url
      }
    }
  end
end

#get_access_code_result(access_code) ⇒ Object



46
47
48
49
50
51
52
53
54
55
# File 'lib/speedway/rapid_api.rb', line 46

def get_access_code_result(access_code)
  @client.request :get_access_code_result do
    soap.body = {
      'request' => {
        'Authentication' => credentials,
        'AccessCode' => access_code
      }
    }
  end
end