/// <inheritdoc /> public async Task <PlaidResult <ItemResponse> > UpdateWebHookAsync(string accessToken, string webhook) { //conditions Condition.Requires(accessToken).IsNotNullOrWhiteSpace(); Condition.Requires(webhook).IsNotNullOrWhiteSpace(); //create the payload to pass var payload = new UpdateWebHookRequest(clientId, clientSecret, accessToken, webhook); //serialize object HttpContent content = ContentExtensions.ToJsonContent(payload); //post it and get the response HttpResponseMessage response = await this.httpClient.PostAsync(PlaidInformation.ItemManagement_UpdateWebhook, content); //read the string string responseJson = await response.Content.ReadAsStringAsync(); //create the result PlaidResult <ItemResponse> result = new PlaidResult <ItemResponse>(responseJson); //is it ok if (response.StatusCode == HttpStatusCode.OK) { ItemResponse itemResponse = JsonConvert.DeserializeObject <ItemResponse>(responseJson); result.Value = itemResponse; } //parse the exception result.Exception = await this.ParseException(response, responseJson); //return return(result); }
/// <inheritdoc /> public async Task <PlaidResult <ListOfCategoriesResponse> > GetListOfCategoriesAsync() { //create the payload to pass var payload = string.Empty; //serialize object HttpContent content = ContentExtensions.ToJsonContent(payload); //post it and get the response HttpResponseMessage response = await this.httpClient.PostAsync("categories/get", content); //read the string string responseJson = await response.Content.ReadAsStringAsync(); //create the result PlaidResult <ListOfCategoriesResponse> result = new PlaidResult <ListOfCategoriesResponse>(responseJson); //is it ok if (response.StatusCode == HttpStatusCode.OK) { ListOfCategoriesResponse listCategoriesResponse = JsonConvert.DeserializeObject <ListOfCategoriesResponse>(responseJson); result.Value = listCategoriesResponse; } //parse the exception result.Exception = await this.ParseException(response, responseJson); //return return(result); }
/// <inheritdoc /> public async Task <PlaidResult <ListOfInstitutionsWithTotalResponse> > GetListOfInstitutionsAsync(int count = 500, int offset = 0) { //conditions Condition.Ensures(count >= 0); Condition.Ensures(offset >= 0); //create the payload to pass var payload = new ListOfInstitutionsRequest(clientId, clientSecret, count, offset); //serialize object HttpContent content = ContentExtensions.ToJsonContent(payload); //post it and get the response HttpResponseMessage response = await this.httpClient.PostAsync(PlaidInformation.Institutions_GetInstitutions, content); //read the string string responseJson = await response.Content.ReadAsStringAsync(); //create the result PlaidResult <ListOfInstitutionsWithTotalResponse> result = new PlaidResult <ListOfInstitutionsWithTotalResponse>(responseJson); //is it ok if (response.StatusCode == HttpStatusCode.OK) { ListOfInstitutionsWithTotalResponse listOfInstitutionsResponse = JsonConvert.DeserializeObject <ListOfInstitutionsWithTotalResponse>(responseJson); result.Value = listOfInstitutionsResponse; } //parse the exception result.Exception = await this.ParseException(response, responseJson); //return return(result); }
/// <inheritdoc /> public async Task <PlaidResult <Institution> > GetInstitutionAsync(string id) { //conditions Condition.Requires(id).IsNotNullOrWhiteSpace(); //create the payload to pass var payload = new InstitutionRequest(clientPublicKey, id); //serialize object HttpContent content = ContentExtensions.ToJsonContent(payload); //post it and get the response HttpResponseMessage response = await this.httpClient.PostAsync(PlaidInformation.Institutions_GetInstitutionsById, content); //read the string string responseJson = await response.Content.ReadAsStringAsync(); //create the result PlaidResult <Institution> result = new PlaidResult <Institution>(responseJson); //is it ok if (response.StatusCode == HttpStatusCode.OK) { Institution institutionResponse = JsonConvert.DeserializeObject <Institution>(responseJson); result.Value = institutionResponse; } //parse the exception result.Exception = await this.ParseException(response, responseJson); //return return(result); }
/// <inheritdoc /> public async Task <PlaidResult <ListOfInstitutionsResponse> > SearchInstitutions(string query, IList <string> products = null) { //conditions Condition.Requires(query).IsNotNullOrWhiteSpace(); //create the payload to pass var payload = new InstitutionSearchRequest(clientPublicKey, query, products); //serialize object HttpContent content = ContentExtensions.ToJsonContent(payload); //post it and get the response HttpResponseMessage response = await this.httpClient.PostAsync(PlaidInformation.Institutions_SearchInstitutions, content); //read the string string responseJson = await response.Content.ReadAsStringAsync(); //create the result PlaidResult <ListOfInstitutionsResponse> result = new PlaidResult <ListOfInstitutionsResponse>(responseJson); //is it ok if (response.StatusCode == HttpStatusCode.OK) { ListOfInstitutionsResponse listOfInstitutionsResponse = JsonConvert.DeserializeObject <ListOfInstitutionsResponse>(responseJson); result.Value = listOfInstitutionsResponse; } //parse the exception result.Exception = await this.ParseException(response, responseJson); //return return(result); }
/// <inheritdoc /> public async Task <PlaidResult <AccessTokenResponse> > ExchangePublicTokenForAccessTokenAsync(string publicToken) { //conditions Condition.Requires(publicToken).IsNotNullOrWhiteSpace(); //create the payload to pass var payload = new ExchangePublicTokenForAccessTokenRequest(clientId, clientSecret, publicToken); //serialize object HttpContent content = ContentExtensions.ToJsonContent(payload); //post it and get the response HttpResponseMessage response = await this.httpClient.PostAsync(PlaidInformation.LinkEndpoint_ExchangePublicToken, content); //read the string string responseJson = await response.Content.ReadAsStringAsync(); //create the result PlaidResult <AccessTokenResponse> result = new PlaidResult <AccessTokenResponse>(responseJson); //is it ok if (response.StatusCode == HttpStatusCode.OK) { AccessTokenResponse exchangeTokenResponse = JsonConvert.DeserializeObject <AccessTokenResponse>(responseJson); result.Value = exchangeTokenResponse; } //parse the exception result.Exception = await this.ParseException(response, responseJson); //return return(result); }
/// <inheritdoc /> public async Task <PlaidResult <RetrieveTransactionsResponse> > RetrieveTransactionsAsync(string accessToken, DateTimeOffset startDate, DateTimeOffset endDate, int count = 250, int offset = 0) { //conditions Condition.Requires(accessToken).IsNotNullOrWhiteSpace(); Condition.Requires(startDate).IsLessOrEqual(endDate); Condition.Requires(count).IsGreaterThan(0); Condition.Requires(offset).IsGreaterOrEqual(0); //create the payload to pass var payload = new RetrieveTransactionsRequest(clientId, clientSecret, accessToken, startDate, endDate, count, offset); //serialize object HttpContent content = ContentExtensions.ToJsonContent(payload); //post it and get the response HttpResponseMessage response = await this.httpClient.PostAsync(PlaidInformation.ProductAccessEndpoint_GetTransactions, content); //read the string string responseJson = await response.Content.ReadAsStringAsync(); //create the result PlaidResult <RetrieveTransactionsResponse> result = new PlaidResult <RetrieveTransactionsResponse>(responseJson); //is it ok if (response.StatusCode == HttpStatusCode.OK) { RetrieveTransactionsResponse retAccsResponse = JsonConvert.DeserializeObject <RetrieveTransactionsResponse>(responseJson); result.Value = retAccsResponse; } //parse the exception result.Exception = await this.ParseException(response, responseJson); //return return(result); }