2022-01-02 15:31:55 -08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module UseCase
|
|
|
|
module Relationship
|
|
|
|
class Create < UseCase::Base
|
2022-06-11 14:10:20 -07:00
|
|
|
option :source_user, type: Types.Instance(::User)
|
|
|
|
option :target_user, type: Types.Instance(::User)
|
2022-01-16 09:38:06 -08:00
|
|
|
option :type, type: Types::RelationshipTypes
|
2022-01-02 15:31:55 -08:00
|
|
|
|
|
|
|
def call
|
|
|
|
source_user.public_send(type, target_user)
|
|
|
|
|
|
|
|
{
|
2022-01-16 09:51:27 -08:00
|
|
|
status: 201,
|
2022-01-02 15:31:55 -08:00
|
|
|
resource: true,
|
2022-01-16 09:51:27 -08:00
|
|
|
extra: {
|
2022-01-02 15:31:55 -08:00
|
|
|
target_user: target_user
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|