Esempio n. 1
0
        public async Task <object> FunctionHandlerAsync(LambdaPayload?payload, ILambdaContext lambdaContext)
        {
            if (payload == null)
            {
                payload = new LambdaPayload();
            }

            LambdaLogger.Log(payload.ToString() + Environment.NewLine);

            var config        = new Configuration();
            var email         = config.GetEmail();
            var password      = config.GetPassowrd();
            var paymentTypeId = config.GetPaymentTypeId();
            var dateTime      = payload.GetDateTime();

            using (var client = new SharmaClient()) {
                await client.Login(email, password);

                try {
                    await client.BookNextReservation(dateTime, paymentTypeId, payload.Mock);
                } catch (NoTimesException ex) {
                    LambdaLogger.Log(ex.Message);
                    var invokePayload = await payload.GetNextAttempt();
                    await InvokeSelf(invokePayload, lambdaContext.FunctionName);
                } catch (Exception ex) {
                    LambdaLogger.Log(ex.Message);
                    return(new { Success = false });
                }
            }

            return(new { Success = true });
        }
Esempio n. 2
0
        static async Task Main(string[] args)
        {
            // TESTING
            // SharmaClient.Debug(); return;

            var ctSource = new CancellationTokenSource();
            var config   = new Configuration(args);

            using var client = new SharmaClient();
            await client.Login(config.GetEmail(), config.GetPassowrd(), ctSource.Token);

            // TESTING
            // await client.BookNext(new DateTime(2021, 3, 20, 12, 0, 0, DateTimeKind.Utc)); return;

            var reservations = await client.GetReservations(ctSource.Token);

            await WriteReservations(reservations, config.Output);
        }