Skip to content

Instantly share code, notes, and snippets.

View ronanq's full-sized avatar

Ronan Quirke ronanq

  • Xero
  • Wellington
View GitHub Profile
@ronanq
ronanq / _config.php
Last active September 8, 2015 09:24
XeroOAuth-PHP config example with site url override
<?php
// standard config settings go before this, just including the bit to change
$signatures = array(
'consumer_key' => 'YOURCONSUMERKEY',
'shared_secret' => 'YOURCONSUMERSECRET',
# BIT TO CHANGE
// Override default settings with SHA2 URLs
'xero_url' => 'https://sha2-api.xero.com/',
'site' => 'https://sha2-api.xero.com',
'authorize_url' => 'https://sha2-api.xero.com/oauth/Authorize',
<%@page import="net.oauth.http.HttpClient"%><%@ page language="java" import="client.PartnerHttpClientPool,java.io.*, java.net.*,java.util.*,java.security.*,net.oauth.OAuth, net.oauth.OAuthAccessor, net.oauth.OAuthConsumer, net.oauth.OAuthMessage, net.oauth.OAuthServiceProvider, net.oauth.signature.RSA_SHA1, net.oauth.client.OAuthClient,java.util.*,java.math.BigInteger,javax.xml.parsers.DocumentBuilder,javax.xml.parsers.DocumentBuilderFactory,javax.xml.xpath.XPath,javax.xml.xpath.XPathConstants,javax.xml.xpath.XPathExpression,javax.xml.xpath.XPathFactory,org.w3c.dom.Document,org.w3c.dom.NodeList,org.xml.sax.InputSource,net.oauth.client.httpclient4.HttpClient4" %>
<%
OAuthServiceProvider xeroPartnerProvider =
new OAuthServiceProvider(
"https://api-partner.network.xero.com/oauth/RequestToken",
"https://api.xero.com/oauth/Authorize",
"https://api-partner.network.xero.com/oauth/AccessToken");
@ronanq
ronanq / gist:9356544
Created March 4, 2014 21:51
Xero Add-on partners with APIs
Sharesight
http://www.sharesight.co.nz/partners/developers/
Unleashed
https://api.unleashedsoftware.com/Help
Vend
https://developers.vendhq.com/documentation
@ronanq
ronanq / repository.cs
Created October 23, 2013 21:17
Invoice create and handle response
var newInvoice = repository.Create<Invoice>(invs).FirstOrDefault();
if (newInvoice != null)
{
if (newInvoice.ValidationStatus == ValidationStatus.ERROR)
{
for (int i = 0; i < newInvoice.ValidationErrors.Count; i++)
{
returnString = returnString + "\n" + newInvoice.ValidationErrors[i].Message;
}
<ServiceDefinition>
<WebRole>
<Startup>
<Task commandLine="Startup\AddCerts.cmd" executionContext="elevated" taskType="simple" />
</Startup>
</WebRole>
</ServiceDefinition>
@ronanq
ronanq / gist:5992757
Created July 14, 2013 00:51
Sample RSA-SHA1 signature base string
GET&https%3A%2F%2Fapi.xero.com%2Fapi.xro%2F2.0%2FContacts&oauth_consumer_key%3DCONSUMERKEY%26oauth_nonce%3Dfef295f8188b8686fc922a66ec4fed1a%26oauth_signature_method%3DRSA-SHA1%26oauth_timestamp%3D1373762753%26oauth_token%3DCONSUMERKEY%26oauth_version%3D1.0
@ronanq
ronanq / email_validation.txt
Last active December 17, 2015 13:29
Xero API email validation REGEX
^\s*((?>[a-zA-Z\d!#$%&'*+\-/=?^_{|}~]+\x20*|""((?=[\x01-\x7f])[^""\\]|\\[\x01-\x7f])*""\x20*)*(?<angle><))?((?!\.)(?>\.?[a-zA-Z\d!#$%&'*+\-/=?^_{|}~]+)+|""((?=[\x01-\x7f])[^""\\]|\\[\x01-\x7f])*"")@(((?!-)[a-zA-Z\d\-]+(?<!-)\.)+[a-zA-Z]{2,}|\[(((?(?<!\[)\.)(25[0-5]|2[0-4]\d|[01]?\d?\d)){4}|[a-zA-Z\d\-]*[a-zA-Z\d]:((?=[\x01-\x7f])[^\\\[\]]|\\[\x01-\x7f])+)\])(?(angle)>)\s*$
@ronanq
ronanq / Correct XML
Created January 27, 2013 19:46
PUT Request to Xero organisation 'Welli NZ Test' (Xero test)
<Invoices>
<Invoice>
<Type>ACCREC</Type><Contact><Name>APIACCOUNT</Name><FirstName>Pete</FirstName><LastName>Contact</LastName><EmailAddress>ronan.quirke+apitest1@gmail.com</EmailAddress><Addresses>
<Address>
<AddressType>POBOX</AddressType></Address><Address>
<AddressType>STREET</AddressType></Address>
</Addresses><Phones>
<Phone>
<PhoneType>FAX</PhoneType></Phone><Phone>
<PhoneType>DDI</PhoneType></Phone><Phone>
def http_put(client, url, body, extra_params = {})
http_request(client, :post, url, body, extra_params)
end