Class: MeetupOrbit::Meetup
- Inherits:
-
Object
- Object
- MeetupOrbit::Meetup
- Defined in:
- lib/meetup_orbit/meetup.rb
Instance Method Summary collapse
- #get_events ⇒ Object
- #get_rsvps(event) ⇒ Object
-
#initialize(params = {}) ⇒ Meetup
constructor
A new instance of Meetup.
- #process_event_rsvps ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Meetup
Returns a new instance of Meetup.
5 6 7 8 9 |
# File 'lib/meetup_orbit/meetup.rb', line 5 def initialize(params = {}) @meetup_urlname = params.fetch(:meetup_urlname) @orbit_api_key = params.fetch(:orbit_api_key) @orbit_workspace = params.fetch(:orbit_workspace) end |
Instance Method Details
#get_events ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/meetup_orbit/meetup.rb', line 41 def get_events url = URI("https://api.meetup.com/#{@meetup_urlname}/events") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Get.new(url) response = https.request(request) response = JSON.parse(response.body) end |
#get_rsvps(event) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/meetup_orbit/meetup.rb', line 54 def get_rsvps(event) url = URI("https://api.meetup.com/#{@meetup_urlname}/events/#{event}/rsvps") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Get.new(url) response = https.request(request) response = JSON.parse(response.body) end |
#process_event_rsvps ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/meetup_orbit/meetup.rb', line 11 def process_event_rsvps events = get_events events.each do |event| next if event["yes_rsvp_count"] <= 1 || event["yes_rsvp_count"].nil? rsvps = get_rsvps(event["id"]) rsvps.drop(1).each do |rsvp| # skip first item which is event owner MeetupOrbit::Orbit.call( type: "event_rsvp", data: { rsvp: { event: rsvp["event"]["name"], group: rsvp["group"]["name"], member_id: rsvp["member"]["id"], member_name: rsvp["member"]["name"], occurred_at: Time.at(rsvp["created"] / 1000).utc, id: "#{rsvp["member"]["id"]}-#{rsvp["event"]["id"]}", link: "https://meetup.com/#{@meetup_urlname}/events/#{rsvp["event"]["id"]}", response: rsvp["response"] } }, orbit_api_key: @orbit_api_key, orbit_workspace: @orbit_workspace ) end end end |