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

Commit c7da77c

Browse files
authored
Merge pull request #372 from MJMortimer/f-batchpayments
Add BatchPayments functionality
2 parents e73046f + 5cbea0b commit c7da77c

13 files changed

+181
-4
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using Xero.Api.Core.Endpoints.Base;
2+
using Xero.Api.Core.Model;
3+
using Xero.Api.Core.Request;
4+
using Xero.Api.Core.Response;
5+
using Xero.Api.Infrastructure.Http;
6+
7+
namespace Xero.Api.Core.Endpoints
8+
{
9+
public interface IBatchPaymentsEndpoint
10+
: IXeroCreateEndpoint<BatchPaymentsEndpoint, BatchPayment, BatchPaymentsRequest, BatchPaymentsResponse>
11+
{
12+
13+
}
14+
15+
public class BatchPaymentsEndpoint
16+
: XeroCreateEndpoint<BatchPaymentsEndpoint, BatchPayment, BatchPaymentsRequest, BatchPaymentsResponse>, IBatchPaymentsEndpoint
17+
{
18+
public BatchPaymentsEndpoint(XeroHttpClient client) :
19+
base(client, "/api.xro/2.0/BatchPayments")
20+
{
21+
}
22+
}
23+
}

Xero.Api/Core/IXeroCoreApi.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public interface IXeroCoreApi
1313
AttachmentsEndpoint Attachments { get; }
1414
IBankTransactionsEndpoint BankTransactions { get; }
1515
IBankTransfersEndpoint BankTransfers { get; }
16+
IBatchPaymentsEndpoint BatchPayments { get; }
1617
IBrandingThemesEndpoint BrandingThemes { get; }
1718
IContactsEndpoint Contacts { get; }
1819
IContactGroupsEndpoint ContactGroups { get; }

Xero.Api/Core/Model/BatchPayment.cs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Runtime.Serialization;
4+
using Xero.Api.Common;
5+
using Xero.Api.Core.Model.Status;
6+
using Xero.Api.Core.Model.Types;
7+
8+
namespace Xero.Api.Core.Model
9+
{
10+
[DataContract(Namespace = "")]
11+
public class BatchPayment : HasUpdatedDate, IHasId
12+
{
13+
[DataMember(Name = "BatchPaymentID", EmitDefaultValue = false)]
14+
public Guid Id { get; set; }
15+
16+
[DataMember(Name = "Type", EmitDefaultValue = false)]
17+
public BatchPaymentType? Type { get; set; }
18+
19+
[DataMember(Name = "Status", EmitDefaultValue = false)]
20+
public BatchPaymentStatus? Status { get; set; }
21+
22+
[DataMember(Name = "Account")]
23+
public Account Account { get; set; }
24+
25+
[DataMember(Name = "Particulars", EmitDefaultValue = false)]
26+
public string Particulars { get; set; }
27+
28+
[DataMember(Name = "Code", EmitDefaultValue = false)]
29+
public string Code { get; set; }
30+
31+
[DataMember(Name = "Reference", EmitDefaultValue = false)]
32+
public string Reference { get; set; }
33+
34+
[DataMember(Name = "Details", EmitDefaultValue = false)]
35+
public string Details { get; set; }
36+
37+
[DataMember(Name = "Narrative", EmitDefaultValue = false)]
38+
public string Narrative { get; set; }
39+
40+
[DataMember(Name = "Date", EmitDefaultValue = false)]
41+
public DateTime? Date { get; set; }
42+
43+
[DataMember(Name = "Payments")]
44+
public List<BatchPaymentPayment> Payments { get; set; }
45+
46+
[DataMember(Name = "TotalAmount", EmitDefaultValue = false)]
47+
public decimal? Total { get; set; }
48+
49+
[DataMember(Name = "IsReconciled", EmitDefaultValue = false)]
50+
public bool? IsReconciled { get; set; }
51+
}
52+
}

Xero.Api/Core/Model/BatchPayments.cs renamed to Xero.Api/Core/Model/BatchPaymentContactDefaults.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
namespace Xero.Api.Core.Model
55
{
6-
[DataContract(Namespace = "")]
7-
public class BatchPayments : CoreData
6+
[DataContract(Namespace = "", Name = "BatchPayments")]
7+
public class BatchPaymentContactDefaults : CoreData
88
{
99
[DataMember(EmitDefaultValue = false)]
1010
public string BankAccountNumber { get; set; }
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using System;
2+
using System.Runtime.Serialization;
3+
using Xero.Api.Common;
4+
5+
namespace Xero.Api.Core.Model
6+
{
7+
[DataContract(Namespace = "", Name = "Payment")]
8+
public class BatchPaymentPayment : CoreData
9+
{
10+
[DataMember(Name = "Invoice")]
11+
public Invoice Invoice { get; set; }
12+
13+
[DataMember(Name = "PaymentID", EmitDefaultValue = false)]
14+
public Guid? PaymentId { get; set; }
15+
16+
[DataMember(Name = "BankAccountNumber", EmitDefaultValue = false)]
17+
public string BankAccountNumber { get; set; }
18+
19+
[DataMember(Name = "Particulars", EmitDefaultValue = false)]
20+
public string Particulars { get; set; }
21+
22+
[DataMember(Name = "Code", EmitDefaultValue = false)]
23+
public string Code { get; set; }
24+
25+
[DataMember(Name = "Reference", EmitDefaultValue = false)]
26+
public string Reference { get; set; }
27+
28+
[DataMember(Name = "Details", EmitDefaultValue = false)]
29+
public string Details { get; set; }
30+
31+
[DataMember(Name = "Narrative", EmitDefaultValue = false)]
32+
public string Narrative { get; set; }
33+
34+
[DataMember(Name = "Amount", EmitDefaultValue = false)]
35+
public decimal? Amount { get; set; }
36+
}
37+
}

Xero.Api/Core/Model/Contact.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public class Contact : HasUpdatedDate, IHasId, IHasAttachment
8282
public BrandingTheme BrandingTheme { get; set; }
8383

8484
[DataMember(EmitDefaultValue = false)]
85-
public BatchPayments BatchPayments { get; set; }
85+
public BatchPaymentContactDefaults BatchPayments { get; set; }
8686

8787
[DataMember(EmitDefaultValue = false)]
8888
public Balances Balances { get; set; }
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System.Runtime.Serialization;
2+
3+
namespace Xero.Api.Core.Model.Status
4+
{
5+
[DataContract(Namespace = "")]
6+
public enum BatchPaymentStatus
7+
{
8+
[EnumMember(Value = "AUTHORISED")]
9+
Authorised,
10+
[EnumMember(Value = "DELETED")]
11+
Deleted
12+
}
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System.Runtime.Serialization;
2+
3+
namespace Xero.Api.Core.Model.Types
4+
{
5+
[DataContract(Namespace = "")]
6+
public enum BatchPaymentType
7+
{
8+
[EnumMember(Value = "PAYBATCH")]
9+
PayBatch,
10+
[EnumMember(Value = "RECBATCH")]
11+
RecBatch
12+
}
13+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System.Runtime.Serialization;
2+
using Xero.Api.Common;
3+
using Xero.Api.Core.Model;
4+
5+
namespace Xero.Api.Core.Request
6+
{
7+
[CollectionDataContract(Namespace = "", Name = "BatchPayments")]
8+
public class BatchPaymentsRequest : XeroRequest<BatchPayment>
9+
{
10+
}
11+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System.Collections.Generic;
2+
using Xero.Api.Common;
3+
using Xero.Api.Core.Model;
4+
5+
namespace Xero.Api.Core.Response
6+
{
7+
public class BatchPaymentsResponse : XeroResponse<BatchPayment>
8+
{
9+
public List<BatchPayment> BatchPayments { get; set; }
10+
11+
public override IList<BatchPayment> Values
12+
{
13+
get { return BatchPayments; }
14+
}
15+
}
16+
}

Xero.Api/Core/XeroCoreApi.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public XeroCoreApi(string baseUri, IAuthenticator auth, IConsumer consumer, IUse
4040
public AttachmentsEndpoint Attachments { get; private set; }
4141
public IBankTransactionsEndpoint BankTransactions { get; private set; }
4242
public IBankTransfersEndpoint BankTransfers { get; private set; }
43+
public IBatchPaymentsEndpoint BatchPayments { get; private set; }
4344
public IBrandingThemesEndpoint BrandingThemes { get; private set; }
4445
public IContactsEndpoint Contacts { get; private set; }
4546
public IContactGroupsEndpoint ContactGroups { get; private set;}
@@ -81,6 +82,7 @@ private void Connect()
8182
Attachments = new AttachmentsEndpoint(Client);
8283
BankTransactions = new BankTransactionsEndpoint(Client);
8384
BankTransfers = new BankTransfersEndpoint(Client);
85+
BatchPayments = new BatchPaymentsEndpoint(Client);
8486
BrandingThemes = new BrandingThemesEndpoint(Client);
8587
Contacts = new ContactsEndpoint(Client);
8688
ContactGroups = new ContactGroupsEndpoint(Client);

Xero.Api/Serialization/DefaultMapper.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ private void BuildCore()
6666
{
6767
JsConfig<AccountStatus>.DeSerializeFn = EnumDeserializer<AccountStatus>;
6868
JsConfig<BankTransactionStatus>.DeSerializeFn = EnumDeserializer<BankTransactionStatus>;
69+
JsConfig<BatchPaymentStatus?>.DeSerializeFn = EnumDeserializerNullable<BatchPaymentStatus>;
6970
JsConfig<ContactStatus>.DeSerializeFn = EnumDeserializer<ContactStatus>;
7071
JsConfig<EmployeeStatus>.DeSerializeFn = EnumDeserializer<EmployeeStatus>;
7172
JsConfig<ExpenseClaimStatus>.DeSerializeFn = EnumDeserializer<ExpenseClaimStatus>;
@@ -83,6 +84,7 @@ private void BuildCore()
8384
JsConfig<AccountType>.DeSerializeFn = EnumDeserializer<AccountType>;
8485
JsConfig<AddressType>.DeSerializeFn = EnumDeserializer<AddressType>;
8586
JsConfig<BankTransactionType>.DeSerializeFn = EnumDeserializer<BankTransactionType>;
87+
JsConfig<BatchPaymentType?>.DeSerializeFn = EnumDeserializerNullable<BatchPaymentType>;
8688
JsConfig<CreditNoteType>.DeSerializeFn = EnumDeserializer<CreditNoteType>;
8789
JsConfig<InvoiceType>.DeSerializeFn = EnumDeserializer<InvoiceType>;
8890
JsConfig<LineAmountType>.DeSerializeFn = EnumDeserializer<LineAmountType>;

Xero.Api/Xero.Api.csproj

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,14 @@
5555
<Compile Include="Core\Endpoints\Base\FourDecimalPlacesEndpoint.cs" />
5656
<Compile Include="Core\Endpoints\Base\IXeroCreateEndpoint.cs" />
5757
<Compile Include="Core\Endpoints\Base\IXeroUpdateEndpoint.cs" />
58+
<Compile Include="Core\Endpoints\BatchPaymentsEndpoint.cs" />
5859
<Compile Include="Core\Endpoints\ContactGroupEndpoint.cs" />
5960
<Compile Include="Core\Endpoints\FoldersEndpoint.cs" />
6061
<Compile Include="Core\Endpoints\HistoryAndNotesEndpoint.cs" />
6162
<Compile Include="Core\Endpoints\InboxEndpoint.cs" />
6263
<Compile Include="Core\Endpoints\LinkedTransactionsEndpoint.cs" />
64+
<Compile Include="Core\Model\BatchPayment.cs" />
65+
<Compile Include="Core\Model\BatchPaymentPayment.cs" />
6366
<Compile Include="Core\Model\ContactCisSetting.cs" />
6467
<Compile Include="Core\Model\EnumExtensions.cs" />
6568
<Compile Include="Core\Model\HistoryRecord.cs" />
@@ -71,10 +74,12 @@
7174
<Compile Include="Core\Model\LinkedTransaction.cs" />
7275
<Compile Include="Core\Model\OrganisationCisSetting.cs" />
7376
<Compile Include="Core\Model\PurchaseOrder.cs" />
77+
<Compile Include="Core\Model\Status\BatchPaymentStatus.cs" />
7478
<Compile Include="Core\Model\Status\LinkedTransactionStatus.cs" />
7579
<Compile Include="Core\Model\Status\PurchaseOrderStatus.cs" />
7680
<Compile Include="Core\Model\Status\TrackingOptionStatus.cs" />
7781
<Compile Include="Core\Model\Types\BankAccountType.cs" />
82+
<Compile Include="Core\Model\Types\BatchPaymentType.cs" />
7883
<Compile Include="Core\Model\Types\HistoryAndNotesEndpointCreateType.cs" />
7984
<Compile Include="Core\Model\Types\HistoryAndNotesEndpointRetrieveType.cs" />
8085
<Compile Include="Core\Model\Types\LinkedTransactionType.cs" />
@@ -83,6 +88,7 @@
8388
<Compile Include="Core\Model\Types\OrganisationClass.cs" />
8489
<Compile Include="Core\Model\Types\OrganisationEdition.cs" />
8590
<Compile Include="Core\Model\Types\SourceType.cs" />
91+
<Compile Include="Core\Request\BatchPaymentsRequest.cs" />
8692
<Compile Include="Core\Request\CurrenciesRequest.cs" />
8793
<Compile Include="Core\Request\HistoryRecordsRequest.cs" />
8894
<Compile Include="Core\Request\LinkedTransactionsRequest.cs" />
@@ -103,6 +109,7 @@
103109
<Compile Include="Core\Model\Types\OverpaymentType.cs" />
104110
<Compile Include="Common\CoreData.cs" />
105111
<Compile Include="Core\Model\Status\ValidationStatus.cs" />
112+
<Compile Include="Core\Response\BatchPaymentsResponse.cs" />
106113
<Compile Include="Core\Response\ContactCisSettingsResponse.cs" />
107114
<Compile Include="Core\Response\HistoryRecordsResponse.cs" />
108115
<Compile Include="Core\Response\LinkedTransactionsResponse.cs" />
@@ -296,7 +303,7 @@
296303
<Compile Include="Core\Model\Types\AddressType.cs" />
297304
<Compile Include="Core\Model\Balance.cs" />
298305
<Compile Include="Core\Model\Balances.cs" />
299-
<Compile Include="Core\Model\BatchPayments.cs" />
306+
<Compile Include="Core\Model\BatchPaymentContactDefaults.cs" />
300307
<Compile Include="Core\Model\BrandingTheme.cs" />
301308
<Compile Include="Core\Model\User.cs" />
302309
<Compile Include="Core\Model\ContactGroup.cs" />

0 commit comments

Comments
 (0)