class Meetup::MeetupApi
Meetup
api
Constants
- API_URL
- API_VERSION
- LOG_LOCATION
- VERSIONED_API_URL
Public Class Methods
access_key()
click to toggle source
Grabs the api ket from config file inside the config directory
# File lib/meetupevents/meetupevents.rb, line 13 def self.access_key return @access_key if @access_key if ENV['MEETUP_API_KEY'].nil? puts 'MEETUP_API_KEY environment variable not found! Please define it.' else @access_key = ENV['MEETUP_API_KEY'] end end
cities_info(id)
click to toggle source
# File lib/meetupevents/meetupevents.rb, line 43 def self.cities_info(id) api_url = URI.join(API_URL, "/#{API_VERSION}/", 'cities') escaped_id = "id+=+#{id}" cities2_response = HTTP.get(api_url, params: { query: URI.encode(escaped_id), signed: true, key: access_key }) response = JSON.parse(cities2_response.to_s) # add_log(response, "city_id_#{id}") response['results'] end
config()
click to toggle source
# File lib/meetupevents/meetupevents.rb, line 26 def self.config return @config if @config @config = { access_key: ENV['MEETUP_API_KEY'] } end
config=(credentials)
click to toggle source
# File lib/meetupevents/meetupevents.rb, line 22 def self.config=(credentials) @config ? @config.update(credentials) : @config = credentials end
find_group_by_url(urlname)
click to toggle source
Finds groups based on a location text query
# File lib/meetupevents/meetupevents.rb, line 109 def self.find_group_by_url(urlname) urlname = CGI.escape(urlname) api_url = URI.join(API_URL, "/#{urlname}") groups_response = HTTP.get(api_url, params: { signed: true, key: access_key }) response = JSON.parse(groups_response.to_s) # add_log(response, "group_with_url_#{urlname}") response end
get_cities(country_code)
click to toggle source
Gets cities based on country code (ex. tw)
# File lib/meetupevents/meetupevents.rb, line 32 def self.get_cities(country_code) api_url = URI.join(VERSIONED_API_URL, '/cities/') cities_response = HTTP.get(api_url, params: { country: country_code, signed: true, key: access_key }) response = JSON.parse(cities_response.to_s) # add_log(response, "cities_#{country_code}") response['results'] end
get_cities_by_country(country)
click to toggle source
Get all cities of a country
# File lib/meetupevents/meetupevents.rb, line 56 def self.get_cities_by_country(country) api_url = URI.join(API_URL, "/#{API_VERSION}/", 'cities') cities_response = HTTP.get(api_url, params: { country: country, signed: true, key: access_key }) response = JSON.parse(cities_response.to_s) # add_log(response, "events_at_#{place}") response end
get_events_city(country, city, topic)
click to toggle source
# File lib/meetupevents/meetupevents.rb, line 80 def self.get_events_city(country, city, topic) params = { country: country, city: city, topic: topic, signed: true, key: access_key } params.tap{ |h| h.delete(:topic) } unless topic != 'none' api_url = URI.join(API_URL, "/#{API_VERSION}/", 'open_events') events_response = HTTP.get(api_url, params: params) response = JSON.parse(events_response.to_s) # add_log(response, "events_at_#{place}") response['results'] end
get_events_location(lat, lon)
click to toggle source
Gets events based on the location. Place var just for fixtures
# File lib/meetupevents/meetupevents.rb, line 68 def self.get_events_location(lat, lon) api_url = URI.join(API_URL, '/find/events/') events_response = HTTP.get(api_url, params: { lon: lon, lat: lat, signed: true, key: access_key }) response = JSON.parse(events_response.to_s) # add_log(response, "events_at_#{place}") response end
get_groups(country_code, location_raw_text)
click to toggle source
Finds groups based on a location text query
# File lib/meetupevents/meetupevents.rb, line 96 def self.get_groups(country_code, location_raw_text) api_url = URI.join(API_URL, '/find/groups') groups_response = HTTP.get(api_url, params: { country: country_code, fallback_suggestions: 'true', location: location_raw_text, key: access_key }) response = JSON.parse(groups_response.to_s) # add_log(response, "groups_at_#{location_raw_text}") response end