Class: Interactions::Events::Rsvp

Inherits:
Object
  • Object
show all
Defined in:
lib/meetup_orbit/interactions/events/rsvp.rb

Instance Method Summary collapse

Constructor Details

#initialize(rsvp:, orbit_workspace:, orbit_api_key:) ⇒ Rsvp

Returns a new instance of Rsvp.



8
9
10
11
12
13
14
# File 'lib/meetup_orbit/interactions/events/rsvp.rb', line 8

def initialize(rsvp:, orbit_workspace:, orbit_api_key:)
  @rsvp = rsvp
  @orbit_workspace = orbit_workspace
  @orbit_api_key = orbit_api_key

  after_initialize!
end

Instance Method Details

#after_initialize!Object



16
17
18
19
20
21
22
23
24
# File 'lib/meetup_orbit/interactions/events/rsvp.rb', line 16

def after_initialize!
  OrbitActivities::Request.new(
    api_key: @orbit_api_key,
    workspace_id: @orbit_workspace,
    user_agent: "community-ruby-meetup-orbit/#{MeetupOrbit::VERSION}",
    action: "new_activity",
    body: construct_body.to_json
  )
end

#construct_bodyObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/meetup_orbit/interactions/events/rsvp.rb', line 26

def construct_body
  hash = {
    activity: {
      activity_type: "meetup:rsvp",
      tags: ["channel:meetup"],
      title: "New RSVP for #{@rsvp[:event]}",
      description: construct_description,
      occurred_at: @rsvp[:occurred_at],
      key: @rsvp[:id],
      link: @rsvp[:link],
      member: {
        name: @rsvp[:member_name]
      }
    },
    identity: {
      source: "meetup",
      name: @rsvp[:member_name],
      uid: @rsvp[:member_id]
    }
  }
end

#construct_descriptionObject



48
49
50
51
52
# File 'lib/meetup_orbit/interactions/events/rsvp.rb', line 48

def construct_description
  <<~HEREDOC
    #{@rsvp[:member_name]} has registered for #{@rsvp[:event]} in the #{@rsvp[:group]} Meetup group
  HEREDOC
end