Example #1
0
        private void HandleTicketResponse(ITicketResponse ticket)
        {
            _log.Info($"Ticket '{ticket.TicketId}' response is {ticket.Status}. Reason={ticket.Reason?.Message}");

            if (ticket.BetDetails != null && ticket.BetDetails.Any())
            {
                foreach (var betDetail in ticket.BetDetails)
                {
                    _log.Info($"Bet decline reason: '{betDetail.Reason?.Message}'.");
                    if (betDetail.SelectionDetails != null && betDetail.SelectionDetails.Any())
                    {
                        foreach (var selectionDetail in betDetail.SelectionDetails)
                        {
                            _log.Info($"Selection decline reason: '{selectionDetail.Reason?.Message}'.");
                        }
                    }
                }
            }

            if (ticket.Status == TicketAcceptance.Accepted)
            {
                //required only if 'explicit acking' is enabled in MTS admin
                ticket.Acknowledge();

                // handle ticket response

                //if for some reason we want to cancel ticket, this is how we can do it
                var ticketCancel = _factory.CreateTicketCancelBuilder().SetTicketId(ticket.TicketId).SetCode(TicketCancellationReason.BookmakerTechnicalIssue).BuildTicket();
                _mtsSdk.SendTicket(ticketCancel);
            }
        }
Example #2
0
        private void HandleTicketResponse(ITicketResponse ticketResponse)
        {
            _log.Info($"Ticket '{ticketResponse.TicketId}' response is {ticketResponse.Status}. Reason={ticketResponse.Reason?.Message}");
            if (ticketResponse.Status == TicketAcceptance.Accepted)
            {
                //required only if 'explicit acking' is enabled in MTS admin
                ticketResponse.Acknowledge();

                // handle ticket response

                //if for some reason we want to cancel ticket, this is how we can do it
                var ticketCancel = _factory.CreateTicketCancelBuilder().SetTicketId(ticketResponse.TicketId).SetCode(TicketCancellationReason.BookmakerTechnicalIssue).BuildTicket();
                _mtsSdk.SendTicket(ticketCancel);
            }
            else
            {
                // if the ticket was declined and response has reoffer, the reoffer or reoffer cancellation can be send
                // the reoffer or reoffer cancellation must be send before predefined timeout, or is automatically canceled
                if (ticketResponse.BetDetails.Any(a => a.Reoffer != null))
                {
                    if (ReofferShouldBeAccepted())
                    {
                        // ReSharper disable once RedundantArgumentDefaultValue
                        var reofferTicket = _factory.CreateTicketReofferBuilder().Set(_originalTicket, ticketResponse, null).BuildTicket();
                        _mtsSdk.SendTicket(reofferTicket);
                    }
                    else
                    {
                        var reofferCancel = _factory.CreateTicketReofferCancelBuilder().SetTicketId(ticketResponse.TicketId).BuildTicket();
                        _mtsSdk.SendTicket(reofferCancel);
                    }
                }
            }
        }
Example #3
0
 public static ITicketCancel GetTicketCancel(string ticketId = null)
 {
     if (string.IsNullOrEmpty(ticketId))
     {
         ticketId = "ticket-" + SR.I1000P;
     }
     return(BuilderFactory.CreateTicketCancelBuilder().SetTicketId(ticketId).SetBookmakerId(SR.I1000).SetCode(TicketCancellationReason.BookmakerBackofficeTriggered).BuildTicket());
 }
Example #4
0
        public void Run()
        {
            _log.Info("Running the MTS SDK Basic example");

            _log.Info("Retrieving configuration from application configuration file");
            var config = MtsSdk.GetConfiguration();

            _log.Info("Creating root MTS SDK instance");
            _mtsSdk = new MtsSdk(config);

            _log.Info("Attaching to events");
            AttachToFeedEvents(_mtsSdk);

            _log.Info("Opening the sdk instance (creating and opening connection to the AMPQ broker)");
            _mtsSdk.Open();
            _factory = _mtsSdk.BuilderFactory;

            // create ticket (in order to be accepted, correct values must be entered)
            // values below are just for demonstration purposes and will not be accepted
            var r      = new Random();
            var ticket = _factory.CreateTicketBuilder()
                         .SetTicketId("ticketId-" + r.Next())
                         .SetSender(_factory.CreateSenderBuilder()
                                    .SetCurrency("EUR")
                                    .SetEndCustomer(_factory.CreateEndCustomerBuilder()
                                                    .SetId("customerClientId-" + r.Next())
                                                    .SetConfidence(1)
                                                    .SetIp(IPAddress.Loopback)
                                                    .SetLanguageId("en")
                                                    .SetDeviceId("UsersDevice-" + r.Next())
                                                    .Build())
                                    .Build())
                         .AddBet(_factory.CreateBetBuilder()
                                 .SetBetId("betId-" + r.Next())
                                 .SetBetBonus(1)
                                 .SetStake(15000, StakeType.Total)
                                 .AddSelectedSystem(1)
                                 .AddSelection(_factory.CreateSelectionBuilder()
                                               .SetEventId("1")
                                               .SetIdUof(3, $"sr:match:{r.Next()}", 12, "1", string.Empty, null)
                                               .SetOdds(11000)
                                               .Build())
                                 .Build())
                         .BuildTicket();

            // send ticket to the MTS. Since this is a blocking way of sending, the response will be result of the method (no event handler will be raised)
            _log.Info("Send ticket to the MTS and wait for the response.");
            var ticketResponse = _mtsSdk.SendTicketBlocking(ticket);

            _log.Info($"TicketResponse received. Status={ticketResponse.Status}, Reason={ticketResponse.Reason.Message}.");

            if (ticketResponse.Status == TicketAcceptance.Accepted)
            {
                //required only if 'explicit acking' is enabled in MTS admin
                ticketResponse.Acknowledge();

                //if for some reason we want to cancel ticket, this is how we can do it
                var ticketCancel         = _factory.CreateTicketCancelBuilder().BuildTicket(ticket.TicketId, ticket.Sender.BookmakerId, TicketCancellationReason.BookmakerTechnicalIssue);
                var ticketCancelResponse = _mtsSdk.SendTicketCancelBlocking(ticketCancel);

                _log.Info($"Ticket '{ticket.TicketId}' response is {ticketCancelResponse.Status}. Reason={ticketCancelResponse.Reason?.Message}");
                if (ticketCancelResponse.Status == TicketCancelAcceptance.Cancelled)
                {
                    //mandatory for all cancellations, except for TimeOutTriggered cancellation
                    ticketCancelResponse.Acknowledge();
                }
            }

            _log.Info("Example successfully executed. Hit <enter> to quit");
            Console.WriteLine(string.Empty);
            Console.ReadLine();

            _log.Info("Detaching from events");
            DetachFromFeedEvents(_mtsSdk);

            _log.Info("Closing the connection and disposing the instance");
            _mtsSdk.Close();


            _log.Info("Example stopped");
        }