Skip to content
This repository has been archived by the owner on Apr 12, 2021. It is now read-only.

Commit

Permalink
Merge pull request #372 from MJMortimer/f-batchpayments
Browse files Browse the repository at this point in the history
Add BatchPayments functionality
  • Loading branch information
MJMortimer authored Jan 25, 2019
2 parents e73046f + 5cbea0b commit c7da77c
Show file tree
Hide file tree
Showing 13 changed files with 181 additions and 4 deletions.
23 changes: 23 additions & 0 deletions Xero.Api/Core/Endpoints/BatchPaymentsEndpoint.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Xero.Api.Core.Endpoints.Base;
using Xero.Api.Core.Model;
using Xero.Api.Core.Request;
using Xero.Api.Core.Response;
using Xero.Api.Infrastructure.Http;

namespace Xero.Api.Core.Endpoints
{
public interface IBatchPaymentsEndpoint
: IXeroCreateEndpoint<BatchPaymentsEndpoint, BatchPayment, BatchPaymentsRequest, BatchPaymentsResponse>
{

}

public class BatchPaymentsEndpoint
: XeroCreateEndpoint<BatchPaymentsEndpoint, BatchPayment, BatchPaymentsRequest, BatchPaymentsResponse>, IBatchPaymentsEndpoint
{
public BatchPaymentsEndpoint(XeroHttpClient client) :
base(client, "/api.xro/2.0/BatchPayments")
{
}
}
}
1 change: 1 addition & 0 deletions Xero.Api/Core/IXeroCoreApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public interface IXeroCoreApi
AttachmentsEndpoint Attachments { get; }
IBankTransactionsEndpoint BankTransactions { get; }
IBankTransfersEndpoint BankTransfers { get; }
IBatchPaymentsEndpoint BatchPayments { get; }
IBrandingThemesEndpoint BrandingThemes { get; }
IContactsEndpoint Contacts { get; }
IContactGroupsEndpoint ContactGroups { get; }
Expand Down
52 changes: 52 additions & 0 deletions Xero.Api/Core/Model/BatchPayment.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using Xero.Api.Common;
using Xero.Api.Core.Model.Status;
using Xero.Api.Core.Model.Types;

namespace Xero.Api.Core.Model
{
[DataContract(Namespace = "")]
public class BatchPayment : HasUpdatedDate, IHasId
{
[DataMember(Name = "BatchPaymentID", EmitDefaultValue = false)]
public Guid Id { get; set; }

[DataMember(Name = "Type", EmitDefaultValue = false)]
public BatchPaymentType? Type { get; set; }

[DataMember(Name = "Status", EmitDefaultValue = false)]
public BatchPaymentStatus? Status { get; set; }

[DataMember(Name = "Account")]
public Account Account { get; set; }

[DataMember(Name = "Particulars", EmitDefaultValue = false)]
public string Particulars { get; set; }

[DataMember(Name = "Code", EmitDefaultValue = false)]
public string Code { get; set; }

[DataMember(Name = "Reference", EmitDefaultValue = false)]
public string Reference { get; set; }

[DataMember(Name = "Details", EmitDefaultValue = false)]
public string Details { get; set; }

[DataMember(Name = "Narrative", EmitDefaultValue = false)]
public string Narrative { get; set; }

[DataMember(Name = "Date", EmitDefaultValue = false)]
public DateTime? Date { get; set; }

[DataMember(Name = "Payments")]
public List<BatchPaymentPayment> Payments { get; set; }

[DataMember(Name = "TotalAmount", EmitDefaultValue = false)]
public decimal? Total { get; set; }

[DataMember(Name = "IsReconciled", EmitDefaultValue = false)]
public bool? IsReconciled { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

namespace Xero.Api.Core.Model
{
[DataContract(Namespace = "")]
public class BatchPayments : CoreData
[DataContract(Namespace = "", Name = "BatchPayments")]
public class BatchPaymentContactDefaults : CoreData
{
[DataMember(EmitDefaultValue = false)]
public string BankAccountNumber { get; set; }
Expand Down
37 changes: 37 additions & 0 deletions Xero.Api/Core/Model/BatchPaymentPayment.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System;
using System.Runtime.Serialization;
using Xero.Api.Common;

namespace Xero.Api.Core.Model
{
[DataContract(Namespace = "", Name = "Payment")]
public class BatchPaymentPayment : CoreData
{
[DataMember(Name = "Invoice")]
public Invoice Invoice { get; set; }

[DataMember(Name = "PaymentID", EmitDefaultValue = false)]
public Guid? PaymentId { get; set; }

[DataMember(Name = "BankAccountNumber", EmitDefaultValue = false)]
public string BankAccountNumber { get; set; }

[DataMember(Name = "Particulars", EmitDefaultValue = false)]
public string Particulars { get; set; }

[DataMember(Name = "Code", EmitDefaultValue = false)]
public string Code { get; set; }

[DataMember(Name = "Reference", EmitDefaultValue = false)]
public string Reference { get; set; }

[DataMember(Name = "Details", EmitDefaultValue = false)]
public string Details { get; set; }

[DataMember(Name = "Narrative", EmitDefaultValue = false)]
public string Narrative { get; set; }

[DataMember(Name = "Amount", EmitDefaultValue = false)]
public decimal? Amount { get; set; }
}
}
2 changes: 1 addition & 1 deletion Xero.Api/Core/Model/Contact.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public class Contact : HasUpdatedDate, IHasId, IHasAttachment
public BrandingTheme BrandingTheme { get; set; }

[DataMember(EmitDefaultValue = false)]
public BatchPayments BatchPayments { get; set; }
public BatchPaymentContactDefaults BatchPayments { get; set; }

[DataMember(EmitDefaultValue = false)]
public Balances Balances { get; set; }
Expand Down
13 changes: 13 additions & 0 deletions Xero.Api/Core/Model/Status/BatchPaymentStatus.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Runtime.Serialization;

namespace Xero.Api.Core.Model.Status
{
[DataContract(Namespace = "")]
public enum BatchPaymentStatus
{
[EnumMember(Value = "AUTHORISED")]
Authorised,
[EnumMember(Value = "DELETED")]
Deleted
}
}
13 changes: 13 additions & 0 deletions Xero.Api/Core/Model/Types/BatchPaymentType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Runtime.Serialization;

namespace Xero.Api.Core.Model.Types
{
[DataContract(Namespace = "")]
public enum BatchPaymentType
{
[EnumMember(Value = "PAYBATCH")]
PayBatch,
[EnumMember(Value = "RECBATCH")]
RecBatch
}
}
11 changes: 11 additions & 0 deletions Xero.Api/Core/Request/BatchPaymentsRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Runtime.Serialization;
using Xero.Api.Common;
using Xero.Api.Core.Model;

namespace Xero.Api.Core.Request
{
[CollectionDataContract(Namespace = "", Name = "BatchPayments")]
public class BatchPaymentsRequest : XeroRequest<BatchPayment>
{
}
}
16 changes: 16 additions & 0 deletions Xero.Api/Core/Response/BatchPaymentsResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System.Collections.Generic;
using Xero.Api.Common;
using Xero.Api.Core.Model;

namespace Xero.Api.Core.Response
{
public class BatchPaymentsResponse : XeroResponse<BatchPayment>
{
public List<BatchPayment> BatchPayments { get; set; }

public override IList<BatchPayment> Values
{
get { return BatchPayments; }
}
}
}
2 changes: 2 additions & 0 deletions Xero.Api/Core/XeroCoreApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public XeroCoreApi(string baseUri, IAuthenticator auth, IConsumer consumer, IUse
public AttachmentsEndpoint Attachments { get; private set; }
public IBankTransactionsEndpoint BankTransactions { get; private set; }
public IBankTransfersEndpoint BankTransfers { get; private set; }
public IBatchPaymentsEndpoint BatchPayments { get; private set; }
public IBrandingThemesEndpoint BrandingThemes { get; private set; }
public IContactsEndpoint Contacts { get; private set; }
public IContactGroupsEndpoint ContactGroups { get; private set;}
Expand Down Expand Up @@ -81,6 +82,7 @@ private void Connect()
Attachments = new AttachmentsEndpoint(Client);
BankTransactions = new BankTransactionsEndpoint(Client);
BankTransfers = new BankTransfersEndpoint(Client);
BatchPayments = new BatchPaymentsEndpoint(Client);
BrandingThemes = new BrandingThemesEndpoint(Client);
Contacts = new ContactsEndpoint(Client);
ContactGroups = new ContactGroupsEndpoint(Client);
Expand Down
2 changes: 2 additions & 0 deletions Xero.Api/Serialization/DefaultMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ private void BuildCore()
{
JsConfig<AccountStatus>.DeSerializeFn = EnumDeserializer<AccountStatus>;
JsConfig<BankTransactionStatus>.DeSerializeFn = EnumDeserializer<BankTransactionStatus>;
JsConfig<BatchPaymentStatus?>.DeSerializeFn = EnumDeserializerNullable<BatchPaymentStatus>;
JsConfig<ContactStatus>.DeSerializeFn = EnumDeserializer<ContactStatus>;
JsConfig<EmployeeStatus>.DeSerializeFn = EnumDeserializer<EmployeeStatus>;
JsConfig<ExpenseClaimStatus>.DeSerializeFn = EnumDeserializer<ExpenseClaimStatus>;
Expand All @@ -83,6 +84,7 @@ private void BuildCore()
JsConfig<AccountType>.DeSerializeFn = EnumDeserializer<AccountType>;
JsConfig<AddressType>.DeSerializeFn = EnumDeserializer<AddressType>;
JsConfig<BankTransactionType>.DeSerializeFn = EnumDeserializer<BankTransactionType>;
JsConfig<BatchPaymentType?>.DeSerializeFn = EnumDeserializerNullable<BatchPaymentType>;
JsConfig<CreditNoteType>.DeSerializeFn = EnumDeserializer<CreditNoteType>;
JsConfig<InvoiceType>.DeSerializeFn = EnumDeserializer<InvoiceType>;
JsConfig<LineAmountType>.DeSerializeFn = EnumDeserializer<LineAmountType>;
Expand Down
9 changes: 8 additions & 1 deletion Xero.Api/Xero.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,14 @@
<Compile Include="Core\Endpoints\Base\FourDecimalPlacesEndpoint.cs" />
<Compile Include="Core\Endpoints\Base\IXeroCreateEndpoint.cs" />
<Compile Include="Core\Endpoints\Base\IXeroUpdateEndpoint.cs" />
<Compile Include="Core\Endpoints\BatchPaymentsEndpoint.cs" />
<Compile Include="Core\Endpoints\ContactGroupEndpoint.cs" />
<Compile Include="Core\Endpoints\FoldersEndpoint.cs" />
<Compile Include="Core\Endpoints\HistoryAndNotesEndpoint.cs" />
<Compile Include="Core\Endpoints\InboxEndpoint.cs" />
<Compile Include="Core\Endpoints\LinkedTransactionsEndpoint.cs" />
<Compile Include="Core\Model\BatchPayment.cs" />
<Compile Include="Core\Model\BatchPaymentPayment.cs" />
<Compile Include="Core\Model\ContactCisSetting.cs" />
<Compile Include="Core\Model\EnumExtensions.cs" />
<Compile Include="Core\Model\HistoryRecord.cs" />
Expand All @@ -71,10 +74,12 @@
<Compile Include="Core\Model\LinkedTransaction.cs" />
<Compile Include="Core\Model\OrganisationCisSetting.cs" />
<Compile Include="Core\Model\PurchaseOrder.cs" />
<Compile Include="Core\Model\Status\BatchPaymentStatus.cs" />
<Compile Include="Core\Model\Status\LinkedTransactionStatus.cs" />
<Compile Include="Core\Model\Status\PurchaseOrderStatus.cs" />
<Compile Include="Core\Model\Status\TrackingOptionStatus.cs" />
<Compile Include="Core\Model\Types\BankAccountType.cs" />
<Compile Include="Core\Model\Types\BatchPaymentType.cs" />
<Compile Include="Core\Model\Types\HistoryAndNotesEndpointCreateType.cs" />
<Compile Include="Core\Model\Types\HistoryAndNotesEndpointRetrieveType.cs" />
<Compile Include="Core\Model\Types\LinkedTransactionType.cs" />
Expand All @@ -83,6 +88,7 @@
<Compile Include="Core\Model\Types\OrganisationClass.cs" />
<Compile Include="Core\Model\Types\OrganisationEdition.cs" />
<Compile Include="Core\Model\Types\SourceType.cs" />
<Compile Include="Core\Request\BatchPaymentsRequest.cs" />
<Compile Include="Core\Request\CurrenciesRequest.cs" />
<Compile Include="Core\Request\HistoryRecordsRequest.cs" />
<Compile Include="Core\Request\LinkedTransactionsRequest.cs" />
Expand All @@ -103,6 +109,7 @@
<Compile Include="Core\Model\Types\OverpaymentType.cs" />
<Compile Include="Common\CoreData.cs" />
<Compile Include="Core\Model\Status\ValidationStatus.cs" />
<Compile Include="Core\Response\BatchPaymentsResponse.cs" />
<Compile Include="Core\Response\ContactCisSettingsResponse.cs" />
<Compile Include="Core\Response\HistoryRecordsResponse.cs" />
<Compile Include="Core\Response\LinkedTransactionsResponse.cs" />
Expand Down Expand Up @@ -296,7 +303,7 @@
<Compile Include="Core\Model\Types\AddressType.cs" />
<Compile Include="Core\Model\Balance.cs" />
<Compile Include="Core\Model\Balances.cs" />
<Compile Include="Core\Model\BatchPayments.cs" />
<Compile Include="Core\Model\BatchPaymentContactDefaults.cs" />
<Compile Include="Core\Model\BrandingTheme.cs" />
<Compile Include="Core\Model\User.cs" />
<Compile Include="Core\Model\ContactGroup.cs" />
Expand Down

0 comments on commit c7da77c

Please sign in to comment.