Skip to content

Instantly share code, notes, and snippets.

View IntuitDeveloperRelations's full-sized avatar

Intuit Partner Platform IntuitDeveloperRelations

View GitHub Profile
@IntuitDeveloperRelations
IntuitDeveloperRelations / V2-QBD-Customer-Add.cs
Last active December 15, 2015 10:38
IPP .NET DevKit v2 - QBD - Add Customer with Name #DotNetDevKitV2 #Customer #QBD
// #DotNetDevKitV2 #Customer #QBD
//Simple routine to add QBD customer
//Documentation: http://goo.gl/XGNz4
var oauthValidator = new OAuthRequestValidator(accessToken, accessTokenSecret, consumerKey,consumerSecret);
var context = new ServiceContext(oauthValidator, realmId, IntuitServicesType.QBD);
var commonService = new DataServices(context);
var cust = new Intuit.Ipp.Data.Qbd.Customer()
{
@IntuitDeveloperRelations
IntuitDeveloperRelations / V2-QBD-Customer-FilterWithMinimumBalance.cs
Last active December 15, 2015 10:38
IPP .NET DevKit v2 - QBD - Retrieve Active QBD Customers with a minimum balance #DotNetDevKitV2 #Customer #QBD
// #DotNetDevKitV2 #Customer #QBD
//Retrieve Active QBD Customers with a minimum balance
//Documentation: http://goo.gl/jUdxR
var oauthValidator = new OAuthRequestValidator(accessToken, accessTokenSecret, consumerKey,consumerSecret);
var context = new ServiceContext(oauthValidator, realmId, IntuitServicesType.QBD);
var commonService = new DataServices(context);
var qbdCustomerQuery = new Intuit.Ipp.Data.Qbd.CustomerQuery
{
ActiveOnly = true,
@IntuitDeveloperRelations
IntuitDeveloperRelations / IPP-Reconnect-V2SDK-DevDefined.cs
Last active December 15, 2015 23:10
DevDefined / IPP .NET DevKit v2 - Platform - Call Reconnect API #DotNetDevKitV2 #Reconnect #IPP
//Documentation: http://docs.developer.intuit.com/0025_Intuit_Anywhere/0060_Reference/3002_Reconnect_API
public string CallReconnectAPI(DataServices dataServices)
{
HttpWebRequest httpWebRequest = WebRequest.Create("https://appcenter.intuit.com/api/v1/Connection/Reconnect") as HttpWebRequest;
httpWebRequest.Method = "GET";
httpWebRequest.Headers.Add("Authorization", GetDevDefinedOAuthHeader(dataServices,httpWebRequest, ""));
UTF8Encoding encoding = new UTF8Encoding();
HttpWebResponse httpWebResponse = httpWebRequest.GetResponse() as HttpWebResponse;
using (Stream data = httpWebResponse.GetResponseStream())
@IntuitDeveloperRelations
IntuitDeveloperRelations / V2-QBO-TimeActivity-Add.cs
Last active December 16, 2015 17:08
IPP .NET DevKit v2 - QBO - TimeActivity - Add
//Add QBO TimeActivity
//Documentation: http://goo.gl/DjJyb
List<Employee> employees = commonService.FindAll(new Employee(), 1, 1).ToList<Employee>();
List<Customer> customers = commonService.FindAll(new Customer(), 1, 1).ToList<Customer>();
TimeActivity timeActivity = new TimeActivity();
timeActivity.BillableStatus = BillableStatusEnum.Billable;
timeActivity.BillableStatusSpecified = true;
timeActivity.Hours = "8";
@IntuitDeveloperRelations
IntuitDeveloperRelations / V2-QBO-Customer-Filter-V2SDK-DevDefined.cs
Last active December 16, 2015 22:08
DevDefined / IPP .NET DevKit v2 - QBO - Customer Filter #DotNetDevKitV2 #QBO
IEnumerable<Customer> customers = GetQboCustomers(dataService, 1, 100, false);
public List<Intuit.Ipp.Data.Qbo.Customer> GetQboCustomers(DataServices dataServices, int startPage, int resultsPerPage, bool includeJobs)
{
StringBuilder requestXML = new StringBuilder();
StringBuilder responseXML = new StringBuilder();
var requestBody = String.Format("PageNum={0}&ResultsPerPage={1}", startPage, resultsPerPage);
if (!includeJobs) { requestBody += "&Filter=IncludeJobs :EQUALS: false"; }
@IntuitDeveloperRelations
IntuitDeveloperRelations / V2-QBD-PurchaseOrder-Filter-V2SDK-DevDefined.cs
Last active December 19, 2015 05:39
DevDefined / IPP .NET DevKit v2 - QBD - PurchaseOrder Query #DotNetDevKitV2 #QBD
public string GetQbdPurchaseOrders(DataServices dataServices, int startPage, int chunkSize)
{
HttpWebRequest httpWebRequest = WebRequest.Create(dataServices.ServiceContext.BaseUrl + "purchaseorder/v2/" + dataServices.ServiceContext.RealmId) as HttpWebRequest;
httpWebRequest.Method = "POST";
httpWebRequest.ContentType = "text/xml";
string requestBody = String.Format("<PurchaseOrderQuery xmlns=\"http://www.intuit.com/sb/cdm/v2\"><StartPage>{0}</StartPage><ChunkSize>{1}</ChunkSize></PurchaseOrderQuery>", startPage, chunkSize);
httpWebRequest.Headers.Add("Authorization", GetDevDefinedOAuthHeader(dataServices, httpWebRequest, requestBody.ToString()));
UTF8Encoding encoding = new UTF8Encoding();
byte[] content = encoding.GetBytes(requestBody.ToString());
using (var stream = httpWebRequest.GetRequestStream())
@IntuitDeveloperRelations
IntuitDeveloperRelations / V2-QBO-Item-Filter-V2SDK-DevDefined.cs
Last active December 19, 2015 21:59
DevDefined / IPP .NET DevKit v2 - QBO - Get Items with DateTimeFilter #DotNetDevKitV2 #Item #Filter
//List<Item> items = GetQboItemsWithDateTimeFiler(commonService, 1, 100, new DateTime(2013, 6, 30, 11, 0, 0));
public List<Intuit.Ipp.Data.Qbo.Item> GetQboItemsWithDateTimeFiler(DataServices dataServices, int startPage, int resultsPerPage, DateTime filterCreateTimeAfter)
{
var filter = "CreateTime :AFTER: " + filterCreateTimeAfter.ToString("yyyy-MM-dd\"T\"HH:mm:sszzz");
var httpWebRequest = WebRequest.Create(dataServices.ServiceContext.BaseUrl + "items/v2/" + dataServices.ServiceContext.RealmId) as HttpWebRequest;
if (httpWebRequest != null)
{
@IntuitDeveloperRelations
IntuitDeveloperRelations / CAD-updateInsitutionLoginWithRefreshAndEmptyCredentials.cs
Last active December 20, 2015 15:49
IPP CAD .NET SDK / UpdateInstitutionLogin passing empty credentials for refresh
int institutionLoginId = 3333; //Returned from DiscoverAndAddAccounts call
InstitutionLogin institutionLogin = new InstitutionLogin(); //Instantiate the object but do not specify credentials
Challenges challenges = new Challenges();
AggregationCategorizationService aggCategorizationService = Services.CADService.GetService(Cache, HttpContext.Current.User.Identity.Name);
aggCategorizationService.UpdateInstitutionLogin(institutionLoginId, institutionLogin, true, out challenges);
@IntuitDeveloperRelations
IntuitDeveloperRelations / V2-QBO-Invoice-Add.cs
Last active December 22, 2015 07:39
IPP .NET DevKit v2 - QBO - Invoice Add
Intuit.Ipp.Data.Qbo.Invoice invoice = new Intuit.Ipp.Data.Qbo.Invoice();
Intuit.Ipp.Data.Qbo.InvoiceHeader invoiceHeader = new Intuit.Ipp.Data.Qbo.InvoiceHeader();
invoiceHeader.DocNumber = "AUTO_GENERATE";
invoiceHeader.TxnDate = new DateTime(2013, 09, 04);
invoiceHeader.TxnDateSpecified = true;
invoiceHeader.CustomerId = new Intuit.Ipp.Data.Qbo.IdType() { idDomain = Intuit.Ipp.Data.Qbo.idDomainEnum.QBO, Value = "12" };
invoiceHeader.SubTotalAmt = 100;
invoiceHeader.SubTotalAmtSpecified = true;
invoiceHeader.TotalAmt = 100;
@IntuitDeveloperRelations
IntuitDeveloperRelations / V3-QBO-Invoice-Create-SalesLineItem.cs
Last active September 13, 2021 21:44
IPP .NET SDK v3 - QBO - Create Invoice with Sales Line Item Details #IppDotNetSdkV3 #Invoice #QBO
static void CreateQBOInvoice(DataService dataService, ServiceContext context)
{
//Find Customer
QueryService<Customer> customerQueryService = new QueryService<Customer>(context);
Customer customer = customerQueryService.ExecuteIdsQuery("Select * From Customer StartPosition 1 MaxResults 1").FirstOrDefault<Customer>();
//Find Tax Code for Invoice - Searching for a tax code named 'StateSalesTax' in this example
QueryService<TaxCode> stateTaxCodeQueryService = new QueryService<TaxCode>(context);
TaxCode stateTaxCode = stateTaxCodeQueryService.ExecuteIdsQuery("Select * From TaxCode Where Name='StateSalesTax' StartPosition 1 MaxResults 1").FirstOrDefault<TaxCode>();