/// <summary>
        /// Try to parse the given JSON representation of a PullEVSEStatus request.
        /// </summary>
        /// <param name="JSON">The JSON to parse.</param>
        /// <param name="PullEVSEStatusRequest">The parsed PullEVSEStatus request.</param>
        /// <param name="ErrorResponse">An optional error response.</param>
        /// <param name="CustomPullEVSEStatusRequestParser">A delegate to parse custom PullEVSEStatus request JSON objects.</param>
        public static Boolean TryParse(JObject JSON,
                                       out PullEVSEStatusRequest PullEVSEStatusRequest,
                                       out String ErrorResponse,
                                       CustomJObjectParserDelegate <PullEVSEStatusRequest> CustomPullEVSEStatusRequestParser = null)
        {
            try
            {
                PullEVSEStatusRequest = default;

                if (JSON?.HasValues != true)
                {
                    ErrorResponse = "The given JSON object must not be null or empty!";
                    return(false);
                }

                #region Parse ProviderId            [mandatory]

                if (!JSON.ParseMandatory("ProviderID",
                                         "provider identification",
                                         Provider_Id.TryParse,
                                         out Provider_Id ProviderId,
                                         out ErrorResponse))
                {
                    return(false);
                }

                #endregion

                #region Parse SearchCenter          [optional]

                GeoCoordinates SearchCenter = default;
                Single?        DistanceKM   = default;

                if (JSON.ParseOptional("SearchCenter",
                                       "SearchCenter",
                                       out JObject searchCenter,
                                       out ErrorResponse))
                {
                    if (searchCenter.ParseOptionalJSON("GeoCoordinates",
                                                       "search center geo coordinates",
                                                       GeoCoordinates.TryParse,
                                                       out SearchCenter,
                                                       out ErrorResponse))
                    {
                        if (ErrorResponse != null)
                        {
                            return(false);
                        }
                    }

                    #endregion

                    #region Parse DistanceKM            [optional]

                    if (searchCenter.ParseOptional("Radius",
                                                   "search center radius",
                                                   out DistanceKM,
                                                   out ErrorResponse))
                    {
                        if (ErrorResponse != null)
                        {
                            return(false);
                        }
                    }
                }

                #endregion

                #region Parse EVSEStatusFilter      [optional]

                if (JSON.ParseOptional("EvseStatus",
                                       "EVSE status filter",
                                       EVSEStatusTypesExtensions.TryParse,
                                       out EVSEStatusTypes EVSEStatusFilter,
                                       out ErrorResponse))
                {
                    if (ErrorResponse != null)
                    {
                        return(false);
                    }
                }

                #endregion

                #region Parse CustomData            [optional]

                var CustomData = JSON["CustomData"] as JObject;

                #endregion


                PullEVSEStatusRequest = new PullEVSEStatusRequest(ProviderId,
                                                                  SearchCenter,
                                                                  DistanceKM,
                                                                  EVSEStatusFilter,
                                                                  CustomData);

                if (CustomPullEVSEStatusRequestParser != null)
                {
                    PullEVSEStatusRequest = CustomPullEVSEStatusRequestParser(JSON,
                                                                              PullEVSEStatusRequest);
                }

                return(true);
            }
            catch (Exception e)
            {
                PullEVSEStatusRequest = default;
                ErrorResponse         = "The given JSON representation of a PullEVSEStatus request is invalid: " + e.Message;
                return(false);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Try to parse the given JSON representation of a PullEVSEData request.
        /// </summary>
        /// <param name="JSON">The JSON to parse.</param>
        /// <param name="PullEVSEDataRequest">The parsed PullEVSEData request.</param>
        /// <param name="ErrorResponse">An optional error response.</param>
        /// <param name="CustomPullEVSEDataRequestParser">A delegate to parse custom PullEVSEData request JSON objects.</param>
        public static Boolean TryParse(JObject JSON,
                                       out PullEVSEDataRequest PullEVSEDataRequest,
                                       out String ErrorResponse,
                                       UInt32?Page = null,
                                       UInt32?Size = null,
                                       IEnumerable <String> SortOrder = null,
                                       CustomJObjectParserDelegate <PullEVSEDataRequest> CustomPullEVSEDataRequestParser = null)
        {
            try
            {
                PullEVSEDataRequest = default;

                if (JSON?.HasValues != true)
                {
                    ErrorResponse = "The given JSON object must not be null or empty!";
                    return(false);
                }

                #region Parse ProviderId                                [mandatory]

                if (!JSON.ParseMandatory("ProviderID",
                                         "provider identification",
                                         Provider_Id.TryParse,
                                         out Provider_Id ProviderId,
                                         out ErrorResponse))
                {
                    return(false);
                }

                #endregion

                #region Parse LastCall                                  [optional]

                if (JSON.ParseOptional("LastCall",
                                       "last call",
                                       out DateTime? LastCall,
                                       out ErrorResponse))
                {
                    if (ErrorResponse != null)
                    {
                        return(false);
                    }
                }

                #endregion


                #region Parse OperatorIdFilter                          [optional]

                if (JSON.ParseOptionalJSON("OperatorIds",
                                           "operator identification filter",
                                           Operator_Id.TryParse,
                                           out IEnumerable <Operator_Id> OperatorIdFilter,
                                           out ErrorResponse))
                {
                    if (ErrorResponse != null)
                    {
                        return(false);
                    }
                }

                #endregion

                #region Parse CountryCodeFilter                         [optional]

                if (JSON.ParseOptionalJSON("CountryCodes",
                                           "country code filter",
                                           Country.TryParse,
                                           out IEnumerable <Country> CountryCodeFilter,
                                           out ErrorResponse))
                {
                    if (ErrorResponse != null)
                    {
                        return(false);
                    }
                }

                #endregion

                #region Parse AccessibilityFilter                       [optional]

                if (JSON.ParseOptionalJSON("Accessibility",
                                           "accessibility filter",
                                           AccessibilityTypesExtensions.TryParse,
                                           out IEnumerable <AccessibilityTypes> AccessibilityFilter,
                                           out ErrorResponse))
                {
                    if (ErrorResponse != null)
                    {
                        return(false);
                    }
                }

                #endregion

                #region Parse AuthenticationModeFilter                  [optional]

                if (JSON.ParseOptionalJSON("AuthenticationModes",
                                           "authentication mode filter",
                                           AuthenticationModesExtensions.TryParse,
                                           out IEnumerable <AuthenticationModes> AuthenticationModeFilter,
                                           out ErrorResponse))
                {
                    if (ErrorResponse != null)
                    {
                        return(false);
                    }
                }

                #endregion

                #region Parse CalibrationLawDataAvailabilityFilter      [optional]

                if (JSON.ParseOptionalJSON("CalibrationLawDataAvailability",
                                           "calibration law data availability filter",
                                           CalibrationLawDataAvailabilitiesExtensions.TryParse,
                                           out IEnumerable <CalibrationLawDataAvailabilities> CalibrationLawDataAvailabilityFilter,
                                           out ErrorResponse))
                {
                    if (ErrorResponse != null)
                    {
                        return(false);
                    }
                }

                #endregion

                #region Parse RenewableEnergyFilter                     [optional]

                if (JSON.ParseOptional("RenewableEnergy",
                                       "renewable energy filter",
                                       out Boolean? RenewableEnergyFilter,
                                       out ErrorResponse))
                {
                    if (ErrorResponse != null)
                    {
                        return(false);
                    }
                }

                #endregion

                #region Parse IsHubjectCompatibleFilter                 [optional]

                if (JSON.ParseOptional("IsHubjectCompatible",
                                       "is hubject compatible filter",
                                       out Boolean? IsHubjectCompatibleFilter,
                                       out ErrorResponse))
                {
                    if (ErrorResponse != null)
                    {
                        return(false);
                    }
                }

                #endregion

                #region Parse IsOpen24Hours                             [optional]

                if (JSON.ParseOptional("IsOpen24Hours",
                                       "is open 24 hours filter",
                                       out Boolean? IsOpen24HoursFilter,
                                       out ErrorResponse))
                {
                    if (ErrorResponse != null)
                    {
                        return(false);
                    }
                }

                #endregion


                #region Parse SearchCenter                              [optional]

                GeoCoordinates SearchCenter = default;
                Single?        DistanceKM   = default;

                if (JSON.ParseOptional("SearchCenter",
                                       "SearchCenter",
                                       out JObject searchCenter,
                                       out ErrorResponse))
                {
                    if (searchCenter.ParseOptionalJSON("GeoCoordinates",
                                                       "search center geo coordinates",
                                                       GeoCoordinates.TryParse,
                                                       out SearchCenter,
                                                       out ErrorResponse))
                    {
                        if (ErrorResponse != null)
                        {
                            return(false);
                        }
                    }

                    #endregion

                    #region Parse DistanceKM                                [optional]

                    if (searchCenter.ParseOptional("Radius",
                                                   "search center radius",
                                                   out DistanceKM,
                                                   out ErrorResponse))
                    {
                        if (ErrorResponse != null)
                        {
                            return(false);
                        }
                    }
                }

                #endregion

                #region Parse OperatorIdFilter                          [optional]

                if (JSON.ParseOptional("GeoCoordinatesResponseFormat",
                                       "geo coordinates response format",
                                       GeoCoordinatesFormatsExtensions.TryParse,
                                       out GeoCoordinatesFormats GeoCoordinatesResponseFormat,
                                       out ErrorResponse))
                {
                    if (ErrorResponse != null)
                    {
                        return(false);
                    }
                }

                #endregion


                #region Parse CustomData                                [optional]

                var CustomData = JSON["CustomData"] as JObject;

                #endregion


                PullEVSEDataRequest = new PullEVSEDataRequest(ProviderId,
                                                              LastCall,

                                                              OperatorIdFilter,
                                                              CountryCodeFilter,
                                                              AccessibilityFilter,
                                                              AuthenticationModeFilter,
                                                              CalibrationLawDataAvailabilityFilter,
                                                              RenewableEnergyFilter,
                                                              IsHubjectCompatibleFilter,
                                                              IsOpen24HoursFilter,

                                                              SearchCenter,
                                                              DistanceKM,
                                                              GeoCoordinatesResponseFormat,

                                                              Page,
                                                              Size,
                                                              SortOrder,

                                                              CustomData);

                if (CustomPullEVSEDataRequestParser != null)
                {
                    PullEVSEDataRequest = CustomPullEVSEDataRequestParser(JSON,
                                                                          PullEVSEDataRequest);
                }

                return(true);
            }
            catch (Exception e)
            {
                PullEVSEDataRequest = default;
                ErrorResponse       = "The given JSON representation of a PullEVSEData request is invalid: " + e.Message;
                return(false);
            }
        }