Sha256: 2719a1bd5eaa090371963530b560f2ff93c6ec281ac60e53e1504e894b9740e7

Contents?: true

Size: 712 Bytes

Versions: 1

Compression:

Stored size: 712 Bytes

Contents

module Commands::Groups::Invitation
  class Rsvp < RestPack::Service::Command
    required do
      integer :application_id
      integer :user_id
      string :access_key
      boolean :accept, default: true
    end

    def execute
      invitation = Models::Groups::Invitation.find_by({
        application_id: inputs[:application_id],
        access_key: inputs[:access_key]
      })

      if invitation
        if inputs[:accept]
          membership = invitation.accept(inputs[:user_id])
        else
          invitation.reject(inputs[:user_id])
        end

        Serializers::Groups::Invitation.serialize(invitation)
      else
        status :not_found unless invitation
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
restpack_group_service-0.0.8 lib/restpack_group_service/commands/invitation/rsvp.rb