internal MatchTimelineDTO(matchTimelineEndpoint timeline)
        {
            Guard.Argument(timeline, nameof(timeline)).NotNull();
            Guard.Argument(timeline.sport_event, nameof(timeline.sport_event)).NotNull();

            SportEvent = RestMapperHelper.MapSportEvent(timeline.sport_event);

            if (timeline.coverage_info != null)
            {
                CoverageInfo = new CoverageInfoDTO(timeline.coverage_info);
            }

            if (timeline.sport_event_conditions != null)
            {
                SportEventConditions = new SportEventConditionsDTO(timeline.sport_event_conditions);
            }

            if (timeline.sport_event_status != null)
            {
                SportEventStatus = new SportEventStatusDTO(timeline.sport_event_status, null, RestMapperHelper.FillHomeAwayCompetitors(timeline.sport_event.competitors));
            }

            if (timeline.timeline != null && timeline.timeline.Length > 0)
            {
                BasicEvents = timeline.timeline.Select(s => new BasicEventDTO(s));
            }

            GeneratedAt = timeline.generated_atSpecified ? timeline.generated_at : (DateTime?)null;
        }
Ejemplo n.º 2
0
        internal MatchTimelineDTO(matchTimelineEndpoint timeline)
        {
            Contract.Requires(timeline != null);
            Contract.Requires(timeline.sport_event != null);

            SportEvent = RestMapperHelper.MapSportEvent(timeline.sport_event);

            if (timeline.coverage_info != null)
            {
                CoverageInfo = new CoverageInfoDTO(timeline.coverage_info);
            }

            if (timeline.sport_event_conditions != null)
            {
                SportEventConditions = new SportEventConditionsDTO(timeline.sport_event_conditions);
            }

            if (timeline.sport_event_status != null)
            {
                SportEventStatus = new SportEventStatusDTO(timeline.sport_event_status, null,
                                                           RestMapperHelper.FillHomeAwayCompetitors(timeline.sport_event.competitors));
            }

            if (timeline.timeline != null && timeline.timeline.Length > 0)
            {
                BasicEvents = timeline.timeline.Select(s => new BasicEventDTO(s));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CompetitionDTO"/> class
        /// </summary>
        /// <param name="sportEvent">A <see cref="sportEvent"/> instance containing basic information about the sport event</param>
        internal CompetitionDTO(sportEvent sportEvent)
            : base(sportEvent)
        {
            BookingStatus?bookingStatus;

            if (RestMapperHelper.TryGetBookingStatus(sportEvent.liveodds, out bookingStatus))
            {
                BookingStatus = bookingStatus;
            }

            if (sportEvent.competitors != null && sportEvent.competitors.Any())
            {
                Competitors         = new ReadOnlyCollection <TeamCompetitorDTO>(sportEvent.competitors.Select(c => new TeamCompetitorDTO(c)).ToList());
                HomeAwayCompetitors = RestMapperHelper.FillHomeAwayCompetitors(sportEvent.competitors);
            }

            Conditions = sportEvent.sport_event_conditions == null
                             ? null
                             : new SportEventConditionsDTO(sportEvent.sport_event_conditions);

            Venue = sportEvent.sport_event_conditions?.venue == null
                        ? null
                        : new VenueDTO(sportEvent.sport_event_conditions.venue);

            if (Venue == null && sportEvent.venue != null)
            {
                Venue = new VenueDTO(sportEvent.venue);
            }
        }
        /// <summary>
        ///     Initializes a new instance of the <see cref="SportEventSummaryDTO" /> class
        /// </summary>
        /// <param name="parentStage">A <see cref="parentStage" /> containing basic information about the event</param>
        protected SportEventSummaryDTO(parentStage parentStage)
        {
            Contract.Requires(parentStage != null);
            Contract.Requires(!string.IsNullOrEmpty(parentStage.id));

            Id        = URN.Parse(parentStage.id);
            Scheduled = parentStage.scheduledSpecified
                ? (DateTime?)parentStage.scheduled
                : null;
            ScheduledEnd = parentStage.scheduled_endSpecified
                ? (DateTime?)parentStage.scheduled_end
                : null;
            //URN sportId;
            //if (URN.TryParse(parentStage.tournament?.sport?.id, out sportId))
            //{
            //    SportId = sportId;
            //}
            Name = parentStage.name;
            SportEventType?type;

            if (RestMapperHelper.TryGetSportEventType(parentStage.type, out type))
            {
                Type = type;
            }
            if (!string.IsNullOrEmpty(parentStage.replaced_by))
            {
                URN replacedBy;
                if (URN.TryParse(parentStage.replaced_by, out replacedBy))
                {
                    ReplacedBy = replacedBy;
                }
            }

            StartTimeTbd = parentStage.start_time_tbdSpecified ? (bool?)parentStage.start_time_tbd : null;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BookmakerDetailsDTO"/> class
        /// </summary>
        /// <param name="msg">The MSG</param>
        /// <param name="serverTimeDifference">The server time difference</param>
        public BookmakerDetailsDTO(bookmaker_details msg, TimeSpan serverTimeDifference)
        {
            Guard.Argument(msg, nameof(msg)).NotNull();

            Id                   = msg.bookmaker_id;
            VirtualHost          = msg.virtual_host;
            Expires              = msg.expire_atSpecified ? (DateTime?)msg.expire_at : null;
            ResponseCode         = RestMapperHelper.MapResponseCode(msg.response_code, msg.response_codeSpecified);
            Message              = msg.message;
            ServerTimeDifference = serverTimeDifference;
        }
Ejemplo n.º 6
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="BookmakerDetailsDTO" /> class
        /// </summary>
        /// <param name="msg">The MSG</param>
        /// <param name="serverTimeDifference">The server time difference</param>
        public BookmakerDetailsDTO(bookmaker_details msg, TimeSpan serverTimeDifference)
        {
            Contract.Requires(msg != null);

            Id                   = msg.bookmaker_id;
            VirtualHost          = msg.virtual_host;
            Expires              = msg.expire_atSpecified ? (DateTime?)msg.expire_at : null;
            ResponseCode         = RestMapperHelper.MapResponseCode(msg.response_code, msg.response_codeSpecified);
            Message              = msg.message;
            ServerTimeDifference = serverTimeDifference;
        }
Ejemplo n.º 7
0
        internal CoverageInfoDTO(coverageInfo coverageInfo)
        {
            Guard.Argument(coverageInfo, nameof(coverageInfo)).NotNull();
            Guard.Argument(coverageInfo.level, nameof(coverageInfo.level)).NotNull().NotEmpty();

            Level    = coverageInfo.level;
            IsLive   = coverageInfo.live_coverage;
            Includes = coverageInfo.coverage != null && coverageInfo.coverage.Any()
                ? new ReadOnlyCollection <string>(coverageInfo.coverage.Select(c => c.includes).ToList())
                : null;
            RestMapperHelper.TryGetCoveredFrom(coverageInfo.covered_from, out var coveredFrom);
            CoveredFrom = coveredFrom;
        }
Ejemplo n.º 8
0
        protected CompetitionDTO(parentStage parentStage)
            : base(parentStage)
        {
            if (RestMapperHelper.TryGetSportEventType(parentStage.type, out var type))
            {
                Type = type;
            }

            //LiveOdds = null;

            if (RestMapperHelper.TryGetStageType(parentStage.stage_type, out var stageType))
            {
                StageType = stageType;
            }
        }
Ejemplo n.º 9
0
        internal CompetitionDTO(sportEventChildrenSport_event stageSummary)
            : base(stageSummary)
        {
            if (RestMapperHelper.TryGetSportEventType(stageSummary.type, out var type))
            {
                Type = type;
            }

            //LiveOdds = null;

            if (RestMapperHelper.TryGetStageType(stageSummary.stage_type, out var stageType))
            {
                StageType = stageType;
            }
        }
Ejemplo n.º 10
0
        internal CoverageInfoDTO(coverageInfo coverageInfo)
        {
            Contract.Requires(coverageInfo != null);
            Contract.Requires(!string.IsNullOrEmpty(coverageInfo.level));

            Level    = coverageInfo.level;
            IsLive   = coverageInfo.live_coverage;
            Includes = coverageInfo.coverage != null && coverageInfo.coverage.Any()
                ? new ReadOnlyCollection <string>(coverageInfo.coverage.Select(c => c.includes).ToList())
                : null;
            CoveredFrom?coveredFrom;

            RestMapperHelper.TryGetCoveredFrom(coverageInfo.covered_from, out coveredFrom);
            CoveredFrom = coveredFrom;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CompetitionDTO"/> class
        /// </summary>
        /// <param name="sportEvent">A <see cref="sportEvent"/> instance containing basic information about the sport event</param>
        internal CompetitionDTO(sportEvent sportEvent)
            : base(sportEvent)
        {
            if (RestMapperHelper.TryGetBookingStatus(sportEvent.liveodds, out var bookingStatus))
            {
                BookingStatus = bookingStatus;
            }

            if (sportEvent.competitors != null && sportEvent.competitors.Any())
            {
                Competitors         = new ReadOnlyCollection <TeamCompetitorDTO>(sportEvent.competitors.Select(c => new TeamCompetitorDTO(c)).ToList());
                HomeAwayCompetitors = RestMapperHelper.FillHomeAwayCompetitors(sportEvent.competitors);
            }

            Conditions = sportEvent.sport_event_conditions == null
                             ? null
                             : new SportEventConditionsDTO(sportEvent.sport_event_conditions);

            Venue = sportEvent.sport_event_conditions?.venue == null
                        ? null
                        : new VenueDTO(sportEvent.sport_event_conditions.venue);

            if (Venue == null && sportEvent.venue != null)
            {
                Venue = new VenueDTO(sportEvent.venue);
            }

            if (RestMapperHelper.TryGetSportEventType(sportEvent.type, out var type))
            {
                Type = type;
            }

            if (!string.IsNullOrEmpty(sportEvent.liveodds))
            {
                LiveOdds = sportEvent.liveodds;
            }

            if (RestMapperHelper.TryGetStageType(sportEvent.stage_type, out var stageType))
            {
                StageType = stageType;
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SportEventSummaryDTO"/> class
        /// </summary>
        /// <param name="sportEvent">A <see cref="sportEvent"/> containing basic information about the event</param>
        internal SportEventSummaryDTO(sportEvent sportEvent)
        {
            Guard.Argument(sportEvent, nameof(sportEvent)).NotNull();
            Guard.Argument(sportEvent.id, nameof(sportEvent.id)).NotNull().NotEmpty();

            Id        = URN.Parse(sportEvent.id);
            Scheduled = sportEvent.scheduledSpecified
                ? (DateTime?)sportEvent.scheduled.ToLocalTime()
                : null;
            ScheduledEnd = sportEvent.scheduled_endSpecified
                ? (DateTime?)sportEvent.scheduled_end.ToLocalTime()
                : null;
            if (sportEvent.tournament?.sport != null)
            {
                URN sportId;
                if (URN.TryParse(sportEvent.tournament.sport.id, out sportId))
                {
                    SportId = sportId;
                }
            }
            Name = sportEvent.name;
            SportEventType?type;

            if (RestMapperHelper.TryGetSportEventType(sportEvent.type, out type))
            {
                Type = type;
            }
            if (!string.IsNullOrEmpty(sportEvent.replaced_by))
            {
                URN replacedBy;
                if (URN.TryParse(sportEvent.replaced_by, out replacedBy))
                {
                    ReplacedBy = replacedBy;
                }
            }
            StartTimeTbd = sportEvent.start_time_tbdSpecified ? (bool?)sportEvent.start_time_tbd : null;

            StatusOnEvent = sportEvent.status;

            LiveOdds = sportEvent.liveodds;
        }
        /// <summary>
        ///     Initializes a new instance of the <see cref="SportEventSummaryDTO" /> class
        /// </summary>
        /// <param name="sportEvent">A <see cref="sportEvent" /> containing basic information about the event</param>
        internal SportEventSummaryDTO(sportEvent sportEvent)
        {
            Contract.Requires(sportEvent != null);
            Contract.Requires(!string.IsNullOrEmpty(sportEvent.id));

            Id        = URN.Parse(sportEvent.id);
            Scheduled = sportEvent.scheduledSpecified
                ? (DateTime?)sportEvent.scheduled
                : null;
            ScheduledEnd = sportEvent.scheduled_endSpecified
                ? (DateTime?)sportEvent.scheduled_end
                : null;
            if (sportEvent.tournament?.sport != null)
            {
                URN sportId;
                if (URN.TryParse(sportEvent.tournament.sport.id, out sportId))
                {
                    SportId = sportId;
                }
            }

            Name = sportEvent.name;
            SportEventType?type;

            if (RestMapperHelper.TryGetSportEventType(sportEvent.type, out type))
            {
                Type = type;
            }
            if (!string.IsNullOrEmpty(sportEvent.replaced_by))
            {
                URN replacedBy;
                if (URN.TryParse(sportEvent.replaced_by, out replacedBy))
                {
                    ReplacedBy = replacedBy;
                }
            }

            StartTimeTbd = sportEvent.start_time_tbdSpecified ? (bool?)sportEvent.start_time_tbd : null;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SportEventSummaryDTO"/> class
        /// </summary>
        /// <param name="childStage">A <see cref="sportEventChildrenSport_event"/> containing basic information about the event</param>
        protected SportEventSummaryDTO(sportEventChildrenSport_event childStage)
        {
            Guard.Argument(childStage, nameof(childStage)).NotNull();
            Guard.Argument(childStage.id, nameof(childStage.id)).NotNull().NotEmpty();

            Id        = URN.Parse(childStage.id);
            Scheduled = childStage.scheduledSpecified
                            ? (DateTime?)childStage.scheduled.ToLocalTime()
                            : null;
            ScheduledEnd = childStage.scheduled_endSpecified
                               ? (DateTime?)childStage.scheduled_end.ToLocalTime()
                               : null;
            //URN sportId;
            //if (URN.TryParse(childStage.tournament?.sport?.id, out sportId))
            //{
            //    SportId = sportId;
            //}
            Name = childStage.name;
            SportEventType?type;

            if (RestMapperHelper.TryGetSportEventType(childStage.type, out type))
            {
                Type = type;
            }
            if (!string.IsNullOrEmpty(childStage.replaced_by))
            {
                URN replacedBy;
                if (URN.TryParse(childStage.replaced_by, out replacedBy))
                {
                    ReplacedBy = replacedBy;
                }
            }
            StartTimeTbd = childStage.start_time_tbdSpecified ? (bool?)childStage.start_time_tbd : null;

            StatusOnEvent = null;

            LiveOdds = null;
        }