Esempio n. 1
0
        static void Main(string[] args)
        {
            var client = new Client()
            {
                BaseUrl = "https://dev.loymax.tech/systemapi/"
            };

            // учётные данные запросите у специалистов Loymax
            client.Authorization("login-here", "password-here");


            var offers = OfferImportBuilder.Create("SampleTitle")               // Установить название акции
                         .WithPartner("43168568-a7f8-4582-9d45-49857634251d")   // указываем id партнёра
                         .WithState(OfferWorkingState.Running)                  // Акция будет сразу запущена
                         .WithChanges(DateTime.Now, OfferChangesState.Approved) // применяется с момента загрузки
                         .WithExpirationDate(DateTime.Now.AddDays(1))           // Истекает срок действия через 1 день
                         .AddChain <PurchaseCalculateEventDto>()                // добавляем цепочку для обработки события расчёта скидки
                         .WithCardStateFilter(CardState.Activated)              // только для активированных карт
                         .WithDirectDiscount(ActionDiscountType.Percent, 0.1)   // 10% прямой скидки
                         .Build();

            var result = client.OfferImportExport_PostOffersAsync(offers).Result; // импортируем акцию в систему

            Console.WriteLine(JsonConvert.SerializeObject(result, Formatting.Indented));
        }
        public static async Task ImportOfferAsync(Client client, string partnerId)
        {
            var goodsGroup = await client.GoodsGroup_GetGoodsGroupsAsync(filter_name : "Products"); // Find a product group with the Products name, which must be previously created in the Product groups section

            var offer = OfferImportBuilder.Create("Sample1. Discount on product group.")            // Set the name of the offer
                        .WithDescription("10% discount on product group with exclusive set.")       // Add a description for the offer
                        .WithPartner(partnerId)                                                     // Specify Partner's ID
                        .WithState(OfferWorkingState.Running)                                       // The offer will be run immediately
                        .WithChanges(DateTime.Now, OfferChangesState.Approved)                      // Applied from specified date
                        .WithPriority(20)                                                           // Set the priority for the offer
                        .AddChain <PurchaseCalculateEventDto>()                                     // Add a chain to process discount calculation event
                        .WithChequePositionGoodsFilter(                                             // Set the Product filter
                type: ChequeGoodsFilterType.OnlyGoods,                                              // Set an additional condition under which the filter will trigger: None
                goodsGroupsIds: new List <Guid> {
                goodsGroup.Data.First().ExternalId.Value
            })                                            // Set the product group found earlier
                        .WithDirectDiscount(              // Set the Direct discount action
                dicsountType: ActionDiscountType.Percent, // Set the calculation method: Percentage
                value: 10.0,                              // Set the discount amount
                calculationExclusionTypes: new List <CalculationExclusionDiscountType> {
                CalculationExclusionDiscountType.Discount
            })                                                                                                                           // Exclude the amount from the calculation: Direct discount
                        .Build();

            var result = await client.OfferImportExport_PostOffersAsync(offer); // Import the offer into the system

            Console.WriteLine(JsonConvert.SerializeObject(result, Formatting.Indented));
        }
Esempio n. 3
0
        public static async Task ImportOfferAsync(Client client, string partnerId)
        {
            var goodsGroup =
                await client.GoodsGroup_GetGoodsGroupsAsync(
                    filter_name : "Товары"); // Find a product group with the Products name, which must be previously created in the Product groups section

            var offer = OfferImportBuilder
                        .Create("Sample5. Special price when buying three units of product")                                                                                                               // Set the name of the offer
                        .WithDescription("When buing at the price of three units of a promotional product within the framework of one cheque, the Member purchases these three items at a fixed price N.") // Add a description for the offer
                        .WithPartner(partnerId)                                                                                                                                                            // Specify Partner's ID
                        .WithState(OfferWorkingState.Running)                                                                                                                                              // The offer will be run immediately
                        .WithChanges(DateTime.Now, OfferChangesState.Approved)                                                                                                                             // Applied from specified date
                        .WithPriority(40)                                                                                                                                                                  // Set the priority for the offer
                        .AddChain <PurchaseCalculateEventDto>()                                                                                                                                            // Add a chain to process discount calculation event
                        .WithChequePositionGoodsFilter(                                                                                                                                                    // Set the Product filter
                type: ChequeGoodsFilterType
                .GoodsQuantity,                                                                                                                                                                            // Set an additional condition under which the filter will trigger: Quantity
                goodsGroupsIds: new List <Guid>
            {
                goodsGroup.Data.First().ExternalId.Value
            },                               // Set the product group found earlier
                firstValue: 3.0,             // The filter only triggers if the number of units in the cheque is 3.0
                @operator: ComparisonOperator.Equals)
                        .WithDirectDiscount( // Set the Direct discount action
                dicsountType: ActionDiscountType
                .PricePerUnit,               // Set the calculation method: Fixed unit price
                value: 100.0)                // Set the discount amount
                        .Build();

            var result = await client.OfferImportExport_PostOffersAsync(offer); // Import the offer into the system

            Console.WriteLine(JsonConvert.SerializeObject(result, Formatting.Indented));
        }
        public static async Task ImportOfferAsync(Client client, string partnerId)
        {
            var goodsGroup = await client.GoodsGroup_GetGoodsGroupsAsync(filter_name : "Products");    // Find a product group with the Products name, which must be previously created in the Product groups section

            var offerBuilder = OfferImportBuilder.Create("Sample3. Fixed price for the product unit.") // Set the name of the offer
                               .WithDescription("Several chains with a given fixed value.")            // Add a description for the offer
                               .WithPartner(partnerId)                                                 // Specify Partner's ID
                               .WithState(OfferWorkingState.Running)                                   // The offer will be run immediately
                               .WithChanges(DateTime.Now, OfferChangesState.Approved)                  // Applied from specified date
                               .WithPriority(30);                                                      // Set the priority for the offer

            // Add the 1st chain to process the discount calculation event.
            offerBuilder.AddChain <PurchaseCalculateEventDto>()
            .WithChequePositionGoodsFilter(            // Set the Product filter
                type: ChequeGoodsFilterType.OnlyGoods, // Set an additional condition under which the filter will trigger: None
                goodsGroupsIds: new List <Guid> {
                goodsGroup.Data.First().ExternalId.Value
            })                                                 // Set the product group found earlier
            .WithDirectDiscount(                               // Set the Direct Discount action
                dicsountType: ActionDiscountType.PricePerUnit, // Set the calculation method: Fixed unit price
                value: 450.0);                                 // Set the discount amount

            // Add the 2nd chain to process the discount calculation event.
            offerBuilder.AddChain <PurchaseCalculateEventDto>()
            .WithChequePositionGoodsFilter(            // Set the Product filter
                type: ChequeGoodsFilterType.OnlyGoods, // Set an additional condition under which the filter will trigger: None
                goodsGroupsIds: new List <Guid>
            {
                goodsGroup.Data.First().ExternalId.Value
            })                     // Set the product group found earlier
            .WithDirectDiscount(   // Set the Direct Discount action
                dicsountType: ActionDiscountType
                .PricePerUnit,     // Set the calculation method: Fixed unit price
                value: 350.0);     // Set the discount amount

            // Add the 3rd chain to process the discount calculation event.
            offerBuilder.AddChain <PurchaseCalculateEventDto>()
            .WithChequePositionGoodsFilter(            // Set the Product filter
                type: ChequeGoodsFilterType.OnlyGoods, // Set an additional condition under which the filter will trigger: None
                goodsGroupsIds: new List <Guid>
            {
                goodsGroup.Data.First().ExternalId.Value
            })                     // Set the product group found earlier
            .WithDirectDiscount(   // Set the Direct Discount action
                dicsountType: ActionDiscountType
                .PricePerUnit,     // Set the calculation method: Fixed unit price
                value: 250.0);     // Set the discount amount

            var offer = offerBuilder.Build();

            var result = await client.OfferImportExport_PostOffersAsync(offer); // Import the offer into the system

            Console.WriteLine(JsonConvert.SerializeObject(result, Formatting.Indented));
        }
        public static async Task ImportOfferAsync(Client client, string partnerId)
        {
            var offer = OfferImportBuilder.Create("SampleTitle")               // Set offer name
                        .WithPartner(partnerId)                                // Indicate partner's ID
                        .WithState(OfferWorkingState.Running)                  // The offer will be run immediately
                        .WithChanges(DateTime.Now, OfferChangesState.Approved) // It has been applied from the moment of loading
                        .WithExpirationDate(DateTime.Now.AddDays(1))           // Expires after 1 day
                        .AddChain <PurchaseCalculateEventDto>()                // The chain for discount calculation event processing is added
                        .WithCardStateFilter(CardState.Activated)              // for activated cards only
                        .WithDirectDiscount(ActionDiscountType.Percent, 0.1)   // 10% direct discount
                        .Build();

            var result = await client.OfferImportExport_PostOffersAsync(offer); // import the offer into the system

            Console.WriteLine(JsonConvert.SerializeObject(result, Formatting.Indented));
        }
        public static async Task ImportOfferAsync(Client client, string partnerId)
        {
            var goodsGroup = await client.GoodsGroup_GetGoodsGroupsAsync(filter_name : "Products"); // Find a product group with the Products name, which must be previously created in the Product groups section

            var offer = OfferImportBuilder.Create("Sapmle4. N+M")                                   // Set the name of the offer
                        .WithPartner(partnerId)                                                     // Specify Partner's ID
                        .WithDescription("When buying 5 products, 6th as a gift.")                  // Add a description for the offer
                        .WithState(OfferWorkingState.Running)                                       // The offer will be run immediately
                        .WithChanges(DateTime.Now, OfferChangesState.Approved)                      // Applied from specified date
                        .WithPriority(35)                                                           // Set the priority of the offer
                        .AddChain <PurchaseCalculateEventDto>()                                     // Add a chain to process discount calculation event
                        .WithGoodsSetDivide(                                                        // Set the Dividing into Sets action
                new List <GoodsSetItemDto>
            {
                new GoodsSetItemDto                                               // Create a new set
                {
                    GoodsGroup = new GoodsGroupExDto                              // The item source for the set is the product group that is found.
                    {
                        Id = goodsGroup.Data.First().ExternalId.Value.ToString(), // Set the product group ID
                    },
                    Value = 6.000,                                                // Set the number of products in the set
                },
            },
                ChequeGoodsSortType.PriceAscending,        // Set the type of product sorting: Ascending prices
                ChequeGoodsSetType.Quantity)               // Set the condition for dividing: Quantity of products
                        .WithChequePositionGoodsFilter(    // Set the Product filter
                type: ChequeGoodsFilterType.GoodsQuantity, // Set an additional condition under which the filter will trigger: Quantity
                goodsGroupsIds: new List <Guid> {
                goodsGroup.Data.First().ExternalId.Value
            },                       // Set the product group found earlier
                firstValue: 1.0,     // The filter will only trigger if the number of units in the cheque is less than or equal to 1.0
                @operator: ComparisonOperator.LessOrEqual,
                chequeGoodsSortType: ChequeGoodsSortType.PriceAscending,
                dividePositions: true)
                        .WithDirectDiscount(              // Set the Direct Discount action
                dicsountType: ActionDiscountType.Percent, // Set the calculation method: Percentage
                value: 100)                               // Set the discount amount
                        .Build();

            var result = await client.OfferImportExport_PostOffersAsync(offer); // Import the offer into the system

            Console.WriteLine(JsonConvert.SerializeObject(result, Formatting.Indented));
        }
Esempio n. 7
0
        public static async Task ImportOfferAsync(Client client, string partnerId)
        {
            var offer = OfferImportBuilder
                        .Create("Sample6. Message to the cheque of a specific target audience")                       // Set the name of the offer
                        .WithDescription("Summable offer providing specific messages for a specific target audience") // Add a description for the offer
                        .WithPartner(partnerId)                                                                       // Specify Partner's ID
                        .WithState(OfferWorkingState.Running)                                                         // The offer will be run immediately
                        .WithChanges(DateTime.Now, OfferChangesState.Approved)                                        // Applied from specified date
                        .WithPriority(45)                                                                             // Set the priority for the offer
                        .IsSum()                                                                                      // Summable offer
                        .WithTargetGroup("1")                                                                         // Set the identifier for target audience, which must be previously created in the Target audiences section
                        .AddChain <PurchaseCalculateEventDto>()                                                       // Add a chain to process discount calculation event
                        .WithChequeMessage("With love. your MegaMax")                                                 // Set the message on the cheque
                        .Build();

            var result = await client.OfferImportExport_PostOffersAsync(offer); // Import the offer into the system

            Console.WriteLine(JsonConvert.SerializeObject(result, Formatting.Indented));
        }
        public static async Task ImportOfferAsync(Client client, string partnerId)
        {
            var offer = OfferImportBuilder.Create("Sample2. Discount for target audience")                                                   // Set the name of the offer
                        .WithDescription("Discount for target audience in a specific POS on the expiration date.")                           // Add a description for the offer
                        .WithPartner(partnerId)                                                                                              // Specify Partner's ID
                        .WithState(OfferWorkingState.Running)                                                                                // The offer will be run immediately
                        .WithChanges(DateTime.Now, OfferChangesState.Approved)                                                               // Applied from specified date
                        .WithExpirationDate(DateTime.Now.AddDays(7))                                                                         // Set the expiration date of the offer
                        .WithPriority(25)                                                                                                    // Set the priority of the offer
                        .WithMerchantFilter(new string[] { "75e67dae-130a-4030-192d-18b02d907950", "55403257-1663-4bd1-9725-20b3bfe51392" }) // Set GUIDs of points of sale in which the offer will be valid
                        .WithTargetGroup(new string[] { "1", "2" })                                                                          // Set the identifiers of the target audiences, which must be previously created in the Target audiences section
                        .AddChain <PurchaseCalculateEventDto>()                                                                              // Add a chain to process discount calculation event
                        .WithDirectDiscount(                                                                                                 // Set the Direct discount action
                dicsountType: ActionDiscountType.Percent,                                                                                    // Set the calculation method: Percentage
                value: 15.0,                                                                                                                 // Set the discount amount
                calculationExclusionTypes: new List <CalculationExclusionDiscountType> {
                CalculationExclusionDiscountType.Discount
            })                                                                                                                           // Exclude amount from the calculation: Direct discount
                        .Build();

            var result = await client.OfferImportExport_PostOffersAsync(offer); // Import the offer into the system

            Console.WriteLine(JsonConvert.SerializeObject(result, Formatting.Indented));
        }