public async static Task <AddInvoiceCCResponse> Add(GetAddesssApi api, AddInvoiceCCRequest request, string path, AdminKey adminKey) { if (api == null) { throw new ArgumentNullException(nameof(api)); } if (request == null) { throw new ArgumentNullException(nameof(request)); } api.SetAuthorizationKey(adminKey); var response = await api.Post(path, request); var body = await response.Content.ReadAsStringAsync(); if (response.IsSuccessStatusCode) { var messageAndId = GetMessageAndId(body); var id = long.Parse(messageAndId.Id); return(new AddInvoiceCCResponse.Success((int)response.StatusCode, response.ReasonPhrase, body, messageAndId.Message, id)); } return(new AddInvoiceCCResponse.Failed((int)response.StatusCode, response.ReasonPhrase, body)); }
public async Task <AddInvoiceCCResponse> Add(AddInvoiceCCRequest request, AdminKey adminKey = null, HttpClient httpClient = null) { using (var api = new GetAddesssApi(adminKey ?? AdminKey, HttpClient ?? httpClient)) { return(await api.InvoiceCC.Add(request)); } }
public async Task <AddInvoiceCCResponse> Add(AddInvoiceCCRequest request) { return(await Add(Api, request, Path, AdminKey)); }