28 lines
912 B
C#
28 lines
912 B
C#
using FastBill.Api.Response;
|
|
using FastBill.Models;
|
|
using RestSharp;
|
|
using RestSharp.Authenticators;
|
|
using Contact = FastBill.Models.Contact;
|
|
|
|
namespace FastBill.Api;
|
|
|
|
public class Contacts
|
|
{
|
|
async public Task<List<Contact>> GetContacts(Settings settings, string customerId)
|
|
{
|
|
var customers = new List<Contact>();
|
|
|
|
var client = new RestClient("https://my.fastbill.com/");
|
|
var request = new RestRequest("api/1.0/api.php"){
|
|
Authenticator = new HttpBasicAuthenticator(settings.EMail, settings.ApiKey)
|
|
};
|
|
request.AddJsonBody(new { SERVICE = "contact.get", FILTER = new { CUSTOMER_ID = customerId } });
|
|
var response = await client.ExecuteAsync<GetContacts>(request);
|
|
if (response.StatusCode == System.Net.HttpStatusCode.OK)
|
|
{
|
|
return response.Data.Response.Contacts;
|
|
}
|
|
|
|
return customers;
|
|
}
|
|
} |