public async Task <CardSearchObject> GetListOfCards(string cardName) { var client = GetClient(); var inputQuery = MakeQuery(cardName); var response = await client.GetAsync($"/cards/search?q={cardName}"); CardSearchObject card = await response.Content.ReadAsAsync <CardSearchObject>(); return(card); }
public async Task <CardSearchObject> GetCommandersAsync(string page) { HttpClient client = new HttpClient(); client.BaseAddress = new Uri($"{page}"); var response = await client.GetAsync(""); CardSearchObject card = await response.Content.ReadAsAsync <CardSearchObject>(); return(card); }
public async Task <CardSearchObject> GetSearch(string input, string budget) { var client = GetClient(); //calls the method that gives the API the general information needed to //receive data from the API var inputQuery = MakeQuery(input); var response = await client.GetAsync($"/cards/search?order=edhrec&q=usd<={budget}+{input}"); //uses the client (HTTPClient) to receive //data from the API based off of a certain endpoint. CardSearchObject card = await response.Content.ReadAsAsync <CardSearchObject>(); //install-package Microsoft.AspNet.WebAPI.Client //response has a property called Content and Content has a method that reads the JSON and plugs it into a specified //obect. If the JSON does not fit within the object we get an Internal Deserialization error return(card); }