Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Adyen/Management/Client/ClientUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ public static bool TryDeserialize<T>(ref Utf8JsonReader reader, JsonSerializerOp
return Models.AmexInfo.ServiceLevelEnum.ToJsonValue(amexInfoServiceLevelEnum);
if (obj is Models.AndroidApp.StatusEnum androidAppStatusEnum)
return Models.AndroidApp.StatusEnum.ToJsonValue(androidAppStatusEnum);
if (obj is Models.CampaignStatusTransition campaignStatusTransition)
return CampaignStatusTransition.ToJsonValue(campaignStatusTransition);
Comment on lines +133 to +134

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The return statement is missing the Models. prefix, which is inconsistent with the rest of the file (e.g., Models.AndroidApp.StatusEnum.ToJsonValue on line 132). If the Adyen.Management.Models namespace is not fully imported, this will also cause a compilation error. Please add the Models. prefix for consistency and safety.

            if (obj is Models.CampaignStatusTransition campaignStatusTransition)
                return Models.CampaignStatusTransition.ToJsonValue(campaignStatusTransition);

if (obj is Models.Connectivity.SimcardStatusEnum connectivitySimcardStatusEnum)
return Models.Connectivity.SimcardStatusEnum.ToJsonValue(connectivitySimcardStatusEnum);
if (obj is Models.CreateCompanyWebhookRequest.CommunicationFormatEnum createCompanyWebhookRequestCommunicationFormatEnum)
Expand All @@ -148,6 +150,14 @@ public static bool TryDeserialize<T>(ref Utf8JsonReader reader, JsonSerializerOp
return Models.CreateMerchantWebhookRequest.NetworkTypeEnum.ToJsonValue(createMerchantWebhookRequestNetworkTypeEnum);
if (obj is Models.DinersInfo.ServiceLevelEnum dinersInfoServiceLevelEnum)
return Models.DinersInfo.ServiceLevelEnum.ToJsonValue(dinersInfoServiceLevelEnum);
if (obj is Models.DisplayTextField displayTextField)
return DisplayTextField.ToJsonValue(displayTextField);
if (obj is Models.DonationCampaignStatus donationCampaignStatus)
return DonationCampaignStatus.ToJsonValue(donationCampaignStatus);
if (obj is Models.DonationFlow donationFlow)
return DonationFlow.ToJsonValue(donationFlow);
if (obj is Models.DonationType donationType)
return DonationType.ToJsonValue(donationType);
Comment on lines +153 to +160

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

These return statements are missing the Models. prefix, which is inconsistent with the rest of the file. Please add the Models. prefix to ensure consistency and avoid potential compilation errors.

            if (obj is Models.DisplayTextField displayTextField)
                return Models.DisplayTextField.ToJsonValue(displayTextField);
            if (obj is Models.DonationCampaignStatus donationCampaignStatus)
                return Models.DonationCampaignStatus.ToJsonValue(donationCampaignStatus);
            if (obj is Models.DonationFlow donationFlow)
                return Models.DonationFlow.ToJsonValue(donationFlow);
            if (obj is Models.DonationType donationType)
                return Models.DonationType.ToJsonValue(donationType);

if (obj is Models.ForceRebootDetails.TypeEnum forceRebootDetailsTypeEnum)
return Models.ForceRebootDetails.TypeEnum.ToJsonValue(forceRebootDetailsTypeEnum);
if (obj is Models.GivexInfo.PaymentFlowEnum givexInfoPaymentFlowEnum)
Expand Down Expand Up @@ -190,6 +200,8 @@ public static bool TryDeserialize<T>(ref Utf8JsonReader reader, JsonSerializerOp
return Models.PulseResponseInfo.ProcessingTypeEnum.ToJsonValue(pulseResponseInfoProcessingTypeEnum);
if (obj is Models.ReleaseUpdateDetails.TypeEnum releaseUpdateDetailsTypeEnum)
return Models.ReleaseUpdateDetails.TypeEnum.ToJsonValue(releaseUpdateDetailsTypeEnum);
if (obj is Models.ScheduleTerminalActionsRequestActionDetails.TypeEnum scheduleTerminalActionsRequestActionDetailsTypeEnum)
return Models.ScheduleTerminalActionsRequestActionDetails.TypeEnum.ToJsonValue(scheduleTerminalActionsRequestActionDetailsTypeEnum);
if (obj is Models.SplitConfigurationLogic.AcquiringFeesEnum splitConfigurationLogicAcquiringFeesEnum)
return Models.SplitConfigurationLogic.AcquiringFeesEnum.ToJsonValue(splitConfigurationLogicAcquiringFeesEnum);
if (obj is Models.SplitConfigurationLogic.AdyenCommissionEnum splitConfigurationLogicAdyenCommissionEnum)
Expand Down
27 changes: 27 additions & 0 deletions Adyen/Management/Client/HostConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,20 @@ public HostConfiguration(IServiceCollection services)
_jsonOptions.Converters.Add(new ApiCredentialLinksJsonConverter());
_jsonOptions.Converters.Add(new ApplePayInfoJsonConverter());
_jsonOptions.Converters.Add(new ApplePayResponseInfoJsonConverter());
_jsonOptions.Converters.Add(new AssociatedPaymentMethodJsonConverter());
_jsonOptions.Converters.Add(new BcmcInfoJsonConverter());
_jsonOptions.Converters.Add(new BcmcResponseInfoJsonConverter());
_jsonOptions.Converters.Add(new BcmcUpdateInfoJsonConverter());
_jsonOptions.Converters.Add(new BillingEntitiesResponseJsonConverter());
_jsonOptions.Converters.Add(new BillingEntityJsonConverter());
_jsonOptions.Converters.Add(new CampaignStatusTransition.CampaignStatusTransitionJsonConverter());
_jsonOptions.Converters.Add(new CardholderReceiptJsonConverter());
_jsonOptions.Converters.Add(new CarnetInfoJsonConverter());
_jsonOptions.Converters.Add(new CarnetResponseInfoJsonConverter());
_jsonOptions.Converters.Add(new CartesBancairesInfoJsonConverter());
_jsonOptions.Converters.Add(new CartesBancairesResponseInfoJsonConverter());
_jsonOptions.Converters.Add(new CartesBancairesUpdateInfoJsonConverter());
_jsonOptions.Converters.Add(new CashAppUpdateInfoJsonConverter());
_jsonOptions.Converters.Add(new ClearpayInfoJsonConverter());
_jsonOptions.Converters.Add(new ClearpayResponseInfoJsonConverter());
_jsonOptions.Converters.Add(new CommissionJsonConverter());
Expand Down Expand Up @@ -123,9 +127,20 @@ public HostConfiguration(IServiceCollection services)
_jsonOptions.Converters.Add(new CustomNotificationJsonConverter());
_jsonOptions.Converters.Add(new DataCenterJsonConverter());
_jsonOptions.Converters.Add(new DccJsonConverter());
_jsonOptions.Converters.Add(new DefaultErrorResponseEntityJsonConverter());
_jsonOptions.Converters.Add(new DinersInfoJsonConverter());
_jsonOptions.Converters.Add(new DinersResponseInfoJsonConverter());
_jsonOptions.Converters.Add(new DiscoverResponseInfoJsonConverter());
_jsonOptions.Converters.Add(new DisplayTextField.DisplayTextFieldJsonConverter());
_jsonOptions.Converters.Add(new DonationAmountJsonConverter());
_jsonOptions.Converters.Add(new DonationAmountUpdateJsonConverter());
_jsonOptions.Converters.Add(new DonationCampaignJsonConverter());
_jsonOptions.Converters.Add(new DonationCampaignNonprofitCauseJsonConverter());
_jsonOptions.Converters.Add(new DonationCampaignRequestJsonConverter());
_jsonOptions.Converters.Add(new DonationCampaignStatus.DonationCampaignStatusJsonConverter());
_jsonOptions.Converters.Add(new DonationCampaignUpdateJsonConverter());
_jsonOptions.Converters.Add(new DonationFlow.DonationFlowJsonConverter());
_jsonOptions.Converters.Add(new DonationType.DonationTypeJsonConverter());
_jsonOptions.Converters.Add(new EFTDirectDebitCAResponseInfoJsonConverter());
_jsonOptions.Converters.Add(new EftPosAustraliaResponseInfoJsonConverter());
_jsonOptions.Converters.Add(new EventUrlJsonConverter());
Expand All @@ -147,6 +162,9 @@ public HostConfiguration(IServiceCollection services)
_jsonOptions.Converters.Add(new HomeScreenSettingsJsonConverter());
_jsonOptions.Converters.Add(new IdNameJsonConverter());
_jsonOptions.Converters.Add(new IdealResponseInfoJsonConverter());
_jsonOptions.Converters.Add(new InPersonDonationSettingsJsonConverter());
_jsonOptions.Converters.Add(new InPersonDonationSettingsResponseJsonConverter());
_jsonOptions.Converters.Add(new InPersonDonationSettingsUpdateJsonConverter());
_jsonOptions.Converters.Add(new InstallAndroidAppDetailsJsonConverter());
_jsonOptions.Converters.Add(new InstallAndroidCertificateDetailsJsonConverter());
_jsonOptions.Converters.Add(new InstalledAPKsJsonConverter());
Expand All @@ -163,10 +181,13 @@ public HostConfiguration(IServiceCollection services)
_jsonOptions.Converters.Add(new ListCompanyApiCredentialsResponseJsonConverter());
_jsonOptions.Converters.Add(new ListCompanyResponseJsonConverter());
_jsonOptions.Converters.Add(new ListCompanyUsersResponseJsonConverter());
_jsonOptions.Converters.Add(new ListDonationCampaignsResponseJsonConverter());
_jsonOptions.Converters.Add(new ListExternalTerminalActionsResponseJsonConverter());
_jsonOptions.Converters.Add(new ListMerchantApiCredentialsResponseJsonConverter());
_jsonOptions.Converters.Add(new ListMerchantResponseJsonConverter());
_jsonOptions.Converters.Add(new ListMerchantUsersResponseJsonConverter());
_jsonOptions.Converters.Add(new ListNonprofitsRequestJsonConverter());
_jsonOptions.Converters.Add(new ListNonprofitsResponseJsonConverter());
_jsonOptions.Converters.Add(new ListStoresResponseJsonConverter());
_jsonOptions.Converters.Add(new ListTerminalsResponseJsonConverter());
_jsonOptions.Converters.Add(new ListWebhooksResponseJsonConverter());
Expand All @@ -188,12 +209,17 @@ public HostConfiguration(IServiceCollection services)
_jsonOptions.Converters.Add(new NameJsonConverter());
_jsonOptions.Converters.Add(new Name2JsonConverter());
_jsonOptions.Converters.Add(new NexoJsonConverter());
_jsonOptions.Converters.Add(new NonprofitJsonConverter());
_jsonOptions.Converters.Add(new NonprofitCauseJsonConverter());
_jsonOptions.Converters.Add(new NotificationJsonConverter());
_jsonOptions.Converters.Add(new NotificationUrlJsonConverter());
_jsonOptions.Converters.Add(new NyceInfoJsonConverter());
_jsonOptions.Converters.Add(new NyceResponseInfoJsonConverter());
_jsonOptions.Converters.Add(new NyceUpdateInfoJsonConverter());
_jsonOptions.Converters.Add(new OfflineProcessingJsonConverter());
_jsonOptions.Converters.Add(new OnlineDonationSettingsJsonConverter());
_jsonOptions.Converters.Add(new OnlineDonationSettingsResponseJsonConverter());
_jsonOptions.Converters.Add(new OnlineDonationSettingsUpdateJsonConverter());
_jsonOptions.Converters.Add(new OpiJsonConverter());
_jsonOptions.Converters.Add(new OrderItemJsonConverter());
_jsonOptions.Converters.Add(new PaginationLinksJsonConverter());
Expand Down Expand Up @@ -245,6 +271,7 @@ public HostConfiguration(IServiceCollection services)
_jsonOptions.Converters.Add(new SplitConfigurationListJsonConverter());
_jsonOptions.Converters.Add(new SplitConfigurationLogicJsonConverter());
_jsonOptions.Converters.Add(new SplitConfigurationRuleJsonConverter());
_jsonOptions.Converters.Add(new SplitDccJsonConverter());
_jsonOptions.Converters.Add(new StandaloneJsonConverter());
_jsonOptions.Converters.Add(new StarInfoJsonConverter());
_jsonOptions.Converters.Add(new StarResponseInfoJsonConverter());
Expand Down
24 changes: 23 additions & 1 deletion Adyen/Management/Extensions/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static class ServiceCollectionExtensions

/// <summary>
/// Add all Management services using the extension methods in <see cref="ServiceCollectionExtensions"/> and configures the <see cref="System.Net.Http.HttpClient"/> and <see cref="IHttpClientBuilder"/>.
/// See: <see cref="APICredentialsCompanyLevelService"/>, <see cref="APICredentialsMerchantLevelService"/>, <see cref="APIKeyCompanyLevelService"/>, <see cref="APIKeyMerchantLevelService"/>, <see cref="AccountCompanyLevelService"/>, <see cref="AccountMerchantLevelService"/>, <see cref="AccountStoreLevelService"/>, <see cref="AllowedOriginsCompanyLevelService"/>, <see cref="AllowedOriginsMerchantLevelService"/>, <see cref="AndroidFilesCompanyLevelService"/>, <see cref="ClientKeyCompanyLevelService"/>, <see cref="ClientKeyMerchantLevelService"/>, <see cref="MyAPICredentialService"/>, <see cref="PaymentMethodsMerchantLevelService"/>, <see cref="PayoutSettingsMerchantLevelService"/>, <see cref="SplitConfigurationMerchantLevelService"/>, <see cref="TerminalActionsCompanyLevelService"/>, <see cref="TerminalActionsTerminalLevelService"/>, <see cref="TerminalOrdersCompanyLevelService"/>, <see cref="TerminalOrdersMerchantLevelService"/>, <see cref="TerminalSettingsCompanyLevelService"/>, <see cref="TerminalSettingsMerchantLevelService"/>, <see cref="TerminalSettingsStoreLevelService"/>, <see cref="TerminalSettingsTerminalLevelService"/>, <see cref="TerminalsTerminalLevelService"/>, <see cref="UsersCompanyLevelService"/>, <see cref="UsersMerchantLevelService"/>, <see cref="WebhooksCompanyLevelService"/>, <see cref="WebhooksMerchantLevelService"/>,
/// See: <see cref="APICredentialsCompanyLevelService"/>, <see cref="APICredentialsMerchantLevelService"/>, <see cref="APIKeyCompanyLevelService"/>, <see cref="APIKeyMerchantLevelService"/>, <see cref="AccountCompanyLevelService"/>, <see cref="AccountMerchantLevelService"/>, <see cref="AccountStoreLevelService"/>, <see cref="AllowedOriginsCompanyLevelService"/>, <see cref="AllowedOriginsMerchantLevelService"/>, <see cref="AndroidFilesCompanyLevelService"/>, <see cref="ClientKeyCompanyLevelService"/>, <see cref="ClientKeyMerchantLevelService"/>, <see cref="DonationCampaignsService"/>, <see cref="MyAPICredentialService"/>, <see cref="PaymentMethodsMerchantLevelService"/>, <see cref="PayoutSettingsMerchantLevelService"/>, <see cref="SplitConfigurationMerchantLevelService"/>, <see cref="TerminalActionsCompanyLevelService"/>, <see cref="TerminalActionsTerminalLevelService"/>, <see cref="TerminalOrdersCompanyLevelService"/>, <see cref="TerminalOrdersMerchantLevelService"/>, <see cref="TerminalSettingsCompanyLevelService"/>, <see cref="TerminalSettingsMerchantLevelService"/>, <see cref="TerminalSettingsStoreLevelService"/>, <see cref="TerminalSettingsTerminalLevelService"/>, <see cref="TerminalsTerminalLevelService"/>, <see cref="UsersCompanyLevelService"/>, <see cref="UsersMerchantLevelService"/>, <see cref="WebhooksCompanyLevelService"/>, <see cref="WebhooksMerchantLevelService"/>,
/// </summary>
/// <param name="services"><see cref="IServiceCollection"/>.</param>
/// <param name="serviceLifetime"><see cref="ServiceLifetime"/>.</param>
Expand All @@ -52,6 +52,7 @@ public static IServiceCollection AddAllManagementServices(this IServiceCollectio
services.AddAndroidFilesCompanyLevelService(serviceLifetime, httpClientOptions, httpClientBuilderOptions);
services.AddClientKeyCompanyLevelService(serviceLifetime, httpClientOptions, httpClientBuilderOptions);
services.AddClientKeyMerchantLevelService(serviceLifetime, httpClientOptions, httpClientBuilderOptions);
services.AddDonationCampaignsService(serviceLifetime, httpClientOptions, httpClientBuilderOptions);
services.AddMyAPICredentialService(serviceLifetime, httpClientOptions, httpClientBuilderOptions);
services.AddPaymentMethodsMerchantLevelService(serviceLifetime, httpClientOptions, httpClientBuilderOptions);
services.AddPayoutSettingsMerchantLevelService(serviceLifetime, httpClientOptions, httpClientBuilderOptions);
Expand Down Expand Up @@ -327,6 +328,27 @@ public static IServiceCollection AddClientKeyMerchantLevelService(this IServiceC
return services;
}

/// <summary>
/// Add <see cref="DonationCampaignsService"/> as the implementation of <see cref="IDonationCampaignsService"/> to the Dependency Injection container <see cref="IServiceCollection"/>.
/// </summary>
/// <param name="services"><see cref="IServiceCollection"/>.</param>
/// <param name="serviceLifetime">Configures the <see cref="ServiceLifetime"/>, defaults to <see cref="ServiceLifetime.Singleton"/>.</param>
/// <returns><see cref="IServiceCollection"/>.</returns>
public static IServiceCollection AddDonationCampaignsService(this IServiceCollection services, ServiceLifetime serviceLifetime = ServiceLifetime.Singleton, Action<System.Net.Http.HttpClient>? httpClientOptions = null, Action<IHttpClientBuilder>? httpClientBuilderOptions = null)
{
services.AddSingleton<DonationCampaignsServiceEvents>();

services.Add(new ServiceDescriptor(typeof(IDonationCampaignsService), typeof(DonationCampaignsService), serviceLifetime));

IHttpClientBuilder builder = services.AddHttpClient<IDonationCampaignsService, DonationCampaignsService>(typeof(IDonationCampaignsService).FullName!, httpClient =>
{
httpClientOptions?.Invoke(httpClient);
});

httpClientBuilderOptions?.Invoke(builder);
return services;
}

/// <summary>
/// Add <see cref="MyAPICredentialService"/> as the implementation of <see cref="IMyAPICredentialService"/> to the Dependency Injection container <see cref="IServiceCollection"/>.
/// </summary>
Expand Down
15 changes: 11 additions & 4 deletions Adyen/Management/Models/AccelResponseInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,19 @@ public override void Write(Utf8JsonWriter writer, ProcessingTypeEnum value, Json
}
}

/// <summary>
/// This is used to track if an optional field is set. If set, <see cref="ProcessingType"/> will be populated.
/// </summary>
[JsonIgnore]
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
public Option<ProcessingTypeEnum?> _ProcessingTypeOption { get; private set; }

/// <summary>
/// The type of transactions processed over this payment method. Allowed values: - **pos** for in-person payments. - **billpay** for subscription payments, both the initial payment and the later recurring payments. These transactions have `recurringProcessingModel` **Subscription**. - **ecom** for all other card not present transactions. This includes non-recurring transactions and transactions with `recurringProcessingModel` **CardOnFile** or **UnscheduledCardOnFile**.
/// </summary>
/// <value>The type of transactions processed over this payment method. Allowed values: - **pos** for in-person payments. - **billpay** for subscription payments, both the initial payment and the later recurring payments. These transactions have &#x60;recurringProcessingModel&#x60; **Subscription**. - **ecom** for all other card not present transactions. This includes non-recurring transactions and transactions with &#x60;recurringProcessingModel&#x60; **CardOnFile** or **UnscheduledCardOnFile**. </value>
[JsonPropertyName("processingType")]
public ProcessingTypeEnum ProcessingType { get; set; }
public ProcessingTypeEnum? ProcessingType { get { return this._ProcessingTypeOption; } set { this._ProcessingTypeOption = new(value); } }

/// <summary>
/// This is used to track if an optional field is set. If set, <see cref="TransactionDescription"/> will be populated.
Expand Down Expand Up @@ -269,7 +276,7 @@ public override AccelResponseInfo Read(ref Utf8JsonReader utf8JsonReader, Type t

var accelResponseInfo = new AccelResponseInfo();
if (processingType.IsSet)
accelResponseInfo.ProcessingType = processingType.Value!;
accelResponseInfo.ProcessingType = processingType.Value;
if (transactionDescription.IsSet)
accelResponseInfo.TransactionDescription = transactionDescription.Value;
return accelResponseInfo;
Expand Down Expand Up @@ -301,9 +308,9 @@ public override void Write(Utf8JsonWriter writer, AccelResponseInfo accelRespons
public void WriteProperties(Utf8JsonWriter writer, AccelResponseInfo accelResponseInfo, JsonSerializerOptions jsonSerializerOptions)
{

if (accelResponseInfo.ProcessingType != null)
if (accelResponseInfo._ProcessingTypeOption.IsSet && accelResponseInfo.ProcessingType != null)
{
string? processingTypeRawValue = AccelResponseInfo.ProcessingTypeEnum.ToJsonValue(accelResponseInfo.ProcessingType);
string? processingTypeRawValue = AccelResponseInfo.ProcessingTypeEnum.ToJsonValue(accelResponseInfo._ProcessingTypeOption.Value!.Value);
writer.WriteString("processingType", processingTypeRawValue);
}

Expand Down
Loading
Loading