Exemplo n.º 1
0
        /// <summary>
        /// create a service class with an authorization token retrieved from GetAuthToken (if you have it). 
        /// If you do not provide one then you will only be able to get the URL to the 
        /// basecamp authorization requested page and to validate a code returned to you by that authorization.
        /// parameters come from the app you set up at integrate.37signals.com
        /// </summary>
        /// <param name="clientID">your client id from 37s</param>
        /// <param name="clientSecret">your client secret from 37s</param>
        /// <param name="redirectURI">the redirect URI you set up with 37s - this must match</param>
        /// <param name="appNameAndContact">your application name and contact info - added to your request header</param>
        /// <param name="cache">an optional cache to use for caching responses from 37s. if you don't provide one, it'll use the System.Runtime.Caching.MemoryCache.Default cache</param>
        /// <param name="accessToken">if you have an access token, provide it here. this is the entire json object returned from the call to GetAccessToken</param>
        public Service(string clientID,
            string clientSecret,
            string redirectURI,
            string appNameAndContact,
            BCXAPI.Providers.IResponseCache cache = null,
            dynamic accessToken = null)
        {
            if (cache == null)
            {
                _cache = new BCXAPI.Providers.DefaultMemoryCache();
            }
            else
            {
                _cache = cache;
            }

            _clientID = clientID;
            _clientSecret = clientSecret;
            _redirectURI = redirectURI;
            _appNameAndContact = appNameAndContact;
            _accessToken = accessToken;

            if (string.IsNullOrWhiteSpace(clientID) ||
                string.IsNullOrWhiteSpace(clientSecret) ||
                string.IsNullOrWhiteSpace(redirectURI) ||
               string.IsNullOrWhiteSpace(_appNameAndContact))
            {
                throw new Exceptions.BaseException("You must provide the client id, client secret, redirect uri, and your app name and contact information to use the API.");
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// create a service class with an authorization token retrieved from GetAuthToken (if you have it).
        /// If you do not provide one then you will only be able to get the URL to the
        /// basecamp authorization requested page and to validate a code returned to you by that authorization.
        /// parameters come from the app you set up at integrate.37signals.com
        /// </summary>
        /// <param name="clientID">your client id from 37s</param>
        /// <param name="clientSecret">your client secret from 37s</param>
        /// <param name="redirectURI">the redirect URI you set up with 37s - this must match</param>
        /// <param name="appNameAndContact">your application name and contact info - added to your request header</param>
        /// <param name="cache">an optional cache to use for caching responses from 37s. if you don't provide one, it'll use the System.Runtime.Caching.MemoryCache.Default cache</param>
        /// <param name="accessToken">if you have an access token, provide it here. this is the entire json object returned from the call to GetAccessToken</param>
        public Service(string clientID,
                       string clientSecret,
                       string redirectURI,
                       string appNameAndContact,
                       BCXAPI.Providers.IResponseCache cache = null,
                       dynamic accessToken = null)
        {
            if (cache == null)
            {
                _cache = new BCXAPI.Providers.DefaultMemoryCache();
            }
            else
            {
                _cache = cache;
            }

            _clientID          = clientID;
            _clientSecret      = clientSecret;
            _redirectURI       = redirectURI;
            _appNameAndContact = appNameAndContact;
            _accessToken       = accessToken;

            if (string.IsNullOrWhiteSpace(clientID) ||
                string.IsNullOrWhiteSpace(clientSecret) ||
                string.IsNullOrWhiteSpace(redirectURI) ||
                string.IsNullOrWhiteSpace(_appNameAndContact))
            {
                throw new Exceptions.BaseException("You must provide the client id, client secret, redirect uri, and your app name and contact information to use the API.");
            }
        }