class TimeTree::BaseClient

Constants

API_HOST

Attributes

ratelimit_limit[R]

@return [Integer]

ratelimit_remaining[R]

@return [Integer]

ratelimit_reset_at[R]

@return [Time]

Public Instance Methods

update_ratelimit(res) click to toggle source

update ratelimit properties

@param res [Faraday::Response] apis http response.

# 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

Private Instance Methods

check_event_id(value) click to toggle source
# File lib/timetree/base_client.rb, line 29
def check_event_id(value)
  check_required_property(value, 'event_id')
end
check_required_property(value, name) click to toggle source
# File lib/timetree/base_client.rb, line 33
def check_required_property(value, name)
  err = Error.new "#{name} is required."
  raise err if value.nil?
  raise err if value.to_s.empty?

  true
end
relationships_params(relationships, default) click to toggle source
# File lib/timetree/base_client.rb, line 45
def relationships_params(relationships, default)
  params = {}
  relationships ||= default
  params[:include] = relationships.join ',' if relationships.is_a? Array
  params
end
to_model(data, included: nil) click to toggle source
# File lib/timetree/base_client.rb, line 41
def to_model(data, included: nil)
  TimeTree::BaseModel.to_model data, client: self, included: included
end