public ApiContext GetAuthorizedContext(PelicanContext pelicanContext, Guid companyFileId) { var keyService = new OAuthKeyService(this); var configuration = new ApiConfiguration(pelicanContext.ClientKey, pelicanContext.ClientSecret, pelicanContext.RedirectUrl); // get companyfiles var cfService = new CompanyFileService(configuration, null, keyService); var companyFiles = cfService.GetRange(); // select var companyFile = companyFiles.FirstOrDefault(_ => _.Id == companyFileId); // fetch accounts var credentials = new CompanyFileCredentials("Administrator", ""); return new ApiContext { ApiConfiguration = configuration, CompanyFileCredentials = credentials, KeyService = keyService, CompanyFile = companyFile, }; }
public void WhenICreateAConfigObjectForNetworkMode() { var config = new ApiConfiguration("<<apibaseurl>>"); Assert.AreEqual("<<apibaseurl>>", config.ApiBaseUrl); Assert.IsNull(config.ClientId); Assert.IsNull(config.ClientSecret); Assert.IsNull(config.RedirectUrl); }
public void WhenICreateAConfigObjectTheBaseUrlDefaultsToCloudUrl() { var config = new ApiConfiguration("<<clientid>>", "<<clientsecret>>", "<<redirecturl>>"); Assert.AreEqual("<<clientid>>", config.ClientId); Assert.AreEqual("<<clientsecret>>", config.ClientSecret); Assert.AreEqual("<<redirecturl>>", config.RedirectUrl); Assert.AreEqual(ApiRequestHandler.ApiRequestUri, config.ApiBaseUrl); }
public void WhenICreateAConfigObjectItCorrectlyStoresTheSuppliedEntries() { var config = new ApiConfiguration("<<clientid>>", "<<clientsecret>>", "<<redirecturl>>", "<<apibaseurl>>"); Assert.AreEqual("<<clientid>>", config.ClientId); Assert.AreEqual("<<clientsecret>>", config.ClientSecret); Assert.AreEqual("<<redirecturl>>", config.RedirectUrl); Assert.AreEqual("<<apibaseurl>>", config.ApiBaseUrl); }
public void InitService( CompanyFile companyFile, SDK.CompanyFileCredentials credentials, SDK.ApiConfiguration myConfiguration, OAuthKeyService myOAuthKeyService) { myCompanyFile = companyFile; myCredentials = credentials; myService = new ItemBillService(myConfiguration, null, myOAuthKeyService); }
public AuthorizationService() { _pelicanContext = PelicanContext.CreateFromApplicationSettings(); var cloudStorageAccount = new CloudStorageAccount(new StorageCredentials(_pelicanContext.StorageAccount, _pelicanContext.StorageAccountKey), true); var configuration = new ApiConfiguration(_pelicanContext.ClientKey, _pelicanContext.ClientSecret, _pelicanContext.RedirectUrl); _oauthService = new OAuthService(configuration); _authorizedUserAndFileTable = new AuthorizedUserAndFileTable(cloudStorageAccount, "PelicanConfiguration"); _authorizedUserAndCompanyFile = _authorizedUserAndFileTable.RetrieveInstanceByRowKey("John Azariah"); }
public JsonResult Search(string search, SortDescription sort, string webApiUrl, bool isCloud) { if (isCloud) { APIConfiguration = new ApiConfiguration(OAuthInformation.Key, OAuthInformation.Secret, OAuthInformation.RedirectUri); } else { APIConfiguration = new ApiConfiguration(webApiUrl); } var searchCriteria = new List<SearchCriteria>(); if (!string.IsNullOrEmpty(search)) searchCriteria = new[]{ new SearchCriteria { Field = "Name", SearchText = search, FieldType = typeof(string) }, new SearchCriteria { Field = "ProductVersion", SearchText = search, FieldType = typeof(string) }, new SearchCriteria { Field = "LibraryPath", SearchText = search, FieldType = typeof(string) }}.ToList(); var query = QueryStringHelper.CombineQuery(searchCriteria, LogicalOperator.or, new[]{sort}, null); var service = new CompanyFileService(APIConfiguration, null, KeyService); var model = service.GetRange(query).ToList() ; return Json(model); }
public void FetchCompanyFies(Action<Exception> onError) { CompanyFiles.Clear(); IsLoading = true; ShowBrowser = false; var config = new ApiConfiguration(); var service = new CompanyFileService(config, new WebRequestFactory(config), _keyService); service.GetRangeAsync() .ContinueWith(t => { if (t.IsFaulted) { onError(t.Exception); ShowBrowser = true; IsLoading = false; } else { CompanyFiles.Clear(); foreach (var companyFile in t.Result) { CompanyFiles.Add(new CompanyFileViewModel {CompanyFile = companyFile}); } IsLoading = false; } }, TaskScheduler.FromCurrentSynchronizationContext()); }