lib/mad_mimi/request.rb in mad_mimi-0.0.1 vs lib/mad_mimi/request.rb in mad_mimi-0.0.2
- old
+ new
@@ -6,17 +6,17 @@
module Request
def get(path, options={}, raw = false)
request(:get, path, options, raw)
end
- def post(path, options={}, raw = false)
- request(:post, path, options, raw)
+ def post(path, options={}, raw = false, ssl = false)
+ request(:post, path, options, raw, ssl)
end
private
- def request(method, path, options, raw = false)
- response = connection(raw).send(method) do |request|
+ def request(method, path, options, raw = false, ssl = false)
+ response = connection(raw, ssl).send(method) do |request|
options = options.merge(MadMimi.authentication)
case method
when :get
request.url(path, options)
when :post
@@ -25,14 +25,14 @@
end
end
raw ? response : response.body
end
- def connection(raw = false)
+ def connection(raw = false, ssl = false)
options = {
:headers => {'Accept' => "application/xml", 'User-Agent' => 'MadMimi Gem'},
:ssl => { :verify => false },
- :url => MadMimi.api_url
+ :url => MadMimi.api_url(ssl)
}
Faraday::Connection.new(options) do |builder|
builder.adapter Faraday.default_adapter
unless raw
\ No newline at end of file