예제 #1
0
        public void BuildTicketAckFromTicketTest()
        {
            var ticketBuilder = _builderFactory.CreateTicketBuilder();
            var senderBuilder = _builderFactory.CreateSenderBuilder().SetBookmakerId(9985).SetLimitId(10).SetCurrency("EUR").SetSenderChannel(SenderChannel.Terminal);

            var ticket = ticketBuilder
                         .SetTicketId("ticket-" + new Random().Next(10000)).SetOddsChange(OddsChangeType.Any)
                         .SetSender(senderBuilder.SetEndCustomer(
                                        _builderFactory.CreateEndCustomerBuilder().SetId("customer-client-" + SR.I1000).SetConfidence(12039203).SetLanguageId("en").Build())
                                    .SetShopId(SR.S1000)
                                    .SetTerminalId(SR.S1000)
                                    .Build())
                         .AddBet(BetBuilder.Create().AddSelectedSystem(1).SetBetId("bet-id-" + SR.I1000).SetBetBonus(SR.I1000).SetStake(92343, StakeType.Total)
                                 .AddSelection(_builderFactory.CreateSelectionBuilder().SetEventId(9691139).SetIdLcoo(324, 1, "", "1").SetOdds(16000).SetBanker(true).Build())
                                 .Build())
                         .BuildTicket();

            var ticketAck = new TicketAck(ticket, TicketAckStatus.Accepted, 100, "message");

            Assert.IsNotNull(ticketAck);
            Assert.IsTrue(ticketAck.Timestamp > DateTime.Today.ToUniversalTime());
            Assert.AreEqual(TicketHelper.MtsTicketVersion, ticketAck.Version);
            Assert.IsTrue(!string.IsNullOrEmpty(ticketAck.TicketId));
            Assert.AreEqual(ticketAck.TicketId, ticket.TicketId);
            Assert.AreEqual(ticket.Sender.BookmakerId, ticketAck.BookmakerId);
        }
예제 #2
0
        public static void Init(TestContext context)
        {
            var configuration = new SdkConfigurationInternal(new SdkConfiguration("user", "pass", "host", "vhost", false, "sslServerName", 5, 12, 17, "GBP", SenderChannel.Mobile), null);

            _builderFactory = new BuilderFactoryHelper(configuration).BuilderFactory;
            _endCustomer    = _builderFactory.CreateEndCustomerBuilder().SetId("customerId").SetIp(IPAddress.Loopback).SetDeviceId("deviceId").SetLanguageId("si").Build();
        }
예제 #3
0
        public void CheckNoEndCustomerConfidenceTest()
        {
            var endCustomer = _builderFactory.CreateEndCustomerBuilder()
                              .SetId("customer-client-" + SR.I1000)
                              .SetIp(IPAddress.Loopback)
                              .SetLanguageId("en")
                              .SetDeviceId("123")
                              .Build();
            var ticketBuilder = TicketBuilderHelper.GetTicketBuilder(null, endCustomer, 5, 10);

            var ticket = ticketBuilder.BuildTicket();
            var dto    = new TicketMapper().Map(ticket);
            var json   = dto.ToJson();

            CheckRequiredFields(json);

            Assert.IsTrue(!json.Contains("confidence"));
        }
예제 #4
0
 public void Init()
 {
     _builderFactory = new BuilderFactoryHelper().BuilderFactory;
     _senderBuilder  = _builderFactory.CreateSenderBuilder().SetBookmakerId(9985).SetLimitId(90).SetCurrency("EUR").SetSenderChannel(SenderChannel.Internet);
     _sender         = _senderBuilder.SetEndCustomer(_builderFactory.CreateEndCustomerBuilder()
                                                     .SetId("customer-client-" + SR.I1000)
                                                     .SetConfidence(12039203)
                                                     .SetIp(IPAddress.Loopback)
                                                     .SetLanguageId("en")
                                                     .SetDeviceId("123")
                                                     .Build())
                       .Build();
 }
예제 #5
0
        public static ITicket GetTicket(string ticketId = null, int bookmakerId = 0, int betCount = 1, int selectionCount = 1)
        {
            var tb = BuilderFactory.CreateTicketBuilder();

            if (string.IsNullOrEmpty(ticketId))
            {
                ticketId = "ticket-" + SR.I1000P;
            }
            if (bookmakerId < 1)
            {
                bookmakerId = SR.I1000P;
            }
            if (betCount < 1)
            {
                betCount = 1;
            }
            if (selectionCount < 1)
            {
                selectionCount = 1;
            }
            for (var i = 0; i < betCount; i++)
            {
                var betBuilder = BuilderFactory.CreateBetBuilder();
                for (var j = 0; j < selectionCount; j++)
                {
                    betBuilder.AddSelection(BuilderFactory.CreateSelectionBuilder().SetEventId(SR.S1000P).SetIdLcoo(SR.I1000, 1, "", "1").SetOdds(SR.I1000P).SetBanker(SR.I100 > 90).Build());
                }

                var bet = betBuilder
                          .AddSelectedSystem(1)
                          .SetBetId("bet-id-" + SR.I1000)
                          .SetBetBonus(SR.I1000)
                          .SetStake(92343, StakeType.Total)
                          .Build();
                tb.AddBet(bet);
            }
            var ticket = tb.SetTicketId(ticketId).SetOddsChange(OddsChangeType.Any)
                         .SetSender(BuilderFactory.CreateSenderBuilder().SetBookmakerId(bookmakerId).SetLimitId(SR.I100).SetCurrency("EUR").SetSenderChannel(SenderChannel.Internet)
                                    .SetEndCustomer(BuilderFactory.CreateEndCustomerBuilder().SetId("customer-client-" + SR.I1000).SetConfidence(SR.I1000P).SetIp(IPAddress.Loopback).SetLanguageId("en").SetDeviceId(SR.S1000).Build())
                                    .Build())
                         .SetTotalCombinations(tb.GetBets().Count())
                         .BuildTicket();

            return(ticket);
        }
예제 #6
0
        public void Run()
        {
            _log.LogInformation("Running the MTS SDK cashout example");

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

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

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

            _log.LogInformation("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

            //cashout ticket is available only for live events
            var r = new Random();

            _originalTicket = _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(123450000, StakeType.Total)
                                      .AddSelectedSystem(1)
                                      .AddSelection(_factory.CreateSelectionBuilder()
                                                    .SetEventId("1")
                                                    .SetIdUof(1, $"sr:match:{r.Next()}", 1, "1", string.Empty, null)
                                                    .SetOdds(11000)
                                                    .Build())
                                      .Build())
                              .BuildTicket();

            // send ticket to the MTS. Since this is a non-blocking way of sending, the response will raise the event TicketResponseReceived
            _log.LogInformation("Send ticket to the MTS.");
            _mtsSdk.SendTicket(_originalTicket);

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

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

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

            _log.LogInformation("Example stopped");
        }
예제 #7
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");
        }
예제 #8
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 bet = _factory.CreateBetBuilder()
                      .SetBetId("betId-" + r.Next())
                      .SetBetBonus(1)
                      .SetStake(11200, StakeType.Total)
                      .AddSelectedSystem(1)
                      .AddSelection(_factory.CreateSelectionBuilder()
                                    .SetEventId("1")
                                    .SetIdUof(3, $"sr:match:{r.Next()}", 12, "1", string.Empty, null) // only one of the following is required to set selectionId (if you use this method, config property 'accessToken' must be provided)
                                    .SetIdLo(1, 1, "1:1", "1")
                                    .SetIdLcoo(1, 1, "1:1", "1")
                                    .SetId("lcoo:409/1/*/YES")
                                    .SetOdds(11000)
                                    .Build())
                      .Build();
            var endCustomer = _factory.CreateEndCustomerBuilder()
                              .SetId("customerClientId-" + r.Next())
                              .SetConfidence(1)
                              .SetIp(IPAddress.Loopback)
                              .SetLanguageId("en")
                              .SetDeviceId("UsersDevice-" + r.Next())
                              .Build();
            var ticket = _factory.CreateTicketBuilder()
                         .SetTicketId("ticketId-" + r.Next())
                         .SetSender(_factory.CreateSenderBuilder()
                                    .SetCurrency("EUR")
                                    .SetEndCustomer(endCustomer)
                                    .Build())
                         .AddBet(bet)
                         .BuildTicket();

            // send ticket to the MTS. Since this is a non-blocking way of sending, the response will come on the event TicketResponseReceived
            _log.Info("Send ticket to the MTS.");
            _log.Info(ticket.ToJson());
            _mtsSdk.SendTicket(ticket);

            _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");
        }
예제 #9
0
        public ITicket GenerateNewTicket(Ticket objTicket)
        {
            if (objTicket != null)
            {
                //ticket object creation
                var preTicket = _factory.CreateTicketBuilder()
                                .SetTicketId("NetbetTicket_" + objTicket.ticketId)
                                .SetSender(_factory.CreateSenderBuilder()
                                           .SetCurrency(objTicket.currencyCode)
                                           .SetEndCustomer(_factory.CreateEndCustomerBuilder()
                                                           .SetId("NetbetUserId_" + objTicket.customerClientId)
                                                           //.SetConfidence(10000)  //optional
                                                           //.SetIp(IPAddress.Loopback) //optional
                                                           .SetLanguageId(_languageCode)
                                                           //.SetDeviceId("UsersDeviceId-") //optional
                                                           .Build())
                                           .Build());

                //bets iteration
                var betBonus = Convert.ToInt64(objTicket.betBonus * seed);
                var betStack = objTicket.betStack * seed;
                if (objTicket.betType == (int)BetType.S || objTicket.betType == (int)BetType.M)
                {
                    //calculating selectedSystem for singles and multiples
                    objTicket.selectedSystem.Add(objTicket.Selections.Count);
                }
                else if (objTicket.betType == (int)BetType.I)
                {
                    //calculating selectedSystem for integrals
                    objTicket.selectedSystem.Add(objTicket.numberSelection);
                }

                //creating single bet object
                var preBet = _factory.CreateBetBuilder()
                             .SetBetId("NetbetBetId_" + objTicket.ticketId)
                             .SetStake(Convert.ToInt64(betStack), StakeType.Total);
                //bet bonus
                if (betBonus > 0)
                {
                    preBet.SetBetBonus(betBonus);
                }

                //setting selected System
                foreach (var selectedSystem in objTicket.selectedSystem)
                {
                    preBet.AddSelectedSystem((int)selectedSystem);
                }

                //setting ticket selections
                foreach (var s in objTicket.Selections)
                {
                    //determining the producer
                    //var producer = 0;
                    //if (s.producerId == Producer.O.ToString())
                    //    producer = (int)Producer.O;
                    //else if (s.producerId == Producer.L.ToString())
                    //    producer = (int)Producer.L;

                    if (s.producerId == 0) //is pre-match
                    {
                        s.producerId = (int)Producer.L;
                    }
                    else
                    {
                        s.producerId = (int)Producer.O;
                    }

                    var eventId     = "sr:match:" + s.matchId.ToString();
                    var selectionId = string.Format("uof:{0}/sr:sport:{1}/{2}/{3}", s.producerId, s.sportId, s.marketId, s.specId);
                    if (s.specifiers != null && s.specifiers != "" && s.spread != null && s.spread != "")
                    {
                        if (s.specifiers.Contains('|'))
                        {
                            string[] specifierList = s.specifiers.Split('|');
                            int      counter       = 0;
                            foreach (var specif in specifierList)
                            {
                                //int len = specif.Length - 7;
                                if (counter == 0)
                                {
                                    selectionId += string.Format("?{0}={1}", specif /*.Substring(6, len)*/, s.spread);
                                }
                                else
                                {
                                    selectionId += string.Format("&{0}={1}", specif /*.Substring(6, len)*/, s.spread);
                                }
                                counter += 1;
                            }
                        }
                        else
                        {
                            //int len = s.specifiers.Length - 7;
                            selectionId += string.Format("?{0}={1}", s.specifiers /*.Substring(6, len)*/, s.spread);
                        }
                    }
                    var odds = Convert.ToInt32(s.odd * seed);

                    //creating single selection
                    var selection = _factory.CreateSelectionBuilder()
                                    .SetEventId(eventId)
                                    .SetId(selectionId)
                                    .SetOdds(odds)
                                    .Build();
                    //adding selection to the bet
                    preBet.AddSelection(selection);
                }

                //building the bet after adding all selections
                var bet = preBet.Build();

                //adding bet to the ticket object
                preTicket.AddBet(bet);

                //building the ticket after adding all bets
                var ticket = preTicket.BuildTicket();
                return(ticket);
            }
            else
            {
                return(null);
            }
        }