chore: initial commit

This commit is contained in:
Matthias Langhard
2021-04-12 13:54:09 +02:00
commit 2a2527f0da
64 changed files with 12106 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.Extensions.Options;
using Novaloop.BexioApi.Contacts.Models;
using Novaloop.BexioApi.Extensions;
using Novaloop.BexioApi.Shared.ApiClient;
using Novaloop.BexioApi.Shared.Models;
namespace Novaloop.BexioApi.Contacts
{
public class BexioContactsApiService : IBexioContactsApiService
{
private readonly BexioApiOptions _options;
private readonly HttpClient _client;
public BexioContactsApiService(BexioApiClient bexioApiClient, IOptions<BexioApiOptions> options)
{
_options = options.Value;
_client = bexioApiClient.Client;
}
/// <summary>
/// Receive all existing contacts
/// </summary>
public async Task<IEnumerable<BexioContact>> GetAll()
{
_client.SetApiKeyHeader(_options.ApiToken);
var response = await _client.GetAsync("contact");
await response.ThrowExceptionWithDetailsIfUnsuccessful();
return await response.Content.ReadAsAsync<BexioContact[]>();
}
/// <summary>
/// Search contacts via query
/// </summary>
/// <param name="searchParams"></param>
/// <returns></returns>
public async Task<IEnumerable<BexioContact>> Search(IEnumerable<BexioSearchParameter> searchParams)
{
_client.SetApiKeyHeader(_options.ApiToken);
var response = await _client.PostAsJsonAsync("contact/search", searchParams);
await response.ThrowExceptionWithDetailsIfUnsuccessful();
return await response.Content.ReadAsAsync<IEnumerable<BexioContact>>();
}
}
}

View File

@@ -0,0 +1,13 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Novaloop.BexioApi.Contacts.Models;
using Novaloop.BexioApi.Shared.Models;
namespace Novaloop.BexioApi.Contacts
{
public interface IBexioContactsApiService
{
Task<IEnumerable<BexioContact>> GetAll();
Task<IEnumerable<BexioContact>> Search(IEnumerable<BexioSearchParameter> searchParams);
}
}

View File

@@ -0,0 +1,95 @@
using Newtonsoft.Json;
using Novaloop.BexioApi.Shared.Models;
namespace Novaloop.BexioApi.Contacts.Models
{
public class BexioContact : BexioBaseModel
{
[JsonProperty("contact_type_id")]
public BexioContactTypeId ContactTypeId { get; set; }
[JsonProperty("name_1")]
public string Name1 { get; set; }
[JsonProperty("name_2")]
public object Name2 { get; set; }
[JsonProperty("salutation_id")]
public int SalutationId { get; set; }
[JsonProperty("salutation_form")]
public object SalutationForm { get; set; }
[JsonProperty("title_id")]
public object TitleId { get; set; }
[JsonProperty("birthday")]
public object Birthday { get; set; }
[JsonProperty("address")]
public string Address { get; set; }
[JsonProperty("postcode")]
public int? Postcode { get; set; }
[JsonProperty("city")]
public string City { get; set; }
[JsonProperty("country_id")]
public int CountryId { get; set; }
[JsonProperty("mail")]
public string Mail { get; set; }
[JsonProperty("mail_second")]
public string MailSecond { get; set; }
[JsonProperty("phone_fixed")]
public string PhoneFixed { get; set; }
[JsonProperty("phone_fixed_second")]
public string PhoneFixedSecond { get; set; }
[JsonProperty("phone_mobile")]
public string PhoneMobile { get; set; }
[JsonProperty("fax")]
public string Fax { get; set; }
[JsonProperty("url")]
public string Url { get; set; }
[JsonProperty("skype_name")]
public string SkypeName { get; set; }
[JsonProperty("remarks")]
public string Remarks { get; set; }
[JsonProperty("language_id")]
public object LanguageId { get; set; }
[JsonProperty("is_lead")]
public bool IsLead { get; set; }
[JsonProperty("contact_group_ids")]
public string ContactGroupIds { get; set; }
[JsonProperty("contact_branch_ids")]
public object ContactBranchIds { get; set; }
[JsonProperty("user_id")]
public int UserId { get; set; }
[JsonProperty("owner_id")]
public int OwnerId { get; set; }
[JsonProperty("updated_at")]
public string UpdatedAt { get; set; }
}
public enum BexioContactTypeId
{
Company = 1,
Person = 2
}
}

View File

@@ -0,0 +1,9 @@
using System.Collections.Generic;
namespace Novaloop.BexioApi.Contacts.Models
{
public abstract class GetContactsResponse
{
public IEnumerable<BexioContact> Tasks { get; set; }
}
}