Esempio n. 1
0
        /// <summary>
        /// Create a new instance
        /// </summary>
        /// <param name="apiKey">API key</param>
        /// <param name="clientConfig">Client config</param>
        public MapsAPIClient(string apiKey, MapsAPIClientConfig clientConfig)
        {
            // Check API key
            if (apiKey == null)
            {
                // Must provide API key or enterprise credentials when creating client.
                throw new APICredentialsNotSpecifiedException();
            }

            // Validate API key
            if (apiKey != null && !apiKey.StartsWith("AIza"))
            {
                // Invalid API key provided
                throw new APIKeyInvalidException();
            }

            // Assign API key to instance
            APIKey = apiKey;

            // Init sent times
            SentTimes = new List <DateTime>();

            // Assign and initialize config
            ClientConfig = clientConfig;
            ClientConfig.Init();
        }
Esempio n. 2
0
        /// <summary>
        /// Create a new instance
        /// </summary>
        /// <param name="clientId">Client Id</param>
        /// <param name="clientSecret">Client secret</param>
        /// <param name="clientConfig">Client config</param>
        public MapsAPIClient(string clientId, string clientSecret, MapsAPIClientConfig clientConfig)
        {
            // Check enterprise credentials
            if (clientId == null || clientSecret == null)
            {
                // Must provide API key or enterprise credentials when creating client.
                throw new APICredentialsNotSpecifiedException();
            }

            // Assign enterprise credentials to instance
            ClientId     = clientId;
            ClientSecret = clientSecret;

            // Init sent times
            SentTimes = new List <DateTime>();

            // Assign and initialize config
            ClientConfig = clientConfig;
            ClientConfig.Init();
        }