public async Task CreateDisbursement_ReturnsSuccess() { var connectionMock = new Mock <IXenditHttpConnection>(); connectionMock .Setup(c => c.SendRequestBodyAsync <XenditBaseRequest, XenditDisbursementCreateResponse>( It.IsAny <Method>(), It.IsAny <string>(), It.IsAny <XenditBaseRequest>(), It.IsAny <string>())) .ReturnsAsync(new XenditDisbursementCreateResponse()); var disbursementClient = new XenditDisbursementClient(connectionMock.Object); var requestedDisbursement = new XenditDisbursementCreateRequest { ExternalId = "Test_Disb_1234" }; var disb = await disbursementClient.CreateAsync(requestedDisbursement); connectionMock.Verify(c => c.SendRequestBodyAsync <XenditDisbursementCreateRequest, XenditDisbursementCreateResponse>( Method.POST, "/disbursements", requestedDisbursement, requestedDisbursement.ExternalId), Times.Once); }
public async Task GetAvailableBanks_ReturnsSuccess() { var connectionMock = new Mock <IXenditHttpConnection>(); connectionMock .Setup(c => c.SendRequestAsync <IEnumerable <XenditDisbursementBank> >( It.IsAny <Method>(), It.IsAny <string>())) .ReturnsAsync(new List <XenditDisbursementBank>()); var disbursementClient = new XenditDisbursementClient(connectionMock.Object); var availableBanks = await disbursementClient.GetAvailableBanksAsync(); connectionMock.Verify(c => c.SendRequestAsync <IEnumerable <XenditDisbursementBank> >( Method.GET, "/available_disbursements_banks"), Times.Once); }
public async Task GetDisbursementByExternalId_ReturnsSuccess() { var disbExternalId = "Test:Disb:1234:EnternId:Get"; var connectionMock = new Mock <IXenditHttpConnection>(); connectionMock .Setup(c => c.SendRequestAsync <XenditDisbursementCreateResponse>( It.IsAny <Method>(), It.IsAny <string>())) .ReturnsAsync(new XenditDisbursementCreateResponse()); var disbursementClient = new XenditDisbursementClient(connectionMock.Object); var availableBanks = await disbursementClient.GetByExternalIdAsync(disbExternalId); connectionMock.Verify(c => c.SendRequestAsync <XenditDisbursementCreateResponse>( Method.GET, $"/disbursements?external_id={disbExternalId}"), Times.Once); }
public XenditClient(string apiKey) { if (string.IsNullOrWhiteSpace(apiKey)) { throw new ArgumentNullException(nameof(apiKey)); } Configuration = new XenditConfiguration { ApiKey = apiKey }; BaseUrl = Configuration.BaseUrl; var connection = new XenditHttpConnection(Configuration); SecurityVerificator = new XenditSecurityVerificator(Configuration); VirtualAccount = new XenditVAClient(connection); Invoice = new XenditInvoiceClient(connection); Disbursement = new XenditDisbursementClient(connection); EWallet = new XenditEWalletClient(connection); }