Class: SPOT::ApiService
- Inherits:
-
Object
- Object
- SPOT::ApiService
- Defined in:
- lib/spot-gps/api_service.rb
Instance Method Summary collapse
-
#get(path:, params: {}) ⇒ Object
Make a GET request to the SPOT API.
-
#initialize(feed_id:, feed_password: nil) ⇒ ApiService
constructor
A new instance of ApiService.
Constructor Details
#initialize(feed_id:, feed_password: nil) ⇒ ApiService
Returns a new instance of ApiService.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/spot-gps/api_service.rb', line 6 def initialize(feed_id:, feed_password: nil) @feed_id = feed_id @feed_password = feed_password = { request: { timeout: SPOT.read_timeout, open_timeout: SPOT.open_timeout } } @connection = Faraday.new(base_uri, ) do |f| f.adapter Faraday::Adapter::NetHttp end end |
Instance Method Details
#get(path:, params: {}) ⇒ Object
Make a GET request to the SPOT API
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/spot-gps/api_service.rb', line 24 def get(path:, params: {}) params ||= {} if feed_password && !feed_password.empty? params = params.merge(feedPassword: feed_password) end response = make_request(:get, path, params) SPOT::ApiResponse.new(response) end |