Class: StravaApi::Base
- Inherits:
-
Object
- Object
- StravaApi::Base
- Defined in:
- lib/strava-api/base.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
- #call(command, key, options) ⇒ Object
-
#initialize ⇒ Base
constructor
A new instance of Base.
Methods included from Efforts
Methods included from Segments
#segment_efforts, #segment_show, #segments
Methods included from Rides
#ride_efforts, #ride_show, #ride_streams, #rides
Methods included from Clubs
#club_members, #club_show, #clubs
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
15 16 17 |
# File 'lib/strava-api/base.rb', line 15 def initialize @errors = [] end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
13 14 15 |
# File 'lib/strava-api/base.rb', line 13 def errors @errors end |
Instance Method Details
#call(command, key, options) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/strava-api/base.rb', line 19 def call(command, key, ) begin result = self.class.get("/#{command}", :query => ) rescue HTTParty::UnsupportedFormat, HTTParty::UnsupportedURIScheme, HTTParty::ResponseError, HTTParty::RedirectionTooDeep raise NetworkError.new end if result && result.parsed_response == "<html><body><h1>500 Internal Server Error</h1></body></html>" @errors << "Strava returned a 500 error" raise CommandError.new end @errors << result["error"] if result && result["error"] raise InvalidResponseError.new if result.nil? || !result["error"].blank? || (!key.nil? && result[key].nil?) result end |