示例#1
0
        public static Tuple <Channel, ApiCallResponse> get(string access_token, string id, channelParameters parameters = null)
        {
            ApiCallResponse apiCallResponse = new ApiCallResponse();
            Channel         channel         = new Channel();

            try
            {
                if (string.IsNullOrEmpty(access_token))
                {
                    apiCallResponse.success      = false;
                    apiCallResponse.errorMessage = "Missing parameter access_token";
                    return(new Tuple <Channel, ApiCallResponse>(channel, apiCallResponse));
                }
                if (string.IsNullOrEmpty(id))
                {
                    apiCallResponse.success      = false;
                    apiCallResponse.errorMessage = "Missing parameter id";
                    return(new Tuple <Channel, ApiCallResponse>(channel, apiCallResponse));
                }

                string requestUrl = Common.baseUrl + "/channels/" + id;
                if (parameters != null)
                {
                    requestUrl += "?" + parameters.getQueryString();
                }

                Dictionary <string, string> headers = new Dictionary <string, string>();
                headers.Add("Authorization", "Bearer " + access_token);
                headers.Add("X-ADN-Migration-Overrides", "response_envelope=1");
                Helper.Response response = Helper.SendGetRequest(
                    requestUrl,
                    headers);

                return(Helper.getData <Channel>(response));
            }
            catch (Exception exp)
            {
                apiCallResponse.success          = false;
                apiCallResponse.errorMessage     = exp.Message;
                apiCallResponse.errorDescription = exp.StackTrace;
            }
            return(new Tuple <Channel, ApiCallResponse>(channel, apiCallResponse));
        }
示例#2
0
            public static Tuple<List<Channel>, ApiCallResponse> getOfCurrentUser(string access_token, channelParameters parameters = null)
            {
                ApiCallResponse apiCallResponse = new ApiCallResponse();
                List<Channel> channels = new List<Channel>();
                try
                {
                    if (string.IsNullOrEmpty(access_token))
                    {
                        apiCallResponse.success = false;
                        apiCallResponse.errorMessage = "Missing parameter access_token";
                        return new Tuple<List<Channel>, ApiCallResponse>(channels, apiCallResponse);
                    }

                    string requestUrl = Common.baseUrl + "/stream/0/channels";
                    if (parameters != null)
                    {
                        requestUrl += "?" + parameters.getQueryString();
                    }

                    Dictionary<string, string> headers = new Dictionary<string, string>();
                    headers.Add("Authorization", "Bearer " + access_token);
                    headers.Add("X-ADN-Migration-Overrides", "response_envelope=1");
                    Helper.Response response = Helper.SendGetRequest(
                            requestUrl,
                            headers);

                    return Helper.getData<List<Channel>>(response);
                }
                catch (Exception exp)
                {
                    apiCallResponse.success = false;
                    apiCallResponse.errorMessage = exp.Message;
                    apiCallResponse.errorDescription = exp.StackTrace;
                }
                return new Tuple<List<Channel>, ApiCallResponse>(channels, apiCallResponse);
            }