/// <summary> /// Initializes the API connector with rest client, endpoint, headers and authentication /// </summary> private void Init() { if (!string.IsNullOrEmpty(PenneoConnector.Endpoint)) { _endpoint = PenneoConnector.Endpoint; } _client = new RestClient(_endpoint); _restResources = ServiceLocator.Instance.GetInstance <RestResources>(); _headers = PenneoConnector.Headers ?? new Dictionary <string, string>(); _headers["Content-type"] = "application/json"; if (!string.IsNullOrEmpty(PenneoConnector.User)) { _headers["penneo-api-user"] = PenneoConnector.User; } if (PenneoConnector.AuthenticationType == AuthType.WSSE) { _client.Authenticator = new WSSEAuthenticator(PenneoConnector.Key, PenneoConnector.Secret); } else { throw new NotSupportedException("Unknown authentication type " + PenneoConnector.AuthenticationType); } LatestEntityServerResults = new Dictionary <Guid, ServerResult>(); PenneoConnector.Reset(); }
internal ApiConnector(PenneoConnector con, RestResources restResources, string endpoint, Dictionary <string, string> headers, string user, string key, string secret, AuthType authType) { _con = con; _restResources = restResources; _endpoint = endpoint; _headers = headers; _user = user; _key = key; _secret = secret; _authType = authType; Init(); }