inviteUser method

  1. @override
Future<PlanInvite> inviteUser(
  1. String token,
  2. int userId
)
override

Invites the user with the given userId to the plan of the user associated with the given token.

Implementation

@override
Future<PlanInvite> inviteUser(String token, int userId) async {
  log('Inviting user $userId');

  try {
    final response = await _apiService.callFunction(
      function: 'local_lbplanner_plan_invite_user',
      token: token,
      body: {
        'inviteeid': userId,
      },
    );

    response.assertJson();

    log('User $userId invited');

    return PlanInvite.fromJson(response.asJson);
  } catch (e, s) {
    log('Failed to invite user $userId', e, s);
    rethrow;
  }
}