Module: BaiduLBS::Request
- Included in:
- Client
- Defined in:
- lib/baidu_lbs/request.rb
Instance Method Summary collapse
- #connection(options) ⇒ Object
- #get(path, params = {}, options = {}) ⇒ Object
- #post(path, params = {}, options = {}) ⇒ Object
- #request(method, path, params, options) ⇒ Object
Instance Method Details
#connection(options) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/baidu_lbs/request.rb', line 29 def connection() connection = Faraday.new(url: BaiduLBS.api_endpoint) do |builder| builder.request :multipart if [:multipart] builder.request :url_encoded builder.use FaradayMiddleware::ParseJson builder.adapter Faraday.default_adapter end connection end |
#get(path, params = {}, options = {}) ⇒ Object
6 7 8 |
# File 'lib/baidu_lbs/request.rb', line 6 def get(path, params = {}, = {}) request(:get, path, params, ) end |
#post(path, params = {}, options = {}) ⇒ Object
10 11 12 |
# File 'lib/baidu_lbs/request.rb', line 10 def post(path, params = {}, = {}) request(:post, path, params, ) end |
#request(method, path, params, options) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/baidu_lbs/request.rb', line 14 def request(method, path, params, ) params[:ak] = BaiduLBS.ak unless params[:ak] response = connection().send(method) do |request| case method when :get, :delete request.url(path, params) when :post, :put request.path = path request.body = params end end response.body end |