Module: Seametrix
Constant Summary
collapse
- Routes =
SeametrixRuby::Services::Routes
- Ports =
SeametrixRuby::Services::Ports
- ResultCode =
SeametrixRuby::Responses::ResultCode
SeametrixRuby::Configuration::DEFAULT_BASE_URL, SeametrixRuby::Configuration::OPTIONS
Class Method Summary
collapse
configure, reset
Class Method Details
.connection(base_url, raw: false) ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/seametrix.rb', line 39
def self.connection(base_url, raw: false)
options = {
ssl: { verify: false },
url: base_url,
headers: {
'User-Agent' => "SeametrixRuby #{SeametrixRuby::VERSION}",
'Content-Type' => 'application/json',
'Accept' => 'application/json'
}
}
Faraday::Connection.new(options) do |conn|
conn.request :json
conn.use Faraday::Request::UrlEncoded
conn.use Faraday::Response::Logger, logger, { bodies: debugging }
unless raw
conn.use FaradayMiddleware::Mashify
conn.use Faraday::Response::ParseJson
end
end
end
|
.request(path, method: :get, raw: false, params: {}) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/seametrix.rb', line 21
def self.request(path, method: :get, raw: false, params: {})
options = { 'AccessKey' => access_key }
resp = connection(base_url, raw: raw).send(method) do |req|
case method
when :post
body = params.delete(:body)
req.path = path
req.params = options
req.body = body.to_json if body
else
req.url path, options.merge(params.try(:[], :body) || params)
end
end
raw ? resp : resp.body
end
|