feat: add referral growth endpoints
This commit is contained in:
@@ -4,6 +4,7 @@ using Tiku.Application.Assets;
|
||||
using Tiku.Application.Auth;
|
||||
using Tiku.Application.Commerce;
|
||||
using Tiku.Application.Content;
|
||||
using Tiku.Application.Growth;
|
||||
using Tiku.Application.Points;
|
||||
using Tiku.Application.Storage;
|
||||
using Tiku.Infrastructure.Content;
|
||||
@@ -194,6 +195,16 @@ public sealed class ExceptionHandlingMiddleware(
|
||||
return;
|
||||
}
|
||||
|
||||
if (exception is ReferralException referralException)
|
||||
{
|
||||
await WriteProblemAsync(
|
||||
context,
|
||||
referralException.Message,
|
||||
ReferralStatusCode(referralException.Code),
|
||||
referralException.Code);
|
||||
return;
|
||||
}
|
||||
|
||||
if (exception is PaymentProviderException paymentProviderException)
|
||||
{
|
||||
await WriteProblemAsync(
|
||||
@@ -367,4 +378,15 @@ public sealed class ExceptionHandlingMiddleware(
|
||||
_ => StatusCodes.Status400BadRequest
|
||||
};
|
||||
}
|
||||
|
||||
private static int ReferralStatusCode(string code)
|
||||
{
|
||||
return code switch
|
||||
{
|
||||
"referral_access_denied" or "tenant_access_denied" => StatusCodes.Status403Forbidden,
|
||||
"referral_code_not_found" => StatusCodes.Status404NotFound,
|
||||
"referral_lead_protected" or "self_referral_not_allowed" => StatusCodes.Status409Conflict,
|
||||
_ => StatusCodes.Status400BadRequest
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user