//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary>Initializes a new instance of the <see cref="BV_Connector"/>.Trusted constructor</summary> /// <remarks> 2012/02/16. </remarks> /// <param name="consumerKey">The application Identifier.</param> /// <param name="consumerSecret">The application Secret.</param> /// <param name="certCollection">The certificate collection to attach into the request, /// for SSL client authentication.</param> //////////////////////////////////////////////////////////////////////////////////////////////////// public BV_Connector(string consumerKey, string consumerSecret, X509CertificateCollection certCollection) { if (String.IsNullOrEmpty(consumerKey) || String.IsNullOrEmpty(consumerKey)||(certCollection==null)) { BlueviaException ex = new BlueviaException("Null or Empty parameter when creating a Trusted BV_Connector."); ex.code = ExceptionCode.InvalidArgumentException; throw ex; } oauthManager = new OAuthManager(consumerKey, consumerSecret); base.certCollection = certCollection; }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary>Function to set the Bluevia Api service response description.</summary> /// <param name="data">The description.</param> //////////////////////////////////////////////////////////////////////////////////////////////////// public void SetResponseData(string data){ if (string.IsNullOrEmpty(data)) { BlueviaException ex = new BlueviaException("Null Data parameter when setting data in Bluevia_Response."); ex.code = ExceptionCode.InvalidArgumentException; throw ex; } else { message = data; } }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary>Function to set the response Http resulting code.</summary> /// <param name="status">The code.</param> //////////////////////////////////////////////////////////////////////////////////////////////////// public void SetResponseStatus(string status){ if (string.IsNullOrEmpty(status)) { BlueviaException ex = new BlueviaException("Null ResponseStatus parameter when setting status in Bluevia_Response."); ex.code = ExceptionCode.InvalidArgumentException; throw ex; } else { code = status; } }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary>Function to add a single header.</summary> /// <param name="key">The label of the header.</param> /// <param name="value">The content of the header.</param> //////////////////////////////////////////////////////////////////////////////////////////////////// public void AddHeader(string key, string value) { if (string.IsNullOrEmpty(key) || string.IsNullOrEmpty(value)) { BlueviaException ex = new BlueviaException("Null or empty key||value parameters when adding a header in additionalResponseData."); ex.code = ExceptionCode.InvalidArgumentException; throw ex; } else { headers.Add(key, value); } }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary>Sets the body headers value.</summary> /// <param name="headers">The received response body headers.</param> //////////////////////////////////////////////////////////////////////////////////////////////////// public void SetHeaders(Dictionary<string, string> headers) { if (headers == null) { BlueviaException ex = new BlueviaException("Null Headers parameter when setting headers in additionalResponseData."); ex.code = ExceptionCode.InvalidArgumentException; throw ex; } else { this.headers = headers; } }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary>Function to set the Bluevia Api service response info. Hedares and body.</summary> /// <param name="addData">The headers and body of the response.</param> //////////////////////////////////////////////////////////////////////////////////////////////////// public void SetResponseAdditionalData(AdditionalResponseData addData) { if (addData==null) { BlueviaException ex = new BlueviaException("Null AdditionalData parameter when setting AdditionalData in Bluevia_Response."); ex.code = ExceptionCode.InvalidArgumentException; throw ex; } else { this.additionalData = addData; } }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary>Initializes a new instance of the <see cref="BV_Connector"/>Untrusted 2 and 3 legged constructor</summary> /// <remarks>2012.05.8 Adding mutual check for token existence. </remarks> /// <param name="consumerKey">The application Identifier.</param> /// <param name="consumerSecret">The application Secret.</param> /// <param name="token">Optional (Mandatory for 3legged behavior): The final customer Identifier.</param> /// <param name="tokenSecret">Optional (Mandatory for 3legged behavior): The final customer Secret.</param> //////////////////////////////////////////////////////////////////////////////////////////////////// public BV_Connector(string consumerKey, string consumerSecret, string token = "", string tokenSecret = "") { if (String.IsNullOrEmpty(consumerKey) || String.IsNullOrEmpty(consumerKey) ) { BlueviaException ex = new BlueviaException("Null or Empty parameter when creating Untrusted BV_Connector."); ex.code = ExceptionCode.InvalidArgumentException; throw ex; } if ((string.IsNullOrWhiteSpace(token) && (!string.IsNullOrWhiteSpace(tokenSecret))) || ((!string.IsNullOrWhiteSpace(token)) && string.IsNullOrWhiteSpace(tokenSecret))) { throw new BlueviaException( "Both token and tokenSecret must be properly filled, or empty, when creating Bluevia Connector." , ExceptionCode.InvalidArgumentException); } oauthManager = new OAuthManager(consumerKey, consumerSecret, token, tokenSecret); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Method to set tokens of a previous Payment.</summary> /// <remarks> 2012/04/02. </remarks> /// <param name="token">The access Token</param> /// <param name="tokenSecret">The Token Secret</param> //////////////////////////////////////////////////////////////////////////////////////////////////// public void SetTokens(string token, string tokenSecret) { if (string.IsNullOrEmpty(token) || string.IsNullOrEmpty(tokenSecret)) { BlueviaException ex = new BlueviaException("Null or empty tokens when using SetTokens."); ex.code = ExceptionCode.InvalidArgumentException; throw ex; } connector.SetTokens(token,tokenSecret); }