Codeunit 30231 Shpfy Refund Enum Convertor

Shopify Connector, Microsoft.Integration.Shopify

src/Apps/W1/Shopify/App/src/Order Refunds/Codeunits/ShpfyRefundEnumConvertor.Codeunit.al45 lines, Copyright (c) Microsoft Corporation. MIT

// ------------------------------------------------------------------------------------------------// Copyright (c) Microsoft Corporation. All rights reserved.// Licensed under the MIT License. See License.txt in the project root for license information.// ------------------------------------------------------------------------------------------------namespace Microsoft.Integration.Shopify;codeunit 30231 "Shpfy Refund Enum Convertor"{    SingleInstance = true;    Access = Internal;    var        RestockTypes: Dictionary of [Text, Enum "Shpfy Restock Type"];    #region "Shpfy Restock Type"    local procedure FillInRestockTypes()    var        EnumValues: List of [Integer];        EnumNames: List of [Text];        Index: Integer;    begin        if RestockTypes.Count > 0 then            exit;        EnumValues := Enum::"Shpfy Restock Type".Ordinals();        EnumNames := Enum::"Shpfy Restock Type".Names();        for Index := 1 to EnumValues.Count do            RestockTypes.Add(EnumNames.Get(Index).Trim().ToUpper().Replace(' ', '_'), Enum::"Shpfy Restock Type".FromInteger(EnumValues.Get(Index)));    end;    internal procedure ConvertToReStockType(Value: Text): Enum "Shpfy Restock Type"    begin        FillInRestockTypes();        if RestockTypes.ContainsKey(Value) then            exit(RestockTypes.Get(Value));    end;    internal procedure ConvertToText(Value: Enum "Shpfy Restock Type"): text    begin        exit(Value.Names.Get(Value.Ordinals().IndexOf(Value.AsInteger())).Trim().ToUpper().Replace(' ', '_'));    end;    #endregion "Shpfy Restock Type"}