Class: TheCity::ApiReader
- Inherits:
-
Object
- Object
- TheCity::ApiReader
- Defined in:
- lib/readers/api_reader.rb
Overview
This adapter is the standard for all loading objects.
Direct Known Subclasses
AddressListReader, AddressReader, CampusListReader, CheckinListByCallboardNumberReader, CheckinListByPagerNumberReader, CheckinListReader, CheckinReader, ChurchReader, DonationExportListReader, DonationExportReader, DonationListReader, DonationReader, FamilyReader, FundListReader, FundReader, GroupAddressListReader, GroupCheckinEventsListReader, GroupCheckinListReader, GroupCheckinReader, GroupEventAttendanceListReader, GroupExportListReader, GroupExportReader, GroupInvitationListReader, GroupListReader, GroupReader, GroupRoleListReader, GroupTagListReader, InvitationListReader, MetricListReader, MetricMeasurementListReader, MetricMeasurementReader, MetricMeasurementValuesReader, MetricReader, PledgeListReader, PledgeReader, RoleListReader, SkillListReader, SkillReader, SkilledUserIdListReader, SkilledUserListReader, TagGroupListReader, TagListReader, TagReader, TerminologyListReader, TerminologyReader, UserAddressListReader, UserAdminPrivilegeListReader, UserCountReader, UserFamilyListReader, UserInvitationListReader, UserListReader, UserNoteListReader, UserProcessAnswerListReader, UserProcessListReader, UserReader, UserRoleListReader, UserSkillListReader, WebHookListReader
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
Instance Method Summary collapse
-
#load_feed ⇒ Object
Loads the list.
-
#rate_limit ⇒ Object
Returns either the value of the x-city-ratelimit-limit-by-ip header or x-city-ratelimit-limit-by-account header, whichever is lower.
-
#rate_limit_remaining ⇒ Object
Returns either the value of the x-city-ratelimit-remaining-by-ip header or x-city-ratelimit-remaining-by-account header, whichever is lower.
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
5 6 7 |
# File 'lib/readers/api_reader.rb', line 5 def headers @headers end |
Instance Method Details
#load_feed ⇒ Object
Loads the list
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/readers/api_reader.rb', line 14 def load_feed # if [email protected]? and [email protected]_cache_expired?( @class_key ) # data = @cacher.get_data( @class_key ) # else @url_data_params ||= {} @url_data_params = stringify_array_params(@url_data_params) response = TheCity::admin_request(:get, @url_data_path, @url_data_params) data = JSON.parse(response.body) @headers = response.headers @cacher.save_data(@class_key, data) unless @cacher.nil? #end return data end |
#rate_limit ⇒ Object
Returns either the value of the x-city-ratelimit-limit-by-ip header or x-city-ratelimit-limit-by-account header, whichever is lower.
31 32 33 34 35 |
# File 'lib/readers/api_reader.rb', line 31 def rate_limit if @headers [@headers['X-City-RateLimit-Limit-By-Ip'].to_i, @headers['X-City-RateLimit-Limit-By-Account'].to_i].min end end |
#rate_limit_remaining ⇒ Object
Returns either the value of the x-city-ratelimit-remaining-by-ip header or x-city-ratelimit-remaining-by-account header, whichever is lower.
39 40 41 42 43 |
# File 'lib/readers/api_reader.rb', line 39 def rate_limit_remaining if @headers [@headers['X-City-RateLimit-Remaining-By-Ip'].to_i, @headers['X-City-RateLimit-Remaining-By-Account'].to_i].min end end |