Class ScraperSession

Namespace
Subsembly.Scraper
Assembly
Subsembly.Scraper.dll

Convenient base implementation with method stubs for IScraperSession.

public abstract class ScraperSession : HttpClient, IDisposable, IScraperSession, IScraperPersist, IScraperSessionAccountInformation, IScraperSessionPayments, IScraperSessionDocuments, IScraperSessionSecuritiesPortfolio
Inheritance
HttpClient
ScraperSession
Implements
Derived
Inherited Members
HttpClient.HttpSendRequestCompleted
HttpClient.Dispose()
HttpClient.SetProxy(HttpProxy)
HttpClient.Timeout
HttpClient.ContentEncoding
HttpClient.Refresh
HttpClient.ContentType
HttpClient.ContentDispositionFileName
HttpClient.LastHttpStatus
HttpClient.CurrentLocation
HttpClient.ReferrerPolicy
HttpClient.AuthorizationHeader
HttpClient.ClearAuthentication()
HttpClient.IgnoreSSL
HttpClient.ThrowOnHttpError
HttpClient.UserAgent
HttpClient.Origin
HttpClient.RedirectLocation
HttpClient.AcceptHeader
HttpClient.AcceptEncodingHeader
HttpClient.AcceptLanguageHeader
HttpClient.AllowRedirects
HttpClient.JsonContentType
HttpClient.JsonCharset
HttpClient.PendingAsyncRequest
HttpClient.CancelAsync()
HttpClient.ResetCookies()
HttpClient.OnAddExtraHeaders(HttpRequest)
HttpClient.OnHttpSendRequestCompleted(HttpSendRequestCompletedEventArgs)
HttpClient.TraceLineEvent
HttpClient.TraceSwitch
HttpClient.TraceOptions
HttpClient.OnTraceLine(HttpClientTraceEventArgs)

Remarks

A scraper implementation shall derive from this class and override the appropriate virtual OnXxx methods with its implementation.

This base class automatically maintains the scraper State and validates the state in all public methods. Hence, a derived class can be assured that its OnXxx methods are only called in applicable states.

Constructors

ScraperSession()

public ScraperSession()

Fields

CREDENTIAL_CHALLENGERESPONSE

public const string CREDENTIAL_CHALLENGERESPONSE = "ChallengeResponse"

Field Value

string

CREDENTIAL_PASSWORD

public const string CREDENTIAL_PASSWORD = "Password"

Field Value

string

CREDENTIAL_USERID

public const string CREDENTIAL_USERID = "UserID"

Field Value

string

Properties

Accounts

Provides the account list from the most recent Login(JsonObject).

public JsonObject[] Accounts { get; }

Property Value

JsonObject[]

Remarks

If the scraper did not provide an account list, then this property is null.

Contact

public IScraperContact Contact { get; }

Property Value

IScraperContact

IsDirty

public bool IsDirty { get; }

Property Value

bool

MaxDocumentDays

public int MaxDocumentDays { get; protected set; }

Property Value

int

MaxStatementDays

public int MaxStatementDays { get; protected set; }

Property Value

int

State

public ScraperSessionState State { get; }

Property Value

ScraperSessionState

UserAddresses

Convenient access to the Addresses array of the UserDetails.

public string[] UserAddresses { get; set; }

Property Value

string[]

UserCardDetails

Convenient access to the CardDetails array of the UserDetails.

public JsonObject[] UserCardDetails { get; set; }

Property Value

JsonObject[]

UserDetails

public JsonObject UserDetails { get; protected set; }

Property Value

JsonObject

Remarks

If the scraper did not provide user details, then this property is null.

UserEMailAddresses

Convenient access to the EMailAddresses array of the UserDetails.

public string[] UserEMailAddresses { get; set; }

Property Value

string[]

UserIdentification

Convenient access to the Identification field of the UserDetails.

public string UserIdentification { get; set; }

Property Value

string

UserName

Convenient access to the Name field of the UserDetails.

public string UserName { get; set; }

Property Value

string

UserPhoneNumbers

Convenient access to the PhoneNumbers array of the UserDetails.

public string[] UserPhoneNumbers { get; set; }

Property Value

string[]

Methods

AddCardDetails(string, string, string)

Adds a new CardDetails object to the UserCardDetails.

protected JsonObject AddCardDetails(string sAccountNumber, string sCardHolderName, string sMaskedCardNumber)

Parameters

sAccountNumber string

Optional account number or some other identification of the account that these UserCardDetails are referring to.

sCardHolderName string

Optional card holder name. If null or empty, then it won't be set in the CardDetails object.

sMaskedCardNumber string

Optional masked card number. If null or empty, then it won't be set in the CardDetails object.

Returns

JsonObject

Returns the newly created CardDetails object that has already been added to the UserCardDetails. The returned object may be used to add further custom fields to the object.

CancelPayment()

public ScraperResult CancelPayment()

Returns

ScraperResult

ContinueDownloadStatement(out SepaDocument, JsonObject)

public ScraperResult ContinueDownloadStatement(out SepaDocument aCamtDoc, JsonObject jsAuthCredentials)

Parameters

aCamtDoc SepaDocument
jsAuthCredentials JsonObject

Returns

ScraperResult

ContinueLogin(JsonObject)

Default implementation validates parameters and then calls OnContinueLogin(out SepaAccount[], JsonObject).

public ScraperResult ContinueLogin(JsonObject jsCredential)

Parameters

jsCredential JsonObject

Returns

ScraperResult

Remarks

A concrete scraper implementation must override OnContinueLogin(out SepaAccount[], JsonObject) and not this method.

ContinuePayment(JsonObject)

Default implementation validates parameters and then calls OnContinuePayment(JsonObject).

public ScraperResult ContinuePayment(JsonObject jsAuthCredentials)

Parameters

jsAuthCredentials JsonObject

Returns

ScraperResult

Remarks

A concrete scraper implementation must override OnContinuePayment(JsonObject) and not this method.

DownloadBalances(out SepaBalance[], JsonObject)

Default implementation validates parameters and then calls OnDownloadBalances(out SepaBalance[], SepaAccount).

public ScraperResult DownloadBalances(out SepaBalance[] vaBalances, JsonObject jsAcct)

Parameters

vaBalances SepaBalance[]
jsAcct JsonObject

Returns

ScraperResult

Remarks

A concrete scraper implementation must override OnDownloadBalances(out SepaBalance[], SepaAccount) and not this method.

DownloadDocument(out byte[], JsonObject, JsonObject)

Default implementation validates parameters and then calls OnDownloadDocument(out byte[], SepaAccount, JsonObject).

public ScraperResult DownloadDocument(out byte[] vbPDF, JsonObject jsAcct, JsonObject jsDoc)

Parameters

vbPDF byte[]
jsAcct JsonObject
jsDoc JsonObject

Returns

ScraperResult

DownloadDocumentList(out JsonArray, JsonObject, DateTime)

Default implementation validates parameters and then calls OnDownloadDocumentList(out JsonArray, SepaAccount, DateTime).

public ScraperResult DownloadDocumentList(out JsonArray jsDocList, JsonObject jsAcct, DateTime tFromDate)

Parameters

jsDocList JsonArray
jsAcct JsonObject
tFromDate DateTime

Returns

ScraperResult

Remarks

A concrete scraper implementation must override OnDownloadDocumentList(out JsonArray, SepaAccount, DateTime) and not this method.

DownloadPortfolio(out IEnumerable<JsonObject>, JsonObject)

public ScraperResult DownloadPortfolio(out IEnumerable<JsonObject> vPortfItems, JsonObject jsAcct)

Parameters

vPortfItems IEnumerable<JsonObject>
jsAcct JsonObject

Returns

ScraperResult

DownloadStatement(out SepaDocument, JsonObject, DateTime)

Default implementation validates parameters and then calls OnDownloadStatement(out SepaStatement, SepaAccount, DateTime).

public ScraperResult DownloadStatement(out SepaDocument aCamtDoc, JsonObject jsAcct, DateTime tFromDate)

Parameters

aCamtDoc SepaDocument

The SepaStatement returned from the scraper is packaged into a full CAMT SepaDocument.

jsAcct JsonObject
tFromDate DateTime

Returns

ScraperResult

Remarks

A concrete scraper implementation must override OnDownloadStatement(out SepaStatement, SepaAccount, DateTime) and not this method.

GetUserDetails(string)

protected string GetUserDetails(string sFieldName)

Parameters

sFieldName string

Returns

string

InitiatePayment(SepaDocument)

Default implementation validates parameters and then calls OnInitiatePayment(SepaDocument).

public ScraperResult InitiatePayment(SepaDocument aPainDoc)

Parameters

aPainDoc SepaDocument

Returns

ScraperResult

Remarks

A concrete scraper implementation must override OnInitiatePayment(SepaDocument) and not this method.

Load(JsonObject)

Loads the HTTP state and then delegates to OnLoad(JsonObject).

public void Load(JsonObject js)

Parameters

js JsonObject

Login(JsonObject)

Default implementation validates parameters and then calls OnLogin(out SepaAccount[], JsonObject).

public ScraperResult Login(JsonObject jsCredential)

Parameters

jsCredential JsonObject

Returns

ScraperResult

Remarks

A concrete scraper implementation must override OnLogin(out SepaAccount[], JsonObject) and not this method.

Logout()

public void Logout()

OnCancelPayment()

Always returns Subsembly.Scraper.ScraperResult.NotSupported.

public virtual ScraperResult OnCancelPayment()

Returns

ScraperResult

OnContinueDownloadStatement(out SepaStatement, JsonObject)

public virtual ScraperResult OnContinueDownloadStatement(out SepaStatement aStmt, JsonObject jsCredential)

Parameters

aStmt SepaStatement
jsCredential JsonObject

Returns

ScraperResult

OnContinueLogin(out SepaAccount[], JsonObject)

The default implementation always returns NotSupported.

public virtual ScraperResult OnContinueLogin(out SepaAccount[] vAccts, JsonObject jsCredential)

Parameters

vAccts SepaAccount[]
jsCredential JsonObject

Returns

ScraperResult

OnContinuePayment(JsonObject)

Always returns Subsembly.Scraper.ScraperResult.NotSupported.

public virtual ScraperResult OnContinuePayment(JsonObject jsAuthCredentials)

Parameters

jsAuthCredentials JsonObject

Returns

ScraperResult

OnDownloadBalances(out SepaBalance[], SepaAccount)

Always throws a NotImplementedException.

public virtual ScraperResult OnDownloadBalances(out SepaBalance[] vaBalances, SepaAccount aAcct)

Parameters

vaBalances SepaBalance[]
aAcct SepaAccount

Returns

ScraperResult

OnDownloadDocument(out byte[], SepaAccount, JsonObject)

Always returns Subsembly.Scraper.ScraperResult.NotSupported.

public virtual ScraperResult OnDownloadDocument(out byte[] vbPDF, SepaAccount aAcct, JsonObject jsDoc)

Parameters

vbPDF byte[]
aAcct SepaAccount
jsDoc JsonObject

Returns

ScraperResult

OnDownloadDocumentList(out JsonArray, SepaAccount, DateTime)

Always throws a NotImplementedException.

public virtual ScraperResult OnDownloadDocumentList(out JsonArray jsDocList, SepaAccount aAcct, DateTime tFromDate)

Parameters

jsDocList JsonArray
aAcct SepaAccount
tFromDate DateTime

Returns

ScraperResult

OnDownloadPortfolio(out IEnumerable<SupaRecordJson>, SepaAccount)

Always returns Subsembly.Scraper.ScraperResult.NotSupported.

public virtual ScraperResult OnDownloadPortfolio(out IEnumerable<SupaRecordJson> vPortfItems, SepaAccount aAcct)

Parameters

vPortfItems IEnumerable<SupaRecordJson>
aAcct SepaAccount

Returns

ScraperResult

OnDownloadStatement(out SepaStatement, SepaAccount, DateTime)

Always throws a NotImplementedException.

public virtual ScraperResult OnDownloadStatement(out SepaStatement aStmt, SepaAccount aAcct, DateTime tFromDate)

Parameters

aStmt SepaStatement
aAcct SepaAccount
tFromDate DateTime

Returns

ScraperResult

OnInitiatePayment(SepaDocument)

Always returns Subsembly.Scraper.ScraperResult.NotSupported.

public virtual ScraperResult OnInitiatePayment(SepaDocument aPainDoc)

Parameters

aPainDoc SepaDocument

Returns

ScraperResult

OnLoad(JsonObject)

Empty default implementation. May be provided by the derived class.

public virtual void OnLoad(JsonObject js)

Parameters

js JsonObject

OnLogin(out SepaAccount[], JsonObject)

No default implementation. Must be provided by the derived class.

public abstract ScraperResult OnLogin(out SepaAccount[] vAccts, JsonObject jsCredential)

Parameters

vAccts SepaAccount[]
jsCredential JsonObject

Returns

ScraperResult

OnLogout()

No default implementation. Must be provided by the derived class.

public abstract void OnLogout()

OnSave(JsonObject)

Empty default implementation. May be provided by the derived class.

public virtual void OnSave(JsonObject js)

Parameters

js JsonObject

Save()

Saves the HTTP state and then delegates to OnSave(JsonObject).

public JsonObject Save()

Returns

JsonObject

SetUserDetails(string, string)

protected void SetUserDetails(string sFieldName, string sFieldValue)

Parameters

sFieldName string
sFieldValue string