public static void Run(Voucherify.Api api)
        {
            var vouchers = new List <DataModel.Contexts.CampaignVoucherImport>()
            {
                new DataModel.Contexts.CampaignVoucherImport()
                {
                    Code              = "Import1",
                    AdditionalInfo    = "DESC",
                    VoucherRedemption = new DataModel.Contexts.VoucherRedemption().WithQuantity(3)
                },
                new DataModel.Contexts.CampaignVoucherImport()
                {
                    Code              = "Import2",
                    AdditionalInfo    = "DESC",
                    VoucherRedemption = new DataModel.Contexts.VoucherRedemption().WithQuantity(3)
                }
            };

            api.Campaigns.ImportVouchers(
                "TEST-SDK-16",
                vouchers,
                (responseImport) =>
            {
                if (responseImport.Exception != null)
                {
                    Console.WriteLine("[CampaignVoucherImport] Exception: {0}", responseImport.Exception);
                    return;
                }

                Console.WriteLine("[CampaignVoucherImport] Result: {0}", responseImport.Result);
            });
        }
        public static void Run(Voucherify.Api api)
        {
            api.Customers.Create(
                new DataModel.Contexts.CustomerCreate()
            {
                Email    = "*****@*****.**",
                Metadata = new Core.DataModel.Metadata(new Dictionary <string, object>()
                {
                    { "key1", "value1" },
                    { "key2", "value2" }
                }),
                Description = "Test Description",
                Name        = "Bandro"
            },
                (responseCreate) =>
            {
                if (responseCreate.Exception != null)
                {
                    Console.WriteLine("[CustomerFlow] (Create) Exception: {0}", responseCreate.Exception);
                    return;
                }

                Console.WriteLine("[CustomerFlow] (Create) Result: {0}", responseCreate.Result);
                api.Customers.Get(responseCreate.Result.Id, (responseGet) =>
                {
                    if (responseCreate.Exception != null)
                    {
                        Console.WriteLine("[CustomerFlow] (Get) Exception: {0}", responseGet.Exception);
                        return;
                    }

                    Console.WriteLine("[CustomerFlow] (Get) Result: {0}", responseGet.Result);
                    api.Customers.Update(
                        responseCreate.Result.Id,
                        DataModel.Contexts.CustomerUpdate.FromCustomer(responseCreate.Result)
                        .WithDescription("Test Description Updated")
                        .WithName("Bandro Updated"),
                        (responseUpdate) =>
                    {
                        if (responseUpdate.Exception != null)
                        {
                            Console.WriteLine("[CustomerFlow] (Update) Exception: {0}", responseUpdate.Exception);
                            return;
                        }

                        Console.WriteLine("[CustomerFlow] (Update) Result: {0}", responseUpdate.Result);
                        api.Customers.Delete(responseUpdate.Result.Id, (responseDelete) =>
                        {
                            if (responseDelete.Exception != null)
                            {
                                Console.WriteLine("[CustomerFlow] (Delete) Exception: {0}", responseDelete.Exception);
                                return;
                            }

                            Console.WriteLine("[CustomerFlow] (Delete) Done");
                        });
                    });
                });
            });
        }
Beispiel #3
0
        public async static Task Run(Voucherify.Api api)
        {
            try
            {
                var vouchers = new List <DataModel.Contexts.CampaignVoucherImport>()
                {
                    new DataModel.Contexts.CampaignVoucherImport()
                    {
                        Code              = "Import1",
                        AdditionalInfo    = "DESC",
                        VoucherRedemption = new DataModel.Contexts.VoucherRedemption().WithQuantity(3)
                    },
                    new DataModel.Contexts.CampaignVoucherImport()
                    {
                        Code              = "Import2",
                        AdditionalInfo    = "DESC",
                        VoucherRedemption = new DataModel.Contexts.VoucherRedemption().WithQuantity(3)
                    }
                };
                var importVouchers = await api.Campaigns.ImportVouchers("TEST-SDK-16", vouchers);

                Console.WriteLine("[CampaignVoucherImport] Result: {0}", importVouchers);
            }
            catch (Exception e)
            {
                Console.WriteLine("[CampaignVoucherImport]  Exception: {0}", e);
            }
        }
        public async static Task Run(Voucherify.Api api)
        {
            try
            {
                var voucherCreate = await api.Vouchers.Create(new DataModel.Contexts.VoucherCreate()
                {
                    Active         = true,
                    Category       = "TEST-SDK-Category",
                    AdditionalInfo = "TEST-AdditionalInfo",
                    StartDate      = DateTime.Now.AddDays(-1),
                    ExpirationDate = DateTime.Now.AddDays(10),
                    Redemption     = new DataModel.Contexts.VoucherRedemption().WithQuantity(1),
                    Metadata       = new Core.DataModel.Metadata(new Dictionary <string, object>()
                    {
                        { "key1", "value1" },
                        { "key2", "value2" }
                    })
                }.WithDiscount(new DataModel.Discount().WithPercentOff(67)));

                Console.WriteLine("[VoucherFlow] (Create) Result: {0}", voucherCreate);
                var voucherGet = await api.Vouchers.Get(voucherCreate.Code);

                Console.WriteLine("[VoucherFlow] (Get) Result: {0}", voucherGet);
                var voucherUpdate = await api.Vouchers.Update(
                    voucherGet.Code,
                    DataModel.Contexts.VoucherUpdate.FromVoucher(voucherGet)
                    .WithAdditionalInfo("Some Additional Text"));

                Console.WriteLine("[VoucherFlow] (Update) Result: {0}", voucherUpdate);
                var voucherValidate = await api.Validations.ValidateVoucher(voucherGet.Code,
                                                                            new DataModel.Contexts.VoucherValidation()
                {
                    TrackingId = "Sample Tracking Id"
                });

                Console.WriteLine("[VoucherFlow] (Validate) Result: {0}", voucherValidate);
                await api.Vouchers.Disable(voucherGet.Code);

                Console.WriteLine("[VoucherFlow] (Disable) Done");
                await api.Vouchers.Enable(voucherGet.Code);

                Console.WriteLine("[VoucherFlow] (Enable) Done");
                await api.Vouchers.Delete(
                    voucherGet.Code,
                    new DataModel.Queries.VoucherDelete()
                {
                    Force = true
                });

                Console.WriteLine("[VoucherFlow] (Delete) Done");
            }
            catch (Exception e)
            {
                Console.WriteLine("[VoucherFlow] Exception: {0}", e);
            }
        }
        public async static Task Run(Voucherify.Api api)
        {
            try
            {
                var productCreated = await api.Products.Create(new DataModel.Contexts.ProductCreate()
                {
                    Attributes = new List <string>()
                    {
                        "color", "size"
                    },
                    Name = "TEST Product"
                });

                Console.WriteLine("[ProductFlow] (Create) Result: {0}", productCreated);
                var productGet = await api.Products.Get(productCreated.Id);

                Console.WriteLine("[ProductFlow] (Get) Result: {0}", productGet);
                var skuCreated = await api.Products.CreateSku(
                    productGet.Id,
                    new DataModel.Contexts.SkuCreate()
                {
                    SkuValue   = "TEST-PRODUCT-WHITE-M",
                    Attributes = new Core.DataModel.Metadata(new Dictionary <string, object>()
                    {
                        { "color", "white" },
                        { "size", "M" }
                    })
                });

                Console.WriteLine("[ProductFlow] (CreateSku) Result: {0}", skuCreated);
                var skuGet = await api.Products.GetSku(productGet.Id, skuCreated.Id);

                Console.WriteLine("[ProductFlow] (GetSku) Exception: {0}", skuGet);
                var skuUpdated = await api.Products.UpdateSku(
                    productGet.Id,
                    skuGet.Id,
                    DataModel.Contexts.SkuUpdate.FromSku(skuGet)
                    .WithCurrency("USD")
                    .WithPrice(100));

                Console.WriteLine("[ProductFlow] (UpdateSku) Result: {0}", skuUpdated);
                var skuList = await api.Products.ListSkus(productGet.Id);

                Console.WriteLine("[ProductFlow] (ListSkus) Result: {0}", skuList);
                await api.Products.DeleteSku(productGet.Id, skuGet.Id);

                Console.WriteLine("[ProductFlow] (DeleteSku) Done}");
                await api.Products.Delete(productGet.Id);

                Console.WriteLine("[ProductFlow] (Delete) Done}");
            }
            catch (Exception e)
            {
                Console.WriteLine("[ProductFlow] Exception: {0}", e);
            }
        }
Beispiel #6
0
        public async static Task Run(Voucherify.Api api)
        {
            try
            {
                var voucherCreate = await api.Vouchers.Create(new Voucherify.DataModel.Contexts.VoucherCreate()
                {
                    Active         = true,
                    Category       = "TEST-SDK-Category",
                    AdditionalInfo = "TEST-AdditionalInfo",
                    StartDate      = DateTime.Now.AddDays(-1),
                    ExpirationDate = DateTime.Now.AddDays(10),
                    Redemption     = new DataModel.Contexts.VoucherRedemption().WithQuantity(1),
                    Metadata       = new Core.DataModel.Metadata(new Dictionary <string, object>()
                    {
                        { "key1", "value1" },
                        { "key2", "value2" }
                    })
                }.WithDiscount(new DataModel.Discount().WithPercentOff(67)));

                Console.WriteLine("[Redemption] (Create) Result: {0}", voucherCreate);
                var redemptionRedeem = await api.Redemptions.Redeem(
                    voucherCreate.Code,
                    new DataModel.Queries.RedemptionRedeem(),
                    new DataModel.Contexts.RedemptionRedeem()
                {
                }.WithCustomerId("*****@*****.**"));

                System.Threading.Thread.Sleep(5000);
                Console.WriteLine("[Redemption] (Redeem) Result: {0}", redemptionRedeem);
                var redemptionList = await api.Redemptions.GetForVoucher(voucherCreate.Code);

                Console.WriteLine("[Redemption] (List) Result: {0}", redemptionList);
                System.Threading.Thread.Sleep(5000);
                var redemptionRollback = await api.Redemptions.Rollback(
                    redemptionRedeem.Id,
                    new DataModel.Queries.RedemptionRollback(),
                    new DataModel.Contexts.RedemptionRollback().WithCustomerId("*****@*****.**"));

                Console.WriteLine("[Redemption] (Rollback) Result: {0}", redemptionRollback);
                await api.Vouchers.Delete(
                    voucherCreate.Code,
                    new DataModel.Queries.VoucherDelete()
                {
                    Force = true
                });

                Console.WriteLine("[Redemption] (Delete) Done");
            }
            catch (Exception e)
            {
                Console.WriteLine("[Redemption] Exception: {0}", e);
            }
        }
Beispiel #7
0
        public static void Run(Voucherify.Api api)
        {
            api.Products.List((response) =>
            {
                if (response.Exception != null)
                {
                    Console.WriteLine("[ProductList] (List) Exception: {0}", response.Exception);
                    return;
                }

                Console.WriteLine("[ProductList] (List) Result: {0}", response.Result);
            });
        }
        public async static Task Run(Voucherify.Api api)
        {
            try
            {
                var productList = await api.Products.List();

                Console.WriteLine("[ProductList] (List) Result: {0}", productList);
            }
            catch (Exception e)
            {
                Console.WriteLine("[ProductList] Exception: {0}", e);
            }
        }
        public static async Task Run()
        {
            try
            {
                var serverApi = new Voucherify.Api("<invalid-app>", "<invalid-token>");
                var result    = await serverApi.Validations.ValidateVoucher("<invalid_code>", new DataModel.Contexts.VoucherValidation());

                Console.WriteLine("[ApiUnauthorized] Result: {0}", result);
            }
            catch (Exception e)
            {
                Console.WriteLine("[ApiUnauthorized] Exception: {0}", e);
            }
        }
        public async static Task Run(Voucherify.Api api)
        {
            try
            {
                var redemptionList = await api.Redemptions.List(new DataModel.Queries.RedemptionsFilter()
                {
                    Limit = 5
                });

                Console.WriteLine("[RedemptionList] (List) Result: {0} First: {1}", redemptionList.Total, redemptionList.Total > 0 ? redemptionList.Redemptions[0] : null);
            }
            catch (Exception e)
            {
                Console.WriteLine("[RedemptionList] Exception: {0}", e);
            }
        }
        public async static Task Run(Voucherify.Api api)
        {
            try
            {
                var voucherList = await api.Vouchers.List(new DataModel.Queries.VouchersFilter()
                {
                    Limit = 5
                });

                Console.WriteLine("[VoucherList] (List) Result: {0} First: {1}", voucherList.Count, voucherList.Count > 0 ? voucherList[0] : null);
            }
            catch (Exception e)
            {
                Console.WriteLine("[VoucherList] Exception: {0}", e);
            }
        }
        public async static Task Run(Voucherify.Api api)
        {
            try
            {
                var vouchers = new List <DataModel.Contexts.VoucherImport>();

                vouchers.Add(new Voucherify.DataModel.Contexts.VoucherImport()
                {
                    Code           = "code1",
                    Active         = true,
                    Category       = "TEST-SDK-Category",
                    AdditionalInfo = "TEST-AdditionalInfo",
                    StartDate      = DateTime.Now.AddDays(-1),
                    ExpirationDate = DateTime.Now.AddDays(10),
                    Redemption     = new DataModel.Contexts.VoucherRedemption().WithQuantity(1),
                    Metadata       = new Core.DataModel.Metadata(new Dictionary <string, object>()
                    {
                        { "key1", "value1" },
                        { "key2", "value2" }
                    })
                }.WithDiscount(new DataModel.Discount().WithPercentOff(67)));
                vouchers.Add(new Voucherify.DataModel.Contexts.VoucherImport()
                {
                    Code           = "code2",
                    Active         = true,
                    Category       = "TEST-SDK-Category",
                    AdditionalInfo = "TEST-AdditionalInfo",
                    StartDate      = DateTime.Now.AddDays(-1),
                    ExpirationDate = DateTime.Now.AddDays(10),
                    Redemption     = new DataModel.Contexts.VoucherRedemption().WithQuantity(1),
                    Metadata       = new Core.DataModel.Metadata(new Dictionary <string, object>()
                    {
                        { "key1", "value1" },
                        { "key2", "value2" }
                    })
                }.WithDiscount(new DataModel.Discount().WithPercentOff(69)));

                var voucherImport = await api.Vouchers.Import(vouchers);

                Console.WriteLine("[VoucherImport] Result: {0}", voucherImport);
            }
            catch (Exception e)
            {
                Console.WriteLine("[VoucherImport] Exception: {0}", e);
            }
        }
Beispiel #13
0
        public static void Run(Voucherify.Api api)
        {
            var vouchers = new List <DataModel.Contexts.VoucherImport>();

            vouchers.Add(new Voucherify.DataModel.Contexts.VoucherImport()
            {
                Code           = "code1",
                Active         = true,
                Category       = "TEST-SDK-Category",
                AdditionalInfo = "TEST-AdditionalInfo",
                StartDate      = DateTime.Now.AddDays(-1),
                ExpirationDate = DateTime.Now.AddDays(10),
                Redemption     = new DataModel.Contexts.VoucherRedemption().WithQuantity(1),
                Metadata       = new Core.DataModel.Metadata(new Dictionary <string, object>()
                {
                    { "key1", "value1" },
                    { "key2", "value2" }
                })
            }.WithDiscount(new DataModel.Discount().WithPercentOff(69)));
            vouchers.Add(new Voucherify.DataModel.Contexts.VoucherImport()
            {
                Code           = "code2",
                Active         = true,
                Category       = "TEST-SDK-Category",
                AdditionalInfo = "TEST-AdditionalInfo",
                StartDate      = DateTime.Now.AddDays(-1),
                ExpirationDate = DateTime.Now.AddDays(10),
                Redemption     = new DataModel.Contexts.VoucherRedemption().WithQuantity(1),
                Metadata       = new Core.DataModel.Metadata(new Dictionary <string, object>()
                {
                    { "key1", "value1" },
                    { "key2", "value2" }
                })
            }.WithDiscount(new DataModel.Discount().WithPercentOff(69)));

            api.Vouchers.Import(vouchers, (response) =>
            {
                if (response.Exception != null)
                {
                    Console.WriteLine("[VoucherImport] Exception: {0}", response.Exception);
                    return;
                }

                Console.WriteLine("[VoucherImport] Result: {0}", response.Result);
            });
        }
        static void Main(string[] args)
        {
            var serverApi = new Voucherify.Api("<app_id>", "<token>");

            //Cases.ApiUnauthorized.Run().Wait();
            //Cases.CampaignFlow.Run(serverApi).Wait();
            //Cases.CampaignVoucherImport.Run(serverApi).Wait();
            //Cases.CustomerFlow.Run(serverApi).Wait();
            //Cases.ProductFlow.Run(serverApi).Wait();
            //Cases.ProductList.Run(serverApi).Wait();
            //Cases.RedemptionFlow.Run(serverApi).Wait();
            //Cases.RedemptionList.Run(serverApi).Wait();
            //Cases.VoucherFlow.Run(serverApi).Wait();
            //Cases.VoucherList.Run(serverApi).Wait();
            //Cases.VoucherImport.Run(serverApi).Wait();

            Console.ReadLine();
        }
        public static void Run(Voucherify.Api api)
        {
            api.Redemptions.List(
                new DataModel.Queries.RedemptionsFilter()
            {
                Limit = 5
            },
                (response) =>
            {
                if (response.Exception != null)
                {
                    Console.WriteLine("[RedemptionList] (List) Exception: {0}", response.Exception);
                    return;
                }

                Console.WriteLine("[RedemptionList] (List) Result: {0} First: {1}", response.Result.Total, response.Result.Total > 0 ? response.Result.Redemptions[0] : null);
            });
        }
Beispiel #16
0
        public static void Run()
        {
            var serverApi = new Voucherify.Api("<invalid-app>", "<invalid-token>");

            serverApi.Validations.ValidateVoucher(
                "<invalid_code>",
                new DataModel.Contexts.VoucherValidation(),
                (response) =>
            {
                if (response.Exception != null)
                {
                    Console.WriteLine("[ApiUnauthorized] Exception: {0}", response.Exception);
                    return;
                }

                Console.WriteLine("[ApiUnauthorized] Result: {0}", response.Result);
            });
        }
        public static void Run(Voucherify.Api api)
        {
            api.Campaigns.Create(
                new DataModel.Contexts.CampaignCreate()
            {
                Name          = "TEST-SDK-16",
                Type          = DataModel.CampaignType.Static,
                VouchersCount = 10,
                Voucher       = new DataModel.Contexts.CampaignVoucherCreate()
                {
                    Redemption = new DataModel.Contexts.VoucherRedemption().SingleUse()
                }.WithDiscount(new DataModel.Discount().WithPercentOff(20))
            },
                (responseCreate) =>
            {
                if (responseCreate.Exception != null)
                {
                    Console.WriteLine("[CampaignFlow] (Create) Exception: {0}", responseCreate.Exception);
                    return;
                }

                Console.WriteLine("[CampaignFlow] (Create) Result: {0}", responseCreate.Result);
                System.Threading.Thread.Sleep(5000);

                api.Campaigns.AddVoucher(
                    responseCreate.Result.Name,
                    new DataModel.Contexts.CampaignAddVoucher()
                {
                    AdditionalInfo    = "DESC",
                    VoucherRedemption = new DataModel.Contexts.VoucherRedemption().WithQuantity(3)
                },
                    (responseAdd) =>
                {
                    if (responseAdd.Exception != null)
                    {
                        Console.WriteLine("[CampaignFlow] (Add) Exception: {0}", responseAdd.Exception);
                        return;
                    }

                    Console.WriteLine("[CampaignFlow] (Add) Result: {0}", responseAdd.Result);
                });
            });
        }
        public async static Task Run(Voucherify.Api api)
        {
            try
            {
                DataModel.Customer createdCustomer = await api.Customers.Create(
                    new DataModel.Contexts.CustomerCreate()
                {
                    Email    = "*****@*****.**",
                    Metadata = new Core.DataModel.Metadata(new Dictionary <string, object>()
                    {
                        { "key1", "value1" },
                        { "key2", "value2" }
                    }),
                    Description = "Test Description",
                    Name        = "Bandro"
                });

                Console.WriteLine("[CustomerFlow] (Create) Result: {0}", createdCustomer);
                DataModel.Customer getCustomer = await api.Customers.Get(createdCustomer.Id);

                Console.WriteLine("[CustomerFlow] (Get) Result: {0}", getCustomer);
                DataModel.Customer updatedCustomer = await api.Customers.Update(
                    getCustomer.Id,
                    DataModel.Contexts.CustomerUpdate.FromCustomer(getCustomer)
                    .WithDescription("Test Description Updated")
                    .WithName("Bandro Updated"));

                Console.WriteLine("[CustomerFlow] (Update) Result: {0}", updatedCustomer);
                await api.Customers.Delete(updatedCustomer.Id);

                Console.WriteLine("[CustomerFlow] (Delete) Done");
            }
            catch (Exception e)
            {
                Console.WriteLine("[CustomerFlow] Exception: {0}", e);
            }
        }
        public async static Task Run(Voucherify.Api api)
        {
            try
            {
                var campaignCreate = await api.Campaigns.Create(
                    new DataModel.Contexts.CampaignCreate()
                {
                    Name          = "TEST-SDK-14",
                    VouchersCount = 5,
                    Voucher       = new DataModel.Contexts.CampaignVoucherCreate()
                    {
                        Redemption = new DataModel.Contexts.VoucherRedemption().SingleUse()
                    }.WithDiscount(new DataModel.Discount().WithAmountOff(2000)),
                    Metadata = new Core.DataModel.Metadata(new System.Collections.Generic.Dictionary <string, object>()
                    {
                        { "test", true }
                    })
                });

                Console.WriteLine("[CampaignFlow] (Create) Result: {0}", campaignCreate);
                System.Threading.Thread.Sleep(5000);
                var campaignAddVoucher = await api.Campaigns.AddVoucher(
                    campaignCreate.Name,
                    new DataModel.Contexts.CampaignAddVoucher()
                {
                    AdditionalInfo    = "DESC",
                    VoucherRedemption = new DataModel.Contexts.VoucherRedemption().WithQuantity(3)
                });

                Console.WriteLine("[CampaignFlow] (Add) Result: {0}", campaignAddVoucher);
            }
            catch (Exception e)
            {
                Console.WriteLine("[CampaignFlow]  Exception: {0}", e);
            }
        }
Beispiel #20
0
        public static void Run(Voucherify.Api api)
        {
            api.Products.Create(
                new DataModel.Contexts.ProductCreate()
            {
                Attributes = new List <string>()
                {
                    "color", "size"
                },
                Name = "TEST Product"
            }, (responseCreate) =>
            {
                if (responseCreate.Exception != null)
                {
                    Console.WriteLine("[ProductFlow] (Create) Exception: {0}", responseCreate.Exception);
                    return;
                }

                Console.WriteLine("[ProductFlow] (Create) Result: {0}", responseCreate.Result);
                api.Products.Get(responseCreate.Result.Id,
                                 (responseGet) =>
                {
                    if (responseGet.Exception != null)
                    {
                        Console.WriteLine("[ProductFlow] (Get) Exception: {0}", responseGet.Exception);
                        return;
                    }

                    Console.WriteLine("[ProductFlow] (Get) Result: {0}", responseGet.Result);
                    api.Products.CreateSku(
                        responseGet.Result.Id,
                        new DataModel.Contexts.SkuCreate()
                    {
                        SkuValue   = "TEST-PRODUCT-WHITE-M",
                        Attributes = new Core.DataModel.Metadata(new Dictionary <string, object>()
                        {
                            { "color", "white" },
                            { "size", "M" }
                        })
                    },
                        (responseCreateSku) =>
                    {
                        if (responseCreateSku.Exception != null)
                        {
                            Console.WriteLine("[ProductFlow] (CreateSku) Exception: {0}", responseCreateSku.Exception);
                            return;
                        }

                        Console.WriteLine("[ProductFlow] (CreateSku) Result: {0}", responseCreateSku.Result);
                        api.Products.GetSku(
                            responseGet.Result.Id,
                            responseCreateSku.Result.Id,
                            (responseGetSku) =>
                        {
                            if (responseCreateSku.Exception != null)
                            {
                                Console.WriteLine("[ProductFlow] (GetSku) Exception: {0}", responseGetSku.Exception);
                                return;
                            }

                            Console.WriteLine("[ProductFlow] (GetSku) Result: {0}", responseGetSku.Result);
                            api.Products.UpdateSku(
                                responseGet.Result.Id,
                                responseCreateSku.Result.Id,
                                DataModel.Contexts.SkuUpdate.FromSku(responseGetSku.Result)
                                .WithCurrency("USD")
                                .WithPrice(100),
                                (responseUpdateSku) =>
                            {
                                if (responseUpdateSku.Exception != null)
                                {
                                    Console.WriteLine("[ProductFlow] (UpdateSku) Exception: {0}", responseUpdateSku.Exception);
                                    return;
                                }

                                Console.WriteLine("[ProductFlow] (UpdateSku) Result: {0}", responseUpdateSku.Result);
                                api.Products.ListSkus(
                                    responseGet.Result.Id,
                                    (responseListSku) =>
                                {
                                    if (responseListSku.Exception != null)
                                    {
                                        Console.WriteLine("[ProductFlow] (ListSkus) Exception: {0}", responseListSku.Exception);
                                        return;
                                    }

                                    Console.WriteLine("[ProductFlow] (ListSkus) Result: {0}", responseListSku.Result);
                                    api.Products.DeleteSku(
                                        responseGet.Result.Id,
                                        responseGetSku.Result.Id,
                                        (repsonseDeleteSku) =>
                                    {
                                        if (repsonseDeleteSku.Exception != null)
                                        {
                                            Console.WriteLine("[ProductFlow] (DeleteSku) Exception: {0}", repsonseDeleteSku.Exception);
                                            return;
                                        }

                                        Console.WriteLine("[ProductFlow] (DeleteSku) Done}");
                                        api.Products.Delete(
                                            responseGet.Result.Id,
                                            (repsonseDelete) =>
                                        {
                                            if (repsonseDelete.Exception != null)
                                            {
                                                Console.WriteLine("[ProductFlow] (Delete) Exception: {0}", repsonseDelete.Exception);
                                                return;
                                            }

                                            Console.WriteLine("[ProductFlow] (Delete) Done}");
                                        });
                                    });
                                });
                            });
                        });
                    });
                });
            });
        }
        public static void Run(Voucherify.Api api)
        {
            api.Vouchers.Create(new Voucherify.DataModel.Contexts.VoucherCreate()
            {
                Active         = true,
                Category       = "TEST-SDK-Category",
                AdditionalInfo = "TEST-AdditionalInfo",
                StartDate      = DateTime.Now.AddDays(-1),
                ExpirationDate = DateTime.Now.AddDays(10),
                Redemption     = new DataModel.Contexts.VoucherRedemption().WithQuantity(1),
                Metadata       = new Core.DataModel.Metadata(new Dictionary <string, object>()
                {
                    { "key1", "value1" },
                    { "key2", "value2" }
                })
            }.WithDiscount(new DataModel.Discount().WithPercentOff(69)),
                                (responseCreate) =>
            {
                if (responseCreate.Exception != null)
                {
                    Console.WriteLine("[Redemption] (Create) Exception: {0}", responseCreate.Exception);
                    return;
                }

                Console.WriteLine("[Redemption] (Create) Result: {0}", responseCreate.Result);

                api.Redemptions.Redeem(
                    responseCreate.Result.Code,
                    new DataModel.Queries.RedemptionRedeem(),
                    new DataModel.Contexts.RedemptionRedeem()
                {
                }.WithCustomerId("*****@*****.**"),
                    (responseRedeem) =>
                {
                    if (responseRedeem.Exception != null)
                    {
                        Console.WriteLine("[Redemption] (Redeem) Exception: {0}", responseRedeem.Exception);
                        return;
                    }

                    Console.WriteLine("[Redemption] (Redeem) Result: {0}", responseRedeem.Result);
                    api.Redemptions.GetForVoucher(
                        responseCreate.Result.Code,
                        (responseList) =>
                    {
                        if (responseList.Exception != null)
                        {
                            Console.WriteLine("[Redemption] (List) Exception: {0}", responseList.Exception);
                            return;
                        }

                        Console.WriteLine("[Redemption] (List) Result: {0}", responseList.Result);
                        System.Threading.Thread.Sleep(5000);
                        api.Redemptions.Rollback(
                            responseRedeem.Result.Id,
                            new DataModel.Queries.RedemptionRollback(),
                            new DataModel.Contexts.RedemptionRollback().WithCustomerId("*****@*****.**"),
                            (responseRollback) =>
                        {
                            if (responseRollback.Exception != null)
                            {
                                Console.WriteLine("[Redemption] (Rollback) Exception: {0}", responseRollback.Exception);
                                return;
                            }

                            Console.WriteLine("[Redemption] (Rollback) Result: {0}", responseRollback.Result);
                            System.Threading.Thread.Sleep(5000);

                            api.Vouchers.Delete(
                                responseCreate.Result.Code,
                                new DataModel.Queries.VoucherDelete()
                            {
                                Force = true
                            },
                                (responseDelete) =>
                            {
                                if (responseDelete.Exception != null)
                                {
                                    Console.WriteLine("[Redemption] (Delete) Exception: {0}", responseDelete.Exception);
                                    return;
                                }

                                Console.WriteLine("[Redemption] (Delete) Done");
                            });
                        });
                    });
                });
            });
        }
        public static void Run(Voucherify.Api api)
        {
            api.Vouchers.Create(new Voucherify.DataModel.Contexts.VoucherCreate()
            {
                Active         = true,
                Category       = "TEST-SDK-Category",
                AdditionalInfo = "TEST-AdditionalInfo",
                StartDate      = DateTime.Now.AddDays(-1),
                ExpirationDate = DateTime.Now.AddDays(10),
                Redemption     = new DataModel.Contexts.VoucherRedemption().WithQuantity(1),
                Metadata       = new Core.DataModel.Metadata(new Dictionary <string, object>()
                {
                    { "key1", "value1" },
                    { "key2", "value2" }
                })
            }.WithDiscount(new DataModel.Discount().WithPercentOff(69)),
                                (responesCreate) =>
            {
                if (responesCreate.Exception != null)
                {
                    Console.WriteLine("[VoucherFlow] (Create) Exception: {0}", responesCreate.Exception);
                    return;
                }

                Console.WriteLine("[VoucherFlow] (Create) Result: {0}", responesCreate.Result);
                api.Vouchers.Get(
                    responesCreate.Result.Code,
                    (responseGet) =>
                {
                    if (responseGet.Exception != null)
                    {
                        Console.WriteLine("[VoucherFlow] (Get) Exception: {0}", responseGet.Exception);
                        return;
                    }

                    Console.WriteLine("[VoucherFlow] (Get) Result: {0}", responseGet.Result);
                    api.Vouchers.Update(
                        responseGet.Result.Code,
                        DataModel.Contexts.VoucherUpdate.FromVoucher(responseGet.Result)
                        .WithAdditionalInfo("Some Additional Text"),
                        (responseUpdate) =>
                    {
                        if (responseUpdate.Exception != null)
                        {
                            Console.WriteLine("[VoucherFlow] (Update) Exception: {0}", responseUpdate.Exception);
                            return;
                        }

                        Console.WriteLine("[VoucherFlow] (Update) Result: {0}", responseUpdate.Result);
                        api.Validations.ValidateVoucher(
                            responseGet.Result.Code,
                            new DataModel.Contexts.VoucherValidation()
                        {
                            TrackingId = "Sample Tracking Id"
                        },
                            (responseValidate) =>
                        {
                            if (responseValidate.Exception != null)
                            {
                                Console.WriteLine("[VoucherFlow] (Validate) Exception: {0}", responseValidate.Exception);
                                return;
                            }

                            Console.WriteLine("[VoucherFlow] (Validate) Result: {0}", responseValidate.Result);
                            api.Vouchers.Disable(
                                responseGet.Result.Code,
                                (responseDisable) =>
                            {
                                if (responseDisable.Exception != null)
                                {
                                    Console.WriteLine("[VoucherFlow] (Disable) Exception: {0}", responseDisable.Exception);
                                    return;
                                }

                                Console.WriteLine("[VoucherFlow] (Disable) Done");
                                api.Vouchers.Enable(
                                    responseGet.Result.Code,
                                    (responseEnable) =>
                                {
                                    if (responseEnable.Exception != null)
                                    {
                                        Console.WriteLine("[VoucherFlow] (Enable) Exception: {0}", responseEnable.Exception);
                                        return;
                                    }

                                    Console.WriteLine("[VoucherFlow] (Enable) Done");
                                    api.Vouchers.Delete(
                                        responseGet.Result.Code,
                                        new DataModel.Queries.VoucherDelete()
                                    {
                                        Force = true
                                    },
                                        (responseDelete) =>
                                    {
                                        if (responseDelete.Exception != null)
                                        {
                                            Console.WriteLine("[VoucherFlow] (Delete) Exception: {0}", responseDelete.Exception);
                                            return;
                                        }

                                        Console.WriteLine("[VoucherFlow] (Delete) Done");
                                    });
                                });
                            });
                        });
                    });
                });
            });
        }