コード例 #1
0
ファイル: Form1.cs プロジェクト: Rusk85/pyLoad-API-Library
 public MainWindow()
 {
     InitializeComponent();
     _downloader = new ApiCaller("192.168.1.35", 8000);
     _downloader.Login("nas", "nas");
     this.Text = "BatchDownloader";
 }
コード例 #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");
        }
コード例 #3
0
        private async void ExecuteAdicionarEventoCommand()
        {
            Tarefa tarefa = new Tarefa();

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

            await ApiCaller.CreateTarefa(tarefa);
        }
コード例 #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);
        }
コード例 #5
0
        public void WhenTheTeacherUnchecksTheStudentIn()
        {
            var response =
                ApiCaller.Delete <ActionReponse <ClassModel> >(
                    Routes.GetAttendClass(ScenarioCache.GetId(ModelIdKeys.ClassId),
                                          ScenarioCache.GetId(ModelIdKeys.UserId)));

            ScenarioCache.StoreActionResponse(response);
        }
コード例 #6
0
        public void WhenTheRatesForAllTeachersAreRequested()
        {
            var url = Routes.TeacherRates;

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

            ScenarioCache.StoreResponse(response);
            ScenarioCache.Store(ModelKeys.TeacherRate, response.Data);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #9
0
ファイル: Tests.cs プロジェクト: emilysas/ReturnOfTheSergei
        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);
        }
コード例 #10
0
        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();
        }
コード例 #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));
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #14
0
ファイル: Program.cs プロジェクト: shahedc/DessertDecider
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            Console.WriteLine(ApiCaller.GetNumericPoints().ToString());
            Console.WriteLine(ApiCaller.GetBoolDecision().ToString());


            Console.ReadKey();
        }
コード例 #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);
            }
        }
コード例 #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);
        }
コード例 #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());
        }
コード例 #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);
        }
コード例 #19
0
        public void WhenTheTeacherUnchecksTheStudentIntoTheEvent()
        {
            var response =
                ApiCaller.Delete <ActionReponse <StandAloneEventModel> >(
                    Routes.GetAttendEvent(ScenarioCache.GetId(ModelIdKeys.StandAloneEventId),
                                          ScenarioCache.GetId(ModelIdKeys.UserId)));

            ScenarioCache.StoreActionResponse(response);
        }
コード例 #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);
        }
コード例 #21
0
    private void BindScripts()
    {
        ApiCaller ac = gameObject.GetComponent <ApiCaller>();

        if (ac == null)
        {
            gameObject.AddComponent("ApiCaller");
        }
    }
コード例 #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));
        }
コード例 #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);
        }
コード例 #24
0
        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");
            }
        }
コード例 #25
0
ファイル: Client.cs プロジェクト: nedap/retail-services-API
        /// <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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #29
0
        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);
        }
コード例 #30
0
        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);
        }
コード例 #31
0
        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.
        }
コード例 #32
0
ファイル: Tests.cs プロジェクト: Rusk85/pyLoad-API-Library
        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();
        }
コード例 #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());
        }
コード例 #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());
        }
コード例 #35
0
    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);
    }
コード例 #36
0
ファイル: Tests.cs プロジェクト: Rusk85/pyLoad-API-Library
        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));
        }
コード例 #37
0
 internal EpcisV1_1Endpoint(ApiCaller apiCaller)
 {
     this.apiCaller = apiCaller;
 }
コード例 #38
0
 internal ErpV1Endpoint(ApiCaller apiCaller)
 {
     this.apiCaller = apiCaller;
 }
コード例 #39
0
 internal EpcV2Endpoint(ApiCaller apiCaller)
 {
     this.apiCaller = apiCaller;
 }
コード例 #40
0
 internal ArticleV2Endpoint(ApiCaller apiCaller)
 {
     this.apiCaller = apiCaller;
 }
コード例 #41
0
        private ApiCaller GetCaller()
        {
            var caller = new ApiCaller("http://laserfiche.leankit.com");
            caller.Authenticate(@"*****@*****.**", @"L@53rf1ch3");

            return caller;
        }
コード例 #42
0
 internal WorkflowV2Endpoint(ApiCaller apiCaller)
 {
     this.apiCaller = apiCaller;
 }
コード例 #43
0
 internal SystemV1Endpoint(ApiCaller apiCaller)
 {
     this.apiCaller = apiCaller;
 }
コード例 #44
0
ファイル: Client.cs プロジェクト: nedap/retail-services-API
        private void Dispose(bool disposing)
        {
            if (disposed)
            {
                return;
            }

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

            disposed = true;
        }