26 lines
858 B
C#
26 lines
858 B
C#
using FastBill.Models;
|
|
using RestSharp;
|
|
using RestSharp.Authenticators;
|
|
|
|
namespace FastBill.Api;
|
|
|
|
public class Customers
|
|
{
|
|
async public Task<List<Customer>> SearchCustomer(Settings settings, string term)
|
|
{
|
|
var customers = new List<Customer>();
|
|
|
|
var client = new RestClient("https://my.fastbill.com/");
|
|
var request = new RestRequest("api/1.0/api.php");
|
|
request.Authenticator = new HttpBasicAuthenticator(settings.EMail, settings.ApiKey);
|
|
request.RequestFormat = DataFormat.Json;
|
|
request.AddJsonBody(new { SERVICE = "customer.get", FILTER = new { TERM = term } });
|
|
var response = await client.ExecuteAsync<List<Customer>>(request);
|
|
if (response.StatusCode == System.Net.HttpStatusCode.OK)
|
|
{
|
|
return response.Data;
|
|
}
|
|
|
|
return customers;
|
|
}
|
|
} |