Beispiel #1
0
        static async Task Main(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine("Usage: ");
                Console.WriteLine("GetCoupons [bookID]");
                return;
            }
            var bookId = args[0];

            if (!File.Exists(".apikey"))
            {
                Console.WriteLine(".apikey file not found!");
                return;
            }
            var apiKey = (await File.ReadAllTextAsync(".apikey")).Trim();

            var client  = new LeanpubApiClient(apiKey);
            var coupons = await client.GetActiveCouponsAsync(bookId);

            foreach (var coupon in coupons)
            {
                Console.WriteLine("https://leanpub.com/dinet/c/" + coupon.coupon_code);
            }
        }
Beispiel #2
0
        static async Task Main(string[] args)
        {
            if (args.Length < 4)
            {
                Console.WriteLine("Usage: ");
                Console.WriteLine("CreateCoupons [BookID] [Prefix] [Start Number] [Count]");
                Console.WriteLine("");
                Console.WriteLine("Example:");
                Console.WriteLine("CreateCoupons dinet miniasp-202105 1 50");
                return;
            }
            var bookId      = args[0];
            var prefix      = args[1]; // example: dinet-miniasp-may
            int startNumber = Convert.ToInt32(args[2]);
            int count       = Convert.ToInt32(args[3]);

            if (count < 1)
            {
                Console.WriteLine("Count should be larger than 0.");
            }


            if (!File.Exists(".apikey"))
            {
                Console.WriteLine(".apikey file not found!");
                return;
            }

            apiKey = (await File.ReadAllTextAsync(".apikey")).Trim();

            apiClient = new LeanpubApiClient(apiKey);

            await BatchCreateCoupons(bookId, prefix, startNumber, count);
        }