Class: TelephoneAppointments::Api

Inherits:
Object
  • Object
show all
Defined in:
lib/telephone_appointments/api.rb

Constant Summary collapse

SSL_PORT =
443

Instance Method Summary collapse

Instance Method Details

#post(path, form_data = nil) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/telephone_appointments/api.rb', line 7

def post(path, form_data = nil)
  uri = URI.parse("#{api_uri}#{path}")
  http = Net::HTTP.new(uri.host, uri.port)
  http.read_timeout = read_timeout
  http.use_ssl = true if uri.port == SSL_PORT
  request = Net::HTTP::Post.new(uri.request_uri, headers)
  request.set_form_data(form_data) if form_data

  TelephoneAppointments::Response.new(http.request(request))
end