Sha256: 696d397b8ab9461f3392c497288db8fbe8c3da8776beb6d267a6f757e2c24295

Contents?: true

Size: 1.39 KB

Versions: 2

Compression:

Stored size: 1.39 KB

Contents

# frozen_string_literal: true

require "json"

module MeetupOrbit
  module Interactions::Events
    class Rsvp
      def initialize(rsvp:, orbit_workspace:, orbit_api_key:)
        @rsvp = rsvp
        @orbit_workspace = orbit_workspace
        @orbit_api_key = orbit_api_key

        after_initialize!
      end

      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

      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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
meetup_orbit-0.1.1 lib/meetup_orbit/interactions/events/rsvp.rb
meetup_orbit-0.1.0 lib/meetup_orbit/interactions/events/rsvp.rb