-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDataServiceFactory.cs
58 lines (57 loc) · 2.32 KB
/
DataServiceFactory.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
////*********************************************************
// <copyright company="Intuit">
// Author:Nimisha
//
////*********************************************************
using Intuit.Ipp.Core;
using Intuit.Ipp.DataService;
using Intuit.Ipp.Security;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using Webhooks.Models.DTO;
namespace Webhooks.Models.Service
{
public class DataServiceFactory
{
private OAuthRequestValidator oAuthRequestValidator = null;
private DataService dataService = null;
IntuitServicesType intuitServicesType = new IntuitServicesType();
private ServiceContext serviceContext = null;
public ServiceContext getServiceContext { get; set; }
/// <summary>
/// Allocate memory for service context objects
/// </summary>
public DataServiceFactory(OAuthTokensRealmLastUpdateddto oAuthorization)
{
try
{
oAuthRequestValidator = new OAuthRequestValidator(
oAuthorization.OAuthTokens.access_token,
oAuthorization.OAuthTokens.access_secret,
oAuthorization.ConsumerKey,
oAuthorization.ConsumerSecret);
intuitServicesType = oAuthorization.OAuthTokens.datasource == "QBO" ? IntuitServicesType.QBO : IntuitServicesType.None;
serviceContext = new ServiceContext(oAuthorization.OAuthTokens.realmid.ToString(), intuitServicesType, oAuthRequestValidator);
serviceContext.IppConfiguration.BaseUrl.Qbo = ConfigurationManager.AppSettings["ServiceContext.BaseUrl.Qbo"];
//serviceContext.IppConfiguration.Logger.RequestLog.EnableRequestResponseLogging = true;
//serviceContext.IppConfiguration.Logger.RequestLog.ServiceRequestLoggingLocation = ConfigurationManager.AppSettings["ServiceRequestLoggingLocation"];
getServiceContext = serviceContext;
dataService = new DataService(serviceContext);
}
catch (Intuit.Ipp.Exception.FaultException ex)
{
throw ex;
}
}
/// <summary>
/// Return the current data service
/// </summary>
public DataService getDataService()
{
return dataService;
}
}
}