lib/hubspot/connection.rb in hubspot-ruby-0.8.1 vs lib/hubspot/connection.rb in hubspot-ruby-0.9.0
- old
+ new
@@ -126,6 +126,34 @@
def self.submit(path, opts)
url = generate_url(path, opts[:params], { base_url: 'https://forms.hubspot.com', hapikey: false })
post(url, body: opts[:body], headers: { 'Content-Type' => 'application/x-www-form-urlencoded' })
end
end
+
+ class FilesConnection < Connection
+ follow_redirects true
+
+ class << self
+ def get(path, opts)
+ url = generate_url(path, opts)
+ response = super(url, read_timeout: read_timeout(opts), open_timeout: open_timeout(opts))
+ log_request_and_response url, response
+ raise(Hubspot::RequestError.new(response)) unless response.success?
+ response.parsed_response
+ end
+
+ def post(path, opts)
+ url = generate_url(path, opts[:params])
+ response = super(
+ url,
+ body: opts[:body],
+ headers: { 'Content-Type' => 'multipart/form-data' },
+ read_timeout: read_timeout(opts), open_timeout: open_timeout(opts)
+ )
+ log_request_and_response url, response, opts[:body]
+ raise(Hubspot::RequestError.new(response)) unless response.success?
+
+ response
+ end
+ end
+ end
end