/// <summary> /// Builds client according to parameter. /// </summary> /// <param name="service">API service enum.</param> /// <returns>Client instance.</returns> public static IClient GetClient(ApisEnum service) { IClient client; switch (service) { case ApisEnum.Pivotal: client = PivotalClient.GetInstance(); break; case ApisEnum.Trello: client = TrelloClient.GetInstance(); break; case ApisEnum.Todoist: client = TodoistClient.GetInstance(); break; case ApisEnum.Salesforce: client = SalesforceClient.GetInstance(); break; default: client = PivotalClient.GetInstance(); break; } return(client); }
/// <summary> /// Builds rest request instances according to parameter. /// </summary> /// <param name="service">API service enum.</param> /// <param name="resource">Enpoint resource.</param> /// <returns>rest request instance.</returns> public static IRequest GetRequest(ApisEnum service, string resource) { IRequest request; switch (service) { case ApisEnum.Pivotal: request = new PivotalRequest(resource); break; case ApisEnum.Trello: request = new TrelloRequest(resource); break; case ApisEnum.Todoist: request = new TodoistRequest(resource); break; case ApisEnum.Salesforce: request = new SalesforceRequest(resource); break; default: request = new PivotalRequest(resource); break; } return(request); }
public void WhenISendDeleteRequest(ApisEnum service, string endpoint) { string endpointMapped = Mapper.MapValue(endpoint, helper.GetData()); IRequest request = RequestFactory.GetRequest(service, endpointMapped); response = RequestManager.Delete(client, request); }
/// <summary> /// Gets API config value. /// </summary> /// <param name="service">API service.</param> /// <returns>API config object.</returns> public ApiConfig GetConfig(ApisEnum service) { var config = new ApiConfig(); switch (service) { case ApisEnum.Pivotal: config = apiServices.Pivotal; break; case ApisEnum.Trello: config = apiServices.Trello; break; case ApisEnum.Todoist: config = apiServices.Todoist; break; case ApisEnum.Salesforce: config = apiServices.Salesforce; break; } return(config); }
public void WhenISendPutRequest(ApisEnum service, string endpoint, string body) { string endpointMapped = Mapper.MapValue(endpoint, helper.GetData()); string bodyMapped = Mapper.MapValue(body, helper.GetData()); IRequest request = RequestFactory.GetRequest(service, endpointMapped); request.GetRequest().AddJsonBody(bodyMapped); response = RequestManager.Put(client, request); ReportUtils.AddJsonData("Request body", bodyMapped); ReportUtils.AddJsonData("Response body", response.GetResponse().Content); }
/// <summary> /// Gets base url value. /// </summary> /// <param name="service">API service.</param> /// <returns>Base url value.</returns> public string GetBaseUrl(ApisEnum service) { return(GetConfig(service).BaseUrl); }
/// <summary> /// Gets key value. /// </summary> /// <param name="service"> API service.</param> /// <returns>Key value.</returns> public string GetKey(ApisEnum service) { return(GetConfig(service).Key); }
/// <summary> /// Gets token value. /// </summary> /// <param name="service">API service.</param> /// <returns>Token value.</returns> public string GetToken(ApisEnum service) { return(GetConfig(service).Token); }
public void GivenIUseTheServiceClient(ApisEnum service) { client = ClientFactory.GetClient(service); }