141 lines
7.5 KiB
C#
141 lines
7.5 KiB
C#
using Sarand.Net.Standard.Accounts.QuickBooks.App;
|
|
using Sarand.Net.Standard.Accounts.QuickBooks.Base;
|
|
using Sarand.Net.Standard.Base.Core;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
namespace Sarand.Net.Standard.Accounts.QuickBooks.Online
|
|
{
|
|
//=======================================================================
|
|
internal class SaQuickBooksApiConsole_Online : SaQuickBooksApiConsole
|
|
{
|
|
//-------------------------------------------------------------------
|
|
// D e f i n i t i o n s
|
|
//-------------------------------------------------------------------
|
|
|
|
#pragma warning disable 0414
|
|
|
|
// Keys.
|
|
// Sarand Sandbox company:
|
|
// CompanyId 193514292338962
|
|
// AppToken lvprdXEkhkqdCXgTfYJxhwFj1CdB3fXIeTs5eGx8TE8U7qGy
|
|
// AppTokenSecret U8IgODOQa4Rl9KEMbQhgimoQi5nbgLi4XlQU4xiB
|
|
// BPE Live Company
|
|
// CompanyId 193514324299222
|
|
// AppToken qyprdb7VvoOivRV7mARrb5I0VVT1caG0f1c0AVVgbhxt36bv
|
|
// AppTokenSecret boGLa6B5RwayoYs1KlDEGk64Rjl0UUsF6By7rvBR
|
|
private static String kpcAppToken_Dev = "0c7f73fdb65efb4033b8a12b61fb01aa3ce9";
|
|
private static String kpcConsumerKey_Dev = "lvprd9HvNstK5yTszldscZ2PBgNGMu";
|
|
private static String kpcConsumerSecret_Dev = "F6IQwnEhJqpoOdTmfXBgt1iq6SDWJ40clxl1xvQR";
|
|
private static String kpcAppToken_Prod = "c0d15b4fbcad2b4cfcb96f9bcdbd2bf7b03d";
|
|
private static String kpcConsumerKey_Prod = "lvprdwLCQdAhuiLtueFpZ7LVG4R6Ir";
|
|
private static String kpcConsumerSecret_Prod = "9j1RBTaHbpTZEA0yUlDINYoAhX8Mt6PfOdAl2YIz";
|
|
|
|
// Online API.
|
|
// Intuit Developer: https://developer.intuit.com/
|
|
private static String kpcServer_QBD_Prod = "quickbooks.api.intuit.com"; // QuickBooks Desktop Rest Service - production.
|
|
private static String kpcServer_QBO_Prod = "quickbooks.api.intuit.com"; // QuickBooks Online Rest Service - production.
|
|
private static String kpcServer_QBO_Sand = "sandbox-quickbooks.api.intuit.com"; // QuickBooks Online Rest Service - sandbox.
|
|
private static String kpcServer_IPP_Prod = "appcenter.intuit.com"; // Platform Rest Service - production.
|
|
private static String kpcBaseUrl_QBD = "https://quickbooks.api.intuit.com/"; // QuickBooks Desktop Rest Service.
|
|
private static String kpcBaseUrl_QBO = "https://quickbooks.api.intuit.com/"; // QuickBooks Online Rest Service.
|
|
private static String kpcBaseUrl_IPP = "https://appcenter.intuit.com/api/"; // Platform Rest Service.
|
|
private static String kpcUrlAccounting_Production = "https://quickbooks.api.intuit.com/"; // Accounting API base URL to use with production keys.
|
|
private static String kpcUrlAccounting_Sandbox = "https://sandbox-quickbooks.api.intuit.com/"; // Accounting API—Sandbox base URL to use with development keys.
|
|
private static String kpcUrlPayments_Production = "https://api.intuit.com/"; // Payments API base URL to use with production keys.
|
|
private static String kpcUrlPayments_Sandbox = "https://sandbox.api.intuit.com/"; // Payments API—Sandbox base URL to use with development keys.
|
|
|
|
// Core constants.
|
|
private static String kpcSlash = "/"; // Slash character.
|
|
private static String kpcVersion = "v3"; // Intuit Services Version.
|
|
private static String kpcResource = "resource";
|
|
private static String kpcUrlVersionCompany = "v3/company/";
|
|
// Content types.
|
|
private static String kpcContentType_TextAny = "text/*";
|
|
private static String kpcContentType_TextHtml = "text/html";
|
|
private static String kpcContentType_TextXml = "text/xml";
|
|
private static String kpcContentType_TextPlain = "text/plain";
|
|
private static String kpcContentType_ApplicationText = "application/text";
|
|
private static String kpcContentType_ApplicationXml = "application/xml";
|
|
private static String kpcContentType_ApplicationJson = "application/json";
|
|
private static String kpcContentType_UrlFormEncoded = "application/x-www-form-urlencoded";
|
|
private static String kpcContentType_OctetStream = "application/octet-stream";
|
|
private static String kpcContentType_ApplicationPdf = "application/pdf";
|
|
// Parameter names.
|
|
private static String kpcParam_Id = "Id";
|
|
private static String kpcParam_SyncToken = "SyncToken";
|
|
private static String kpcParam_Domain = "domain";
|
|
private static String kpcParam_MetaData = "MetaData";
|
|
private static String kpcParam_Sparse = "sparse";
|
|
private static String kpcParam_Status = "status";
|
|
private static String kpcParam_IdDomainQuery = "?idDomain=";
|
|
private static String kpcAUTHORIZATIONSTRING_FORHEADER = "Authorization"; // Authorization String For Header.
|
|
private static String kpcREQUESTFILENAME_FORMAT = "{0}{1}Request-{2}.txt"; // Request File Name Format.
|
|
private static String kpcRESPONSEFILENAME_FORMAT = "{0}{1}Response-{2}.txt"; // Response File Name Format.
|
|
private static String kpcERRORRESPONSEFILENAME_FORMAT = "{0}{1}Error-Response-{2}.txt"; // Error Response File Name Format.
|
|
private static String kpcCONTENTENCODING = "Content-Encoding"; // The Compression format of the request data.
|
|
private static String kpcACCEPTENCODING = "Accept-Encoding"; // The Compression format of the response data.
|
|
private static String kpcUSERAGENT = "V3PHPSDK2.4.1"; // The Request source header value.
|
|
|
|
#pragma warning restore 0414
|
|
|
|
//-------------------------------------------------------------------
|
|
// Data members.
|
|
|
|
//-------------------------------------------------------------------
|
|
// Static initialisation.
|
|
static SaQuickBooksApiConsole_Online ()
|
|
{
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Construction.
|
|
internal SaQuickBooksApiConsole_Online (SaQuickBooksParams prmQbk) : base(prmQbk)
|
|
{
|
|
}
|
|
protected override void Dispose (bool disposing)
|
|
{
|
|
if (disposing)
|
|
{
|
|
}
|
|
base.Dispose(disposing);
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Properties.
|
|
|
|
//-------------------------------------------------------------------
|
|
// D a t a I t e m s
|
|
//-------------------------------------------------------------------
|
|
public override SaQuickBooksDataItem CreateDataItem (Qbk.EntityType entityType)
|
|
{
|
|
return new SaQuickBooksDataItem_Online(entityType);
|
|
}
|
|
/// <summary>Create data item iterator (to retrieve list of data items of specific type).</summary>
|
|
public override SaQuickBooksDataItem.Iterator CreateItemIterator (Qbk.EntityType entityType)
|
|
{
|
|
return new SaQuickBooksDataItem_Online.Iterator(this, entityType);
|
|
}
|
|
|
|
//---------------------------------------------------------------
|
|
// Online Authorisation.
|
|
public SaQuickBooksRequest_Online.AuthorisationData DoQBooksOnlineAuthorisation ()
|
|
{
|
|
SaQuickBooksRequest_Online.AuthorisationData authData = new SaQuickBooksRequest_Online.AuthorisationData();
|
|
return authData;
|
|
}
|
|
//---------------------------------------------------------------
|
|
// QBO interface.
|
|
public bool DoQBooksRequest (SaQuickBooksRequest_Online qboRequest)
|
|
{
|
|
ClearErrorState();
|
|
|
|
return OK;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
}
|
|
//=======================================================================
|
|
}
|