Class: Microbilt::Requests::CreateForm

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/microbilt/requests/create_form.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#http_connection

Constructor Details

#initialize(options = nil) ⇒ CreateForm

Returns a new instance of CreateForm.



9
10
11
12
13
14
15
# File 'lib/microbilt/requests/create_form.rb', line 9

def initialize(options = nil)
  options.keys.each do |k|
    self.send("#{k}=", options[k])
  end if options

  do_not_request_phones = false if do_not_request_phones.nil?
end

Instance Attribute Details

#callback_typeObject

Returns the value of attribute callback_type.



7
8
9
# File 'lib/microbilt/requests/create_form.rb', line 7

def callback_type
  @callback_type
end

#callback_urlObject

Returns the value of attribute callback_url.



6
7
8
# File 'lib/microbilt/requests/create_form.rb', line 6

def callback_url
  @callback_url
end

#contact_byObject

Returns the value of attribute contact_by.



7
8
9
# File 'lib/microbilt/requests/create_form.rb', line 7

def contact_by
  @contact_by
end

#do_not_request_phonesObject

Returns the value of attribute do_not_request_phones.



7
8
9
# File 'lib/microbilt/requests/create_form.rb', line 7

def do_not_request_phones
  @do_not_request_phones
end

#final_urlObject

Returns the value of attribute final_url.



6
7
8
# File 'lib/microbilt/requests/create_form.rb', line 6

def final_url
  @final_url
end

Instance Method Details

#call(customer) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/microbilt/requests/create_form.rb', line 27

def call(customer)
  response = http_connection.post do |req|
    req.url Microbilt::Configuration::CREATE_FORM_URI
    req.headers['Content-Type'] = Microbilt::Configuration::CONTENT_TYPE
    req.params = all_params(customer)
  end

  handle_response(response)
end

#to_paramsObject



17
18
19
20
21
22
23
24
25
# File 'lib/microbilt/requests/create_form.rb', line 17

def to_params
  {
    'CallbackUrl' => callback_url,
    'CallbackType' => callback_type.to_s,
    'FinalURL' => final_url,
    'ContactBy' => contact_by.to_s.upcase,
    'DoNotRequestPhones' => do_not_request_phones.to_s
  }
end