Skip to content

Instantly share code, notes, and snippets.

@georgehemmings
Created December 20, 2016 11:03
Show Gist options
  • Save georgehemmings/ff607ef425ecb2d5be6a0f9cee0e6882 to your computer and use it in GitHub Desktop.
Save georgehemmings/ff607ef425ecb2d5be6a0f9cee0e6882 to your computer and use it in GitHub Desktop.
ORCA API demo
using System;
using System.Collections.Generic;
using System.Linq;
using Orca.ServiceModel;
using Orca.ServiceModel.Types;
using ServiceStack;
using ServiceStack.Text;
namespace Demo
{
class Program
{
static void Main(string[] args)
{
JsConfig.DateHandler = DateHandler.ISO8601;
JsConfig.SkipDateTimeConversion = true;
var client = new JsonServiceClient("http://devteam-sandbox.orca/api")
{
AlwaysSendBasicAuthHeader = true,
UserName = "cRowTXfCpy0f7wBjNNzl",
Password = "IzCVmcoLY4uSqmTAymii"
};
var debt = client.Send(new GetDebt
{
Code = "INI0000002"
}).Debt;
var plc1 = client.Send(new CreateTransaction
{
DebtCode = debt.Code,
TransactionTypeCode = "PLC",
Amount = 1000,
TransactionDate = DateTime.Today
}).Transaction;
var plc2 = client.Send(new CreateTransaction
{
DebtCode = debt.Code,
TransactionTypeCode = "PLC",
Amount = 100,
TransactionDate = DateTime.Today
}).Transaction;
var debtor = debt.Debtors.First();
client.Send(new UpdateAllocationPlan
{
DebtCode = debt.Code,
DebtorId = debtor.Id,
Proportions = new List<AllocationPlanProportion>
{
new AllocationPlanProportion
{
TransactionId = plc1.Id,
Percentage = 25
},
new AllocationPlanProportion
{
TransactionId = plc2.Id,
Percentage = 75
}
}
});
client.Send(new CreateTransaction
{
DebtCode = debt.Code,
TransactionTypeCode = "CHQ",
Amount = 50,
TransactionDate = DateTime.Today
});
client.Send(new GetTransactions { DebtCode = debt.Code }).PrintDump();
client.Send(new CreateDebtorProposedAddress
{
DebtorId = debtor.Id,
Line1 = "5 Greengate",
Line2 = "",
Line3 = "",
Line4 = "",
Line5 = "",
Postcode = "HG3 1GY",
UseForCorrespondence = true
});
client.Send(new GetDebtorProposedAddresses
{
DebtorId = debtor.Id
}).PrintDump();
Console.ReadKey();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment