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

Commit 72a874b

Browse files
committed
Added the ability to get purchase orders as pdf
1 parent cfded64 commit 72a874b

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

CoreTests/Integration/Pdf/Get.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ public void can_get_credit_note_as_pdf()
2020
AssertOk(PdfEndpointType.CreditNotes, new CreditNotes.Create().Given_a_creditnote().Id);
2121
}
2222

23+
[Test]
24+
public void can_get_purchase_order_as_pdf()
25+
{
26+
AssertOk(PdfEndpointType.PurchaseOrders, new PurchaseOrders.Create().Given_a_purchase_order().Id);
27+
}
28+
2329
[Test]
2430
public void invoice_gives_404_when_not_found()
2531
{
@@ -32,6 +38,12 @@ public void credit_note_gives_404_when_not_found()
3238
Assert.Throws<NotFoundException>(() => Api.PdfFiles.Get(PdfEndpointType.CreditNotes, Guid.NewGuid()));
3339
}
3440

41+
[Test]
42+
public void purchase_order_gives_404_when_not_found()
43+
{
44+
Assert.Throws<NotFoundException>(() => Api.PdfFiles.Get(PdfEndpointType.PurchaseOrders, Guid.NewGuid()));
45+
}
46+
3547
private void AssertOk(PdfEndpointType type, Guid id)
3648
{
3749
var pdf = Api.PdfFiles.Get(type, id);

CoreTests/Integration/PurchaseOrders/Create.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,27 @@ private Guid ContactId
5858
return Api.Contacts.Find().First().Id;
5959
}
6060
}
61+
62+
public PurchaseOrder Given_a_purchase_order()
63+
{
64+
return Api.PurchaseOrders.Create(
65+
new PurchaseOrder
66+
{
67+
Status = PurchaseOrderStatus.Authorised,
68+
Date = DateTime.Today,
69+
Contact = new Contact { Id = ContactId },
70+
LineItems = new List<LineItem>()
71+
{
72+
new LineItem
73+
{
74+
Description = "An item I want to purchase",
75+
UnitAmount = 1,
76+
Quantity = 1,
77+
78+
}
79+
}
80+
}
81+
);
82+
}
6183
}
6284
}

Xero.Api/Core/Model/Types/PdfEndpointType.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
public enum PdfEndpointType
44
{
55
CreditNotes,
6-
Invoices
6+
Invoices,
7+
PurchaseOrders
78
}
89
}

0 commit comments

Comments
 (0)