コード例 #1
0
        public override NoAPIResponse getResponse()
        {
            BrimeAPIResponse response = doRequest();

            BrimeAPIError.ThrowException(response);
            return(new NoAPIResponse(response.Data));
        }
コード例 #2
0
        public override BrimeEmoteSet getResponse()
        {
            BrimeAPIResponse response = doRequest();

            BrimeAPIError.ThrowException(response);
            return(new BrimeEmoteSet(response.Data));
        }
コード例 #3
0
        }                                                               // No parameters

        public override int getResponse()
        {
            BrimeAPIResponse response = doRequest();

            BrimeAPIError.ThrowException(response);
            return(response.Data.Value <int>("total"));
        }
コード例 #4
0
        public override List <BrimeClip> getResponse()
        {
            BrimeAPIResponse response = doRequest();

            BrimeAPIError.ThrowException(response);

            JArray?clips = response.Data.Value <JArray>("clips");

            if (clips != null)
            {
                List <BrimeClip> _result = new List <BrimeClip>(clips.Count);
                foreach (JToken?clip in clips)
                {
                    if (clip != null)
                    {
                        _result.Add(new BrimeClip(clip));
                    }
                }
                return(_result);
            }
            else
            {
                return(new List <BrimeClip>());
            }
        }
コード例 #5
0
        public override LivestreamsByCategoryResponse getResponse()
        {
            BrimeAPIResponse response = doRequest();

            BrimeAPIError.ThrowException(response);
            return(new LivestreamsByCategoryResponse(response));
        }
コード例 #6
0
        public override bool getResponse()
        {
            BrimeAPIResponse response = doRequest();

            try {
                BrimeAPIError.ThrowException(response);
            } catch (BrimeAPIInvalidChannel) {
                return(false);
            }
            return(true);
        }
コード例 #7
0
ファイル: CategoryRequest.cs プロジェクト: Tybern82/BrimeAPI
        public override BrimeCategory getResponse()
        {
            // Trigger the request and process the JSON response.
            BrimeAPIResponse response = doRequest();

            // Trigger exceptions for any detected errors in the response.
            BrimeAPIError.ThrowException(response);

            // Generate the new Category from the response.
            return(new BrimeCategory(response.Data));
        }
コード例 #8
0
ファイル: BrimeAPIResponse.cs プロジェクト: Tybern82/BrimeAPI
        public BrimeAPIResponse(string json)
        {
            // Process the JSON data
            JObject apiResponse = JObject.Parse(json);

            // Identify whether there is an actual API response, or just load empty data response if none present.
            JObject?data = apiResponse.Value <JObject>("data");

            if (data == null)
            {
                Logger.Warn("Missing 'data' in JSON response");
                Data = JObject.Parse("{}");
            }
            else
            {
                Data = data;
            }

            // Identify whether there are any API errors.
            JArray?apiErrors = apiResponse.Value <JArray>("errors");

            if (apiErrors != null)
            {
                Errors = new List <BrimeAPIError>(apiErrors.Count);
                foreach (JToken err in apiErrors)
                {
                    string?eMessage = err.ToObject <string>();
                    if (eMessage == null)
                    {
                        Logger.Error("Unable to decode error in response");
                        throw new BrimeAPIMalformedResponse("Unable to decode error in response");
                    }
                    Errors.Add(BrimeAPIError.lookupError(eMessage));
                }
            }
            else
            {
                // No errors detected in response data
                Errors = new List <BrimeAPIError>();
            }
            // Log a warning if any error identified.
            Logger.Warn(() => {
                return(String.Join <BrimeAPIError>(", ", Errors));
            });

            // Identify whether there is any Notice in the API response. By default this will be logged.
            string?notice = apiResponse.Value <string>("__notice");

            __Notice = (notice == null) ? "" : notice;
            if (!string.IsNullOrWhiteSpace(__Notice))
            {
                Logger.Info(() => { return("API-NOTICE: " + __Notice); });
            }
        }
コード例 #9
0
 public GlobalEmotesResponse(BrimeAPIResponse apiResponse)
 {
     BrimeAPIError.ThrowException(apiResponse);
     try {
         JArray?emoteSets = apiResponse.Data.Value <JArray>("emoteSets");
         GlobalEmoteSets = new List <BrimeEmoteSet>((emoteSets == null) ? 0 : emoteSets.Count);
         if (emoteSets != null)
         {
             foreach (JToken set in emoteSets)
             {
                 GlobalEmoteSets.Add(new BrimeEmoteSet(set));
             }
         }
     } catch (Exception e) {
         throw new BrimeAPIMalformedResponse(e.ToString());
     }
 }
コード例 #10
0
        public override List <BrimeStream> getResponse()
        {
            BrimeAPIResponse response = doRequest();

            BrimeAPIError.ThrowException(response);
            List <BrimeStream> _result;
            JArray?            streams = response.Data.Value <JArray>("streams");

            if (streams != null)
            {
                _result = new List <BrimeStream>(streams.Count);
                foreach (JToken item in streams)
                {
                    _result.Add(new BrimeStream(item));
                }
            }
            else
            {
                _result = new List <BrimeStream>();
            }
            return(_result);
        }
コード例 #11
0
        public override List <LivestreamsByCategoryResponse> getResponse()
        {
            BrimeAPIResponse response = doRequest();

            BrimeAPIError.ThrowException(response);
            JArray?items = response.Data.Value <JArray>("categories");

            if (items != null)
            {
                List <LivestreamsByCategoryResponse> _result = new List <LivestreamsByCategoryResponse>(items.Count);
                foreach (JToken item in items)
                {
                    if (item != null)
                    {
                        _result.Add(new LivestreamsByCategoryResponse(item));
                    }
                }
                return(_result);
            }
            else
            {
                return(new List <LivestreamsByCategoryResponse>());
            }
        }
コード例 #12
0
 public BrimeAPIInternalError(BrimeAPIError error) : base(error)
 {
 }
コード例 #13
0
 public BrimeAPIRateLimitExceeded(BrimeAPIError error) : base(error)
 {
 }
コード例 #14
0
 public BrimeAPIInvalidChannel(BrimeAPIError error) : base(error)
 {
 }
コード例 #15
0
 public BrimeAPIMissingScope(BrimeAPIError error) : base(error)
 {
 }
コード例 #16
0
 public BrimeAPINotImplemented(BrimeAPIError error) : base(error)
 {
 }
コード例 #17
0
 public BrimeAPIInvalidClientID(BrimeAPIError error) : base(error)
 {
 }
コード例 #18
0
 public BrimeAPIMissingAccess(BrimeAPIError apiError) : base(apiError)
 {
 }
コード例 #19
0
 public BrimeAPIMissingParameter(BrimeAPIError error) : base(error)
 {
 }