Example #1
0
 public MainWindow()
 {
     InitializeComponent();
     _downloader = new ApiCaller("192.168.1.35", 8000);
     _downloader.Login("nas", "nas");
     this.Text = "BatchDownloader";
 }
Example #2
0
        static void Main()
        {
            var caller = new ApiCaller("http://apitesting.leankitkanban.com");
            caller.Authenticate("*****@*****.**", "qwerty");

            //var x = caller.GetBoardIdentifiers("13835201");
            var y = caller.GetBoardAttributes("13835201");
            //var z = caller.GetListOfItemsInBackLog("13835201");
        }
        private async void ExecuteAdicionarEventoCommand()
        {
            Tarefa tarefa = new Tarefa();

            tarefa.Nome       = Nome;
            tarefa.Finalizado = false;

            await ApiCaller.CreateTarefa(tarefa);
        }
Example #4
0
        public void ThenTheStandAloneEventClassCapacityIs(int classCapacity)
        {
            var response = ApiCaller.Get <StandAloneEventModel>(Routes.GetById(Routes.StandAloneEvent, ScenarioCache.GetId(ModelIdKeys.StandAloneEventId)));

            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            Assert.IsNotNull(response.Data);

            Assert.AreEqual(classCapacity, response.Data.ClassCapacity);
        }
        public void WhenTheTeacherUnchecksTheStudentIn()
        {
            var response =
                ApiCaller.Delete <ActionReponse <ClassModel> >(
                    Routes.GetAttendClass(ScenarioCache.GetId(ModelIdKeys.ClassId),
                                          ScenarioCache.GetId(ModelIdKeys.UserId)));

            ScenarioCache.StoreActionResponse(response);
        }
        public void WhenTheRatesForAllTeachersAreRequested()
        {
            var url = Routes.TeacherRates;

            var response = ApiCaller.Get <List <TeacherRateModel> >(url);

            ScenarioCache.StoreResponse(response);
            ScenarioCache.Store(ModelKeys.TeacherRate, response.Data);
        }
Example #7
0
        public void ThenTheCurrentUsersNameIsUnchanged()
        {
            var response = ApiCaller.Get <UserNamesModel>(Routes.CurrentUserNames);

            var expectedNames = ScenarioCache.Get <UserNamesModel>(ModelKeys.UserNames);

            Assert.IsNull(response.Data.FirstName);
            Assert.IsNull(response.Data.Surname);
        }
Example #8
0
        public void GivenOpeningHoursNeedToBeChanged()
        {
            var response     = ApiCaller.Get <List <TimeSlotModel> >(Routes.OpeningHours);
            var openingHours = response.Data.Single();

            var newOpeningHours = new TimeSlotModel(openingHours.Day, openingHours.OpeningTime.PlusHours(1), openingHours.ClosingTime.PlusHours(1));

            ScenarioCache.Store(ModelKeys.OpeningHours, newOpeningHours);
        }
Example #9
0
        public void APICallerReturnsOpeningCrawlFromAnyOfThe7FilmsAtRandom()
        {
            var apiCaller            = new ApiCaller();
            var openingCrawl         = apiCaller.GetOpeningCrawl();
            var anotherOpeningCrawl  = apiCaller.GetOpeningCrawl();
            var afurtherOpeningCrawl = apiCaller.GetOpeningCrawl();

            Assert.That(openingCrawl != anotherOpeningCrawl && openingCrawl != afurtherOpeningCrawl);
        }
        public ConfirmationController()
        {
            var paysonMerchantId = ConfigurationManager.AppSettings["PaysonMerchantId"];
            var paysonApiKey     = ConfigurationManager.AppSettings["PaysonApiKey"];

            _apiCaller = new ApiCaller(paysonMerchantId, paysonApiKey, true);
            _apiCaller.SetApiUrl(ConfigurationManager.AppSettings["PaysonRestUrl"]);
            _databaseConnection = new InMemoryDatabaseConnection();
        }
Example #11
0
        public async Task <Result> Void(Booking booking, ApiCaller apiCaller)
        {
            if (booking.PaymentStatus != BookingPaymentStatuses.Authorized)
            {
                return(Result.Failure($"Void is only available for payments with '{BookingPaymentStatuses.Authorized}' status"));
            }

            return(await _creditCardPaymentProcessingService.VoidMoney(booking.ReferenceCode, apiCaller, _paymentCallbackService));
        }
Example #12
0
        public async Task <Result> Refund(string referenceCode, ApiCaller apiCaller, DateTime operationDate, IPaymentCallbackService paymentCallbackService,
                                          string reason)
        {
            return(await GetChargingAccountId()
                   .Bind(GetRefundableAmount)
                   .Bind(RefundMoneyToAccount)
                   .Bind(ProcessPaymentResults));


            Task <Result <int> > GetChargingAccountId()
            => paymentCallbackService.GetChargingAccountId(referenceCode);


            async Task <Result <(int accountId, MoneyAmount)> > GetRefundableAmount(int accountId)
            {
                var(_, isFailure, refundableAmount, error) = await paymentCallbackService.GetRefundableAmount(referenceCode, operationDate);

                if (isFailure)
                {
                    return(Result.Failure <(int, MoneyAmount)>(error));
                }

                return(accountId, refundableAmount);
            }

            async Task <Result <Payment> > RefundMoneyToAccount((int, MoneyAmount) refundInfo)
            {
                var(accountId, refundableAmount) = refundInfo;
                return(await GetPayment(referenceCode)
                       .Check(Refund)
                       .Map(UpdatePaymentStatus));


                Task <Result> Refund(Payment _)
                => _accountPaymentProcessingService.RefundMoney(accountId,
                                                                new ChargedMoneyData(
                                                                    refundableAmount.Amount,
                                                                    refundableAmount.Currency,
                                                                    reason: reason,
                                                                    referenceCode: referenceCode),
                                                                apiCaller);


                async Task <Payment> UpdatePaymentStatus(Payment payment)
                {
                    payment.Status         = PaymentStatuses.Refunded;
                    payment.RefundedAmount = refundableAmount.Amount;
                    _context.Payments.Update(payment);
                    await _context.SaveChangesAsync();

                    return(payment);
                }
            }

            Task <Result> ProcessPaymentResults(Payment payment)
            => paymentCallbackService.ProcessPaymentChanges(payment);
        }
Example #13
0
        private async Task PreaperWalletForNewUser(string userName)
        {
            var user = await userManager.FindByNameAsync(userName);

            var wallet = new Wallet(user.Id, 100000M);

            var api = new ApiCaller();
            await api.CreateWallet(wallet);
        }
Example #14
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            Console.WriteLine(ApiCaller.GetNumericPoints().ToString());
            Console.WriteLine(ApiCaller.GetBoolDecision().ToString());


            Console.ReadKey();
        }
Example #15
0
        public void ThenAllTheClassesInTheBlockDoesNotHaveTheRoom()
        {
            var block = ApiCaller.Get <BlockModel>(Routes.GetById(Routes.Blocks, ScenarioCache.GetId(ModelIdKeys.BlockId))).Data;

            foreach (var classModel in block.Classes)
            {
                Assert.IsNull(classModel.Room);
            }
        }
Example #16
0
        public void ThenTheUsersTermAndConditionsAgreementIsRecorded()
        {
            var userId = ScenarioCache.GetUserId();

            var response = ApiCaller.Get <UserModel>(Routes.GetUserById(userId));

            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            Assert.IsTrue(response.Data.AgreesToTerms);
        }
Example #17
0
        public void ThenTheUserHasAClipPass()
        {
            var response = ApiCaller.Get <List <ClipPassModel> >(Routes.GetUserPasses(ScenarioCache.GetId(ModelIdKeys.UserId)));

            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            Assert.IsNotEmpty(response.Data);

            ScenarioCache.Store(ModelKeys.Pass, response.Data.Single());
        }
Example #18
0
        public void ThenTheCorrectNumberOfClassesAreCreated()
        {
            var response = ApiCaller.Get <BlockModel>(Routes.GetById(Routes.Blocks, ScenarioCache.GetId(ModelIdKeys.BlockId)));
            var block    = response.Data;

            var expectedBlock = ScenarioCache.Get <BlockModel>(ModelKeys.Block);

            Assert.AreEqual(expectedBlock.NumberOfClasses, block.Classes.Count);
        }
Example #19
0
        public void WhenTheTeacherUnchecksTheStudentIntoTheEvent()
        {
            var response =
                ApiCaller.Delete <ActionReponse <StandAloneEventModel> >(
                    Routes.GetAttendEvent(ScenarioCache.GetId(ModelIdKeys.StandAloneEventId),
                                          ScenarioCache.GetId(ModelIdKeys.UserId)));

            ScenarioCache.StoreActionResponse(response);
        }
Example #20
0
        public void ThenTheStandAloneEventIsNowPrivate()
        {
            var response = ApiCaller.Get <StandAloneEventModel>(Routes.GetById(Routes.StandAloneEvent, ScenarioCache.GetId(ModelIdKeys.StandAloneEventId)));

            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            Assert.IsNotNull(response.Data);

            Assert.IsTrue(response.Data.IsPrivate);
        }
Example #21
0
    private void BindScripts()
    {
        ApiCaller ac = gameObject.GetComponent <ApiCaller>();

        if (ac == null)
        {
            gameObject.AddComponent("ApiCaller");
        }
    }
Example #22
0
        public async Task <Result> Refund(Booking booking, DateTime operationDate, ApiCaller apiCaller)
        {
            if (booking.PaymentStatus != BookingPaymentStatuses.Captured)
            {
                return(Result.Failure($"Refund is only available for payments with '{BookingPaymentStatuses.Captured}' status"));
            }

            return(await _creditCardPaymentProcessingService.RefundMoney(booking.ReferenceCode, apiCaller, operationDate, _paymentCallbackService));
        }
Example #23
0
        public void ThenTheClassSStartAndEndTimeIsUpdated()
        {
            var classModel = ApiCaller.Get <ClassModel>(Routes.GetById(Routes.Classes, ScenarioCache.GetId(ModelIdKeys.ClassId))).Data;

            var expectedClassModel = ScenarioCache.Get <ClassModel>(ModelKeys.Class);

            Assert.AreEqual(expectedClassModel.StartTime, classModel.StartTime);
            Assert.AreEqual(expectedClassModel.EndTime, classModel.EndTime);
        }
        private async void GetForecast()
        {
            var url = $"https://api.openweathermap.org/data/2.5/forecast?q={Location}&appid=57fa57ff52ef2cd7db37b5577cd46a64&units=metric";

            var result = await ApiCaller.Get(url);

            if (result.Successful)
            {
                try
                {
                    var forcastInfo = JsonConvert.DeserializeObject <ForecastInfo>(result.Response);

                    List <List> allList = new List <List>();

                    foreach (var list in forcastInfo.list)
                    {
                        var date = DateTime.Parse(list.dt_txt);

                        if (date > DateTime.Now && date.Hour == 0 && date.Minute == 0 && date.Second == 0)
                        {
                            allList.Add(list);
                        }
                    }

                    int allListCount = allList.Count;

                    dayOneTxt.Text    = DateTime.Parse(allList[0].dt_txt).ToString("dddd");
                    dateOneTxt.Text   = DateTime.Parse(allList[0].dt_txt).ToString("dd MMM");
                    iconOneImg.Source = $"w{allList[0].weather[0].icon}";
                    tempOneTxt.Text   = allList[0].main.temp.ToString("0");

                    dayTwoTxt.Text    = DateTime.Parse(allList[1].dt_txt).ToString("dddd");
                    dateTwoTxt.Text   = DateTime.Parse(allList[1].dt_txt).ToString("dd MMM");
                    iconTwoImg.Source = $"w{allList[1].weather[0].icon}";
                    tempTwoTxt.Text   = allList[1].main.temp.ToString("0");

                    dayThreeTxt.Text    = DateTime.Parse(allList[2].dt_txt).ToString("dddd");
                    dateThreeTxt.Text   = DateTime.Parse(allList[2].dt_txt).ToString("dd MMM");
                    iconThreeImg.Source = $"w{allList[2].weather[0].icon}";
                    tempThreeTxt.Text   = allList[2].main.temp.ToString("0");

                    dayFourTxt.Text    = DateTime.Parse(allList[3].dt_txt).ToString("dddd");
                    dateFourTxt.Text   = DateTime.Parse(allList[3].dt_txt).ToString("dd MMM");
                    iconFourImg.Source = $"w{allList[3].weather[0].icon}";
                    tempFourTxt.Text   = allList[3].main.temp.ToString("0");
                }
                catch (Exception ex)
                {
                    await DisplayAlert("Weather Info", ex.Message, "OK");
                }
            }
            else
            {
                await DisplayAlert("Weather Info", "No forecast information found", "OK");
            }
        }
Example #25
0
        /// <summary>
        /// Create a API client instance
        /// </summary>
        /// <param name="clientId">OAuth 2.0 client ID</param>
        /// <param name="secret">OAuth 2.0 secret</param>
        public Client(string clientId, string secret)
        {
            apiCaller = new ApiCaller(clientId, secret);

            ArticleV2 = new ArticleV2Endpoint(apiCaller);
            EpcV2 = new EpcV2Endpoint(apiCaller);
            EpcisV1_1 = new EpcisV1_1Endpoint(apiCaller);
            ErpV1 = new ErpV1Endpoint(apiCaller);
            WorkflowV2 = new WorkflowV2Endpoint(apiCaller);
        }
Example #26
0
        static void Main(string[] args)
        {
            AddValues();
            consoleIo = new ConsoleIo();
            String    url       = Url(consoleIo.UserReponses);
            ApiCaller apiCaller = new ApiCaller(url);
            var       jsonObj   = apiCaller.Response;

            Output(jsonObj);
        }
Example #27
0
        public void WhenAUserIsCreated()
        {
            var expectedUser = ScenarioCache.Get <UserModel>(ExpectedUserKey);

            var userResponse = ApiCaller.Post <ActionReponse <UserModel> >(expectedUser, Routes.Users);

            Assert.AreEqual(HttpStatusCode.Created, userResponse.StatusCode);

            ScenarioCache.Store(ModelIdKeys.UserId, userResponse.Data.ActionResult.Id);
        }
Example #28
0
        public void ThenTheUserIsEnroledInTheBlock()
        {
            var response = ApiCaller.Get <BlockForRegistrationModel>(Routes.GetById(Routes.Blocks, ScenarioCache.GetId(ModelIdKeys.BlockId)));

            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);

            var user = response.Data.EnroledStudents.Single();

            Assert.AreEqual(ScenarioCache.GetId(ModelIdKeys.UserId), user.Id);
        }
        private string GetSetting(SettingTypes settingType)
        {
            var response = ApiCaller.Get <SettingItemModel>(Routes.GetSettingsByType(settingType));

            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);

            var actualRate = response.Data.Value;

            return(actualRate);
        }
        public void ThenLogoSettingIsRetrieved()
        {
            var response = ApiCaller.Get <SettingItemModel>(Routes.GetSettingsByType(SettingTypes.Logo));

            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);

            var expectedLogoSetting = ScenarioCache.Get <SettingItemModel>(ModelKeys.SettingItem);

            Assert.AreEqual(expectedLogoSetting.Value, response.Data.Value);
        }
        public void ApiCaller_FindTitles_Queen_ReturnsCorrectData()
        {
            ApiCaller     caller = new ApiCaller();
            List <string> result = caller.FindSongTitlesByArtist(testArtistId);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Count > 0);
            //I thought about asserting the exact number of songs that are returned 220. However if queen ever released another song
            //this unit test would break.
        }
Example #32
0
        public static void Test_MethodRepresentations()
        {
            var api = new ApiCaller("192.168.1.35", 8000);

            var l = api.Login("nas", "nas");

            //Debug.WriteLine(l);

            api.UnpauseServer();
        }
Example #33
0
        public void ThenTheBlocksDatesAreInUtc()
        {
            var response = ApiCaller.Get <BlockModel>(Routes.GetById(Routes.Blocks, ScenarioCache.GetId(ModelIdKeys.BlockId)));

            var originalBlock = ScenarioCache.Get <BlockModel>(ModelKeys.Block);

            Assert.AreNotEqual(originalBlock.StartDate.Offset, response.Data.StartDate.Offset);
            Assert.AreEqual(originalBlock.StartDate.ToUniversalTime(), response.Data.StartDate.ToUniversalTime());
            Assert.AreEqual(originalBlock.StartDate.ToLocalTime(), response.Data.StartDate.ToLocalTime());
        }
Example #34
0
        public async Task <Result> RefreshStatus(int bookingId, ApiCaller apiCaller)
        {
            var(_, _, batchOperationResult) = await RefreshStatuses(new List <int> {
                bookingId
            }, apiCaller);

            return(batchOperationResult.HasErrors
                ? Result.Failure(batchOperationResult.Message)
                : Result.Success());
        }
    public void Constructors()
    {
      Assert.Throws<ArgumentNullException>(() => new ApiCaller(ApiDataFormat.Xml, null));
      Assert.Throws<ArgumentException>(() => new ApiCaller(ApiDataFormat.Xml, string.Empty));

      var caller = new ApiCaller(ApiDataFormat.Xml, "apiToken", "appToken");
      Assert.Equal("apiToken", caller.ApiToken);
      Assert.Equal("appToken", caller.AppToken);
      Assert.Equal(ApiDataFormat.Xml, caller.Format);
      Assert.True(caller.Field("jsonSerializer").To<ISerializer>() is RuLawJsonSerializer);
      Assert.True(caller.Field("jsonDeserializer").To<IDeserializer>() is RuLawJsonDeserializer);
      Assert.True(caller.Field("xmlSerializer").To<ISerializer>() is RuLawXmlSerializer);
      Assert.True(caller.Field("xmlDeserializer").To<IDeserializer>() is RuLawXmlDeserializer);

      var client = caller.Field("restClient").To<RestClient>();
      Assert.Equal("http://api.duma.gov.ru/api", client.BaseUrl.ToString());
      var token = client.DefaultParameters.FirstOrDefault(x => x.Name == "app_token");
      Assert.NotNull(token);
      Assert.Equal("appToken", token.Value);
    }
Example #36
0
        public static void Test_Login()
        {
            var apiCaller = new ApiCaller("192.168.1.35", 8000);

            var loggedIn = apiCaller.Login("nas", "nas");

            var links = new List<Url>
            {
                new Url(@"http://uploaded.net/file/zlrwd0pw"),
                new Url(@"http://uploaded.net/file/zqh6mdzf"),
                new Url(@"http://uploaded.net/file/zwshn6au"),
                new Url(@"http://uploaded.net/file/zxvzn7r5"),
            };

            var pid = apiCaller.AddPackage(links.Select(l => l.ToString()).ToArray());

            var package = apiCaller.GetPackageInfo(pid);

            Console.WriteLine(String.Format("Folder: {0} | {1} of {2} links downloaded",
                package.folder, package.stats.linksdone, package.stats.linkstotal));
        }
 internal EpcisV1_1Endpoint(ApiCaller apiCaller)
 {
     this.apiCaller = apiCaller;
 }
 internal ErpV1Endpoint(ApiCaller apiCaller)
 {
     this.apiCaller = apiCaller;
 }
 internal EpcV2Endpoint(ApiCaller apiCaller)
 {
     this.apiCaller = apiCaller;
 }
 internal ArticleV2Endpoint(ApiCaller apiCaller)
 {
     this.apiCaller = apiCaller;
 }
Example #41
0
        private ApiCaller GetCaller()
        {
            var caller = new ApiCaller("http://laserfiche.leankit.com");
            caller.Authenticate(@"*****@*****.**", @"L@53rf1ch3");

            return caller;
        }
 internal WorkflowV2Endpoint(ApiCaller apiCaller)
 {
     this.apiCaller = apiCaller;
 }
 internal SystemV1Endpoint(ApiCaller apiCaller)
 {
     this.apiCaller = apiCaller;
 }
Example #44
0
        private void Dispose(bool disposing)
        {
            if (disposed)
            {
                return;
            }

            if (disposing)
            {
                if (apiCaller != null)
                {
                    apiCaller.Dispose();
                    apiCaller = null;
                }
            }

            disposed = true;
        }