예제 #1
0
파일: Api.cs 프로젝트: paw-sad/Playground
        public ReleasePlayerResponse ReleasePlayer(ReleasePlayerRequest request)
        {
            if (!_currentUserId.HasValue)
            {
                throw new InvalidOperationException("No access");
            }

            var user = _usersService.GetUserById(new GetUserByIdRequest
            {
                UserId = _currentUserId.Value
            });

            var command = new TransfersModule.Contract.ReleasePlayerContract.Request()
            {
                ReleasingClubId = request.ReleasingClubId,
                EngagingClubId  = request.EngagingClubId,
                PlayerId        = request.PlayerId,
            };

            if (!AuthorizationService.CanExecuteCommand(user, command))
            {
                throw new InvalidOperationException("You can only release players only from your own club");
            }

            var response = new TransfersApi().Execute(command).Result;

            return(new ReleasePlayerResponse
            {
                TransferInstructionId = response.TransferInstructionId.Value
            });
        }
예제 #2
0
파일: Api.cs 프로젝트: paw-sad/Playground
        public EngageWithoutTransferAgreementResponse EngagePlayerWithoutTransferAgreement(EngageWithoutTransferAgreementRequest request)
        {
            if (!_currentUserId.HasValue)
            {
                throw new InvalidOperationException("No access");
            }

            var currentUser = _usersService.GetUserById(new GetUserByIdRequest
            {
                UserId = _currentUserId.Value
            });

            var command = new TransfersModule.Contract.EngageWithoutTransferAgreement.Request
            {
                ReleasingClubId = request.ReleasingClubId,
                PlayerId        = request.PlayerId,
                EngagingClubId  = request.EngagingClubId,
            };

            if (!AuthorizationService.CanExecuteCommand(currentUser, command))
            {
                throw new InvalidOperationException("You can only engage players for your own club");
            }

            var response = new TransfersApi().Execute(command).Result;

            return(new EngageWithoutTransferAgreementResponse
            {
                TransferId = response.TransferId
            });
        }
        public async Task TestTransferWithNoPayments()
        {
            var request = new EngageWithoutTransferAgreement.Request
            {
                ReleasingClubId = 1,
                EngagingClubId  = 2,
                PlayerId        = 1,
                PlayersContract = new PlayersContract
                {
                    EmploymentContractStart = new DateTime(2020, 01, 01),
                    EmploymentContractEnd   = new DateTime(2021, 01, 01),
                    Salary = new NoSalary()
                }
            };

            var api = new TransfersApi();
            // when engaging player without transfer agreement and no payments
            var response = await api.Execute(request);

            // then i should get new completed transfer
            var transfer = await api.Execute(new GetTransferByIdContract.Request
            {
                Id = response.TransferId
            });

            transfer.State.ShouldBe(TransferState.Completed);
        }
        public void UserServiceContructor_ShouldReturnTheObject()
        {
            // Arrange:
            _loggerMock = new Mock <ILogger <TransfersApi> >();
            var authServiceMock = new Mock <IAuthApi>();
            var config          = GetConfiguration();

            // Act:
            _objectToTest = new TransfersApi(config, _loggerMock.Object, authServiceMock.Object);
            // Assert:
            Assert.NotNull(_objectToTest);
        }
        public TransfersApiTests()
        {
            // Arrange:
            var services      = new ServiceCollection();
            var configuration = TestHelper.GetIConfigurationRoot();

            // Act:
            services.AddMangoPayServices(configuration);
            var provider = services.BuildServiceProvider();

            _objectToTest = provider.GetRequiredService <ITransfersApi>() as TransfersApi;
        }
예제 #6
0
        public FlutterwaveApi(string apiKey)
        {
            _apiKey = apiKey;
            _flutterwaveApiBaseUrl = new Uri("https://api.flutterwave.com/v3/");

            Card          = new CardPaymentApi(this);
            Transactions  = new TransactionsApi(this);
            Verifications = new VerificationApi(this);
            Banks         = new BanksApi(this);
            Bills         = new BillsApi(this);
            Settlements   = new SettlementsApi(this);
            Otps          = new OtpsApi(this);
            Chargebacks   = new ChargebacksApi(this);
            Misc          = new MiscApi(this);
            Transfers     = new TransfersApi(this);
        }
예제 #7
0
 public void Init()
 {
     instance = new TransfersApi();
 }