Class: TimeTree::BaseClient

Inherits:
Object
  • Object
show all
Defined in:
lib/timetree/base_client.rb

Direct Known Subclasses

CalendarApp::Client, OAuthApp::Client

Constant Summary collapse

API_HOST =
'https://timetreeapis.com'

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#ratelimit_limitInteger (readonly)

Returns:

  • (Integer)


7
8
9
# File 'lib/timetree/base_client.rb', line 7

def ratelimit_limit
  @ratelimit_limit
end

#ratelimit_remainingInteger (readonly)

Returns:

  • (Integer)


9
10
11
# File 'lib/timetree/base_client.rb', line 9

def ratelimit_remaining
  @ratelimit_remaining
end

#ratelimit_reset_atTime (readonly)

Returns:

  • (Time)


11
12
13
# File 'lib/timetree/base_client.rb', line 11

def ratelimit_reset_at
  @ratelimit_reset_at
end

Instance Method Details

#update_ratelimit(res) ⇒ Object

update ratelimit properties

apis http response.

Parameters:

  • res (Faraday::Response)


18
19
20
21
22
23
24
25
# File 'lib/timetree/base_client.rb', line 18

def update_ratelimit(res)
  limit = res.headers['x-ratelimit-limit']
  remaining = res.headers['x-ratelimit-remaining']
  reset = res.headers['x-ratelimit-reset']
  @ratelimit_limit = limit.to_i if limit
  @ratelimit_remaining = remaining.to_i if remaining
  @ratelimit_reset_at = Time.at reset.to_i if reset
end