コード例 #1
0
        public TKey GetApiKeyDetail(string keySid = "")
        {
            Key keyValue = null;

            if (string.IsNullOrEmpty(keySid))
            {
                string keyString = File.ReadAllText(@"..\Key.JSON");
                if (!string.IsNullOrEmpty(keyString))
                {
                    keyValue = JsonConvert.DeserializeObject <Key>(keyString);
                }
            }
            else
            {
                keyValue = TwilioClient.GetKey(keySid);
            }

            if (keyValue == null)
            {
                throw new Exception("Api key not available");
            }

            if (keyValue != null && keyValue.RestException != null)
            {
                throw new Exception(keyValue.RestException.Message);
            }

            return(Mapper.Map <TKey>(keyValue));
        }