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

Commit

Permalink
Added the ability to get purchase orders as pdf
Browse files Browse the repository at this point in the history
  • Loading branch information
MJMortimer committed Apr 4, 2016
1 parent cfded64 commit 72a874b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
12 changes: 12 additions & 0 deletions CoreTests/Integration/Pdf/Get.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ public void can_get_credit_note_as_pdf()
AssertOk(PdfEndpointType.CreditNotes, new CreditNotes.Create().Given_a_creditnote().Id);
}

[Test]
public void can_get_purchase_order_as_pdf()
{
AssertOk(PdfEndpointType.PurchaseOrders, new PurchaseOrders.Create().Given_a_purchase_order().Id);
}

[Test]
public void invoice_gives_404_when_not_found()
{
Expand All @@ -32,6 +38,12 @@ public void credit_note_gives_404_when_not_found()
Assert.Throws<NotFoundException>(() => Api.PdfFiles.Get(PdfEndpointType.CreditNotes, Guid.NewGuid()));
}

[Test]
public void purchase_order_gives_404_when_not_found()
{
Assert.Throws<NotFoundException>(() => Api.PdfFiles.Get(PdfEndpointType.PurchaseOrders, Guid.NewGuid()));
}

private void AssertOk(PdfEndpointType type, Guid id)
{
var pdf = Api.PdfFiles.Get(type, id);
Expand Down
22 changes: 22 additions & 0 deletions CoreTests/Integration/PurchaseOrders/Create.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,27 @@ private Guid ContactId
return Api.Contacts.Find().First().Id;
}
}

public PurchaseOrder Given_a_purchase_order()
{
return Api.PurchaseOrders.Create(
new PurchaseOrder
{
Status = PurchaseOrderStatus.Authorised,
Date = DateTime.Today,
Contact = new Contact { Id = ContactId },
LineItems = new List<LineItem>()
{
new LineItem
{
Description = "An item I want to purchase",
UnitAmount = 1,
Quantity = 1,

}
}
}
);
}
}
}
3 changes: 2 additions & 1 deletion Xero.Api/Core/Model/Types/PdfEndpointType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
public enum PdfEndpointType
{
CreditNotes,
Invoices
Invoices,
PurchaseOrders
}
}

0 comments on commit 72a874b

Please sign in to comment.