/// <summary> /// Initializes a new instance of the <see cref="TicketCashout"/> class /// </summary> /// <param name="ticketId">The ticket identifier</param> /// <param name="bookmakerId">The bookmaker identifier</param> /// <param name="stake">The cashout stake</param> /// <param name="percent">The cashout percent</param> /// <param name="betCashouts">The list of <see cref="IBetCashout"/></param> public TicketCashout(string ticketId, int bookmakerId, long?stake, int?percent, IReadOnlyCollection <IBetCashout> betCashouts) { Guard.Argument(ticketId).Require(TicketHelper.ValidateTicketId(ticketId)); Guard.Argument(bookmakerId, nameof(bookmakerId)).Positive(); Guard.Argument(stake, nameof(stake)).Require(stake >= 0 || percent >= 0 || (betCashouts != null && betCashouts.Any())); if (percent != null && stake == null) { throw new ArgumentException("If percent is set, also stake must be."); } if (betCashouts != null && (stake != null || percent != null)) { throw new ArgumentException("Stake and/or Percent cannot be set at the same time as BetCashouts."); } TicketId = ticketId; BookmakerId = bookmakerId; CashoutStake = stake; CashoutPercent = percent; BetCashouts = betCashouts; Timestamp = DateTime.UtcNow; Version = TicketHelper.MtsTicketVersion; CorrelationId = TicketHelper.GenerateTicketCorrelationId(); }
/// <summary> /// Initializes a new instance of the <see cref="TicketCancel"/> class /// </summary> /// <param name="ticketId">The ticket identifier</param> /// <param name="bookmakerId">The bookmaker identifier</param> public TicketReofferCancel(string ticketId, int bookmakerId) { Guard.Argument(ticketId, nameof(ticketId)).Require(TicketHelper.ValidateTicketId(ticketId)); Guard.Argument(bookmakerId, nameof(bookmakerId)).Positive(); TicketId = ticketId; BookmakerId = bookmakerId; Timestamp = DateTime.UtcNow; Version = TicketHelper.MtsTicketVersion; CorrelationId = TicketHelper.GenerateTicketCorrelationId(); }
/// <summary> /// Initializes a new instance of the <see cref="TicketCancelAck"/> class /// </summary> /// <param name="ticket">The ticket</param> /// <param name="status">The status</param> /// <param name="code">The code</param> /// <param name="message">The message</param> public TicketCancelAck(ITicketCancel ticket, TicketCancelAckStatus status, int code, string message) { Guard.Argument(ticket, nameof(ticket)).NotNull(); TicketId = ticket.TicketId; BookmakerId = ticket.BookmakerId; Code = code; TicketCancelStatus = status; Message = message; Timestamp = DateTime.UtcNow; Version = TicketHelper.MtsTicketVersion; CorrelationId = TicketHelper.GenerateTicketCorrelationId(); }
/// <summary> /// Initializes a new instance of the <see cref="ITicketNonSrSettle"/> class /// </summary> /// <param name="ticketId">The ticket identifier</param> /// <param name="bookmakerId">The bookmaker identifier</param> /// <param name="stake">The non-sportradar settle stake</param> public TicketNonSrSettle(string ticketId, int bookmakerId, long stake) { Guard.Argument(ticketId, nameof(ticketId)).Require(TicketHelper.ValidateTicketId(ticketId)); Guard.Argument(bookmakerId, nameof(bookmakerId)).Positive(); Guard.Argument(stake, nameof(stake)).NotNegative(); TicketId = ticketId; BookmakerId = bookmakerId; NonSrSettleStake = stake; Timestamp = DateTime.UtcNow; Version = TicketHelper.MtsTicketVersion; CorrelationId = TicketHelper.GenerateTicketCorrelationId(); }
/// <summary> /// Initializes a new instance of the <see cref="TicketCancelAck"/> class /// </summary> /// <param name="ticketId">The ticket identifier</param> /// <param name="bookmakerId">The bookmaker identifier</param> /// <param name="status">The status</param> /// <param name="code">The code</param> /// <param name="message">The message</param> public TicketCancelAck(string ticketId, int bookmakerId, TicketCancelAckStatus status, int code, string message) { Guard.Argument(ticketId, nameof(ticketId)).Require(TicketHelper.ValidateTicketId(ticketId)); Guard.Argument(bookmakerId, nameof(bookmakerId)).Positive(); TicketId = ticketId; BookmakerId = bookmakerId; Code = code; TicketCancelStatus = status; Message = message; Timestamp = DateTime.Now; Version = TicketHelper.MtsTicketVersion; CorrelationId = TicketHelper.GenerateTicketCorrelationId(); }
/// <summary> /// Initializes a new instance of the <see cref="Ticket"/> class /// </summary> /// <param name="ticketId">The ticket identifier</param> /// <param name="sender">The sender</param> /// <param name="bets">The bets</param> /// <param name="reofferId">The reoffer identifier</param> /// <param name="altStakeRefId">The alt stake reference identifier</param> /// <param name="isTestSource">if set to <c>true</c> [is test source]</param> /// <param name="oddsChangeType">Type of the odds change</param> /// <exception cref="ArgumentException">Only ReofferId or AltStakeRefId can specified</exception> /// <param name="totalCombinations">Expected total number of generated combinations on this ticket (optional, default null). If present is used to validate against actual number of generated combinations</param> /// <param name="lastMatchEndTime">End time of last (non Sportradar) match on ticket.</param> public Ticket(string ticketId, ISender sender, IEnumerable <IBet> bets, string reofferId, string altStakeRefId, bool isTestSource, OddsChangeType?oddsChangeType, int?totalCombinations, DateTime?lastMatchEndTime) { Guard.Argument(ticketId, nameof(ticketId)).Require(TicketHelper.ValidateTicketId(ticketId)); Guard.Argument(sender, nameof(sender)).NotNull(); Guard.Argument(bets, nameof(bets)).NotNull(); if (!bets.Any()) { throw new ArgumentOutOfRangeException(nameof(bets)); } Guard.Argument(bets, nameof(bets)).Require(bets.Count() <= 50); Guard.Argument(reofferId, nameof(reofferId)).Require(string.IsNullOrEmpty(reofferId) || TicketHelper.ValidateTicketId(reofferId)); Guard.Argument(altStakeRefId, nameof(altStakeRefId)).Require(string.IsNullOrEmpty(altStakeRefId) || TicketHelper.ValidateTicketId(altStakeRefId)); Guard.Argument(reofferId, nameof(reofferId)).Require(!(!string.IsNullOrEmpty(reofferId) && !string.IsNullOrEmpty(altStakeRefId))); Guard.Argument(totalCombinations, nameof(totalCombinations)).Require(totalCombinations == null || totalCombinations > 0); Guard.Argument(lastMatchEndTime, nameof(lastMatchEndTime)).Require(lastMatchEndTime == null || lastMatchEndTime > new DateTime(2000, 1, 1)); TicketId = ticketId; Sender = sender; Bets = bets as IReadOnlyList <IBet>; ReofferId = reofferId; AltStakeRefId = altStakeRefId; TestSource = isTestSource; OddsChange = oddsChangeType; Timestamp = DateTime.UtcNow; Version = TicketHelper.MtsTicketVersion; CorrelationId = TicketHelper.GenerateTicketCorrelationId(); LastMatchEndTime = lastMatchEndTime; if (!string.IsNullOrEmpty(reofferId) && !string.IsNullOrEmpty(altStakeRefId)) { throw new ArgumentException("Only ReofferId or AltStakeRefId can be specified, not both."); } if (Bets != null) { var selections = new List <ISelection>(); foreach (var bet in Bets) { selections.AddRange(bet.Selections); } Guard.Argument(selections, nameof(selections)).NotNull(); if (!selections.Any()) { throw new ArgumentOutOfRangeException(nameof(bets), "At least one bet is missing selections."); } Selections = selections.Distinct(); } TotalCombinations = totalCombinations; }
/// <summary> /// Initializes a new instance of the <see cref="TicketCancel"/> class /// </summary> /// <param name="ticketId">The ticket identifier</param> /// <param name="bookmakerId">The bookmaker identifier</param> /// <param name="code">The code</param> /// <param name="percent">The percent of ticket to cancel</param> /// <param name="betCancels">The list of <see cref="IBetCancel"/></param> public TicketCancel(string ticketId, int bookmakerId, TicketCancellationReason code, int?percent, IReadOnlyCollection <IBetCancel> betCancels) { Guard.Argument(ticketId, nameof(ticketId)).Require(TicketHelper.ValidateTicketId(ticketId)); Guard.Argument(bookmakerId, nameof(bookmakerId)).Positive(); Guard.Argument(percent, nameof(percent)).Require(TicketHelper.ValidatePercent(percent)); Guard.Argument(betCancels, nameof(betCancels)).Require(betCancels == null || betCancels.Any()); if (percent != null && betCancels != null) { throw new ArgumentException("Percent and BetCancels cannot be set at the same time."); } TicketId = ticketId; BookmakerId = bookmakerId; Code = code; Timestamp = DateTime.UtcNow; Version = TicketHelper.MtsTicketVersion; CorrelationId = TicketHelper.GenerateTicketCorrelationId(); CancelPercent = percent; BetCancels = betCancels; }