Exemple #1
0
        public async Task <Result <LegalPerson> > DeleteAsync(string company_id, CancellationToken cancellationToken = default(CancellationToken))
        {
            try
            {
                var url = $"/v1/companies/{company_id}";

                var response = await _httpClient.DeleteAsync(url, cancellationToken);

                var result = await HttpResponseConvert <LegalPerson> .ResponseReadAsStringAsync(response);

                return(result);
            }
            catch (Exception ex)
            {
                return(new Result <LegalPerson>(ResultStatusCode.Error, ex.Message));
            }
        }
Exemple #2
0
        public async Task <Result <LegalPerson> > PostAsync(LegalPerson item, CancellationToken cancellationToken = default(CancellationToken))
        {
            try
            {
                var url = $"/v1/companies";

                var response = await _httpClient.PostAsync(url, new StringContent(item.ToJson <LegalPerson>(), Encoding.UTF8, "application/json"), cancellationToken);

                var result = await HttpResponseConvert <LegalPerson> .ResponseReadAsStringAsync(response, true);

                return(result);
            }
            catch (Exception ex)
            {
                return(new Result <LegalPerson>(ResultStatusCode.Error, ex.Message));
            }
        }
        public async Task <Result <InvoiceResource> > PostAsync(string company_id, Invoice item, CancellationToken cancellationToken = default(CancellationToken))
        {
            try
            {
                var url = $"/v1/companies/{company_id}/serviceinvoices";

                var response = await _httpClient.PostAsync(url, new StringContent(item.ToJson <Invoice>(), Encoding.UTF8, "application/json"), cancellationToken);

                var result = await HttpResponseConvert <InvoiceResource> .ResponseReadAsStringAsync(response);

                return(result);
            }
            catch (Exception ex)
            {
                return(new Result <InvoiceResource>(ResultStatusCode.Error, ex.Message));
            }
        }
        public async Task <Result <string> > GetDocumentPdfUrlAsync(string company_id, string invoiceId, CancellationToken cancellationToken = default(CancellationToken))
        {
            try
            {
                var url = $"/v1/companies/{company_id}/serviceinvoices/{invoiceId}/pdf";

                var response = await _httpClient.GetAsync(url, cancellationToken);

                var result = await HttpResponseConvert <string> .ResponseReadAsByteAsync(response);

                return(result);
            }
            catch (Exception ex)
            {
                return(new Result <string>(ResultStatusCode.Error, ex.Message));
            }
        }
        public async Task <Result <string> > SendEmailAsync(string company_id, string invoiceId, CancellationToken cancellationToken = default(CancellationToken))
        {
            try
            {
                var url = $"/v1/companies/{company_id}/serviceinvoices/{invoiceId}/sendemail";

                var response = await _httpClient.PutAsync(url, null, cancellationToken);

                var result = await HttpResponseConvert <string> .ResponseReadAsStringAsyncRetXml(response);

                return(result);
            }
            catch (Exception ex)
            {
                return(new Result <string>(ResultStatusCode.Error, ex.Message));
            }
        }