public void RevokeUserFromMerhant_Success() { App createdApp = _appService.CreateApp(new CreateAppRequest()).Content; IPaylikeMerchantService merchantService = new PaylikeMerchantService(createdApp.Key); Merchant createdMerchant = merchantService.CreateMerchant(_createMerchantRequest).Content; merchantService.InviteUserToMerchant(new InviteUserToMerchantRequest() { MerchantId = createdMerchant.Id, Email = "*****@*****.**" }); var merchantUsers = merchantService.GetMerchantUsers(new GetMerchantUsersRequest() { MerchantId = createdMerchant.Id, Limit = 5 }); var revokeResponse = merchantService.RevokeUserFromMerchant(new RevokeUserFromMerchantRequest() { MerchantId = createdMerchant.Id, UserId = merchantUsers.Content[0].Id }); Assert.IsNull(revokeResponse.Content); Assert.IsFalse(revokeResponse.IsError); Assert.AreEqual(204, revokeResponse.ResponseCode); }
public void RevokeAppFromMerchant_Success() { App createdApp = _appService.CreateApp(new CreateAppRequest()).Content; _appService.SetApiKey(createdApp.Key); IPaylikeMerchantService merchantService = new PaylikeMerchantService(createdApp.Key); Merchant merchant = merchantService.CreateMerchant(_createMerchantRequest).Content; AddAppToMerchantRequest addRequest = new AddAppToMerchantRequest() { MerchantId = merchant.Id, AppId = createdApp.Id }; merchantService.AddAppToMerchant(addRequest); var revokeResponse = merchantService.RevokeAppFromMerchant(new RevokeAppFromMerchantRequest() { MerchantId = merchant.Id, AppId = createdApp.Id }); Assert.IsNull(revokeResponse.Content); Assert.IsFalse(revokeResponse.IsError); Assert.AreEqual(204, revokeResponse.ResponseCode); }
public void CreateMerchant_Success() { App createdApp = _appService.CreateApp(new CreateAppRequest()).Content; IPaylikeMerchantService merchantService = new PaylikeMerchantService(createdApp.Key); ApiResponse <Merchant> merchant = merchantService.CreateMerchant(_createMerchantRequest); Assert.AreEqual(201, merchant.ResponseCode); Assert.IsFalse(string.IsNullOrEmpty(merchant.Content.Id)); }
public void GetMerchantApps_Success() { App createdApp = _appService.CreateApp(new CreateAppRequest()).Content; _appService.SetApiKey(createdApp.Key); IPaylikeMerchantService merchantService = new PaylikeMerchantService(createdApp.Key); Merchant merchant = merchantService.CreateMerchant(_createMerchantRequest).Content; for (int i = 0; i < 4; i++) { createdApp = _appService.CreateApp(new CreateAppRequest()).Content; merchantService.AddAppToMerchant(new AddAppToMerchantRequest() { MerchantId = merchant.Id, AppId = createdApp.Id }); } ApiResponse <List <App> > appsResponse = merchantService.GetMerchantApps(new GetMerchantAppsRequest() { MerchantId = merchant.Id, Limit = 3 }); Assert.AreEqual(3, appsResponse.Content.Count); var beforeApps = merchantService.GetMerchantApps(new GetMerchantAppsRequest() { MerchantId = merchant.Id, Before = appsResponse.Content[2].Id, Limit = 2 }); Assert.AreEqual(2, beforeApps.Content.Count); var afterApps = merchantService.GetMerchantApps(new GetMerchantAppsRequest() { MerchantId = merchant.Id, After = appsResponse.Content[2].Id, Limit = 2 }); Assert.AreEqual(2, beforeApps.Content.Count); var firstAppsIds = appsResponse.Content.Select(m => m.Id); var beforeAppsIds = beforeApps.Content.Select(m => m.Id); var afterAppsIds = afterApps.Content.Select(m => m.Id); var beforeIntersection = firstAppsIds.Intersect(beforeAppsIds); var afterIntersection = firstAppsIds.Intersect(afterAppsIds); Assert.AreEqual(0, beforeIntersection.Count()); Assert.AreEqual(2, afterIntersection.Count()); }
public void GetMerchantUsers_Success() { App createdApp = _appService.CreateApp(new CreateAppRequest()).Content; IPaylikeMerchantService merchantService = new PaylikeMerchantService(createdApp.Key); var createdMerchant = merchantService.CreateMerchant(_createMerchantRequest).Content; for (int i = 0; i < 5; i++) { merchantService.InviteUserToMerchant(new InviteUserToMerchantRequest() { MerchantId = createdMerchant.Id, Email = "test" + i.ToString() + "@example.com" }); } ApiResponse <List <User> > usersResponse = merchantService.GetMerchantUsers(new GetMerchantUsersRequest() { MerchantId = createdMerchant.Id, Limit = 3 }); Assert.AreEqual(3, usersResponse.Content.Count); var beforeUsers = merchantService.GetMerchantUsers(new GetMerchantUsersRequest() { MerchantId = createdMerchant.Id, Before = usersResponse.Content[2].Id, Limit = 2 }); Assert.AreEqual(2, beforeUsers.Content.Count); var afterMerchants = merchantService.GetMerchantUsers(new GetMerchantUsersRequest() { MerchantId = createdMerchant.Id, After = usersResponse.Content[2].Id, Limit = 2 }); Assert.AreEqual(2, beforeUsers.Content.Count); var firtUsersIds = usersResponse.Content.Select(m => m.Id); var beforeUsersIds = beforeUsers.Content.Select(m => m.Id); var afterUsersIds = afterMerchants.Content.Select(m => m.Id); var beforeIntersection = firtUsersIds.Intersect(beforeUsersIds); var afterIntersection = firtUsersIds.Intersect(afterUsersIds); Assert.AreEqual(0, beforeIntersection.Count()); Assert.AreEqual(2, afterIntersection.Count()); }
public void CreateMerchant_WhenMissingRequiredFields_Fails() { App createdApp = _appService.CreateApp(new CreateAppRequest()).Content; IPaylikeMerchantService merchantService = new PaylikeMerchantService(createdApp.Key); ApiResponse <Merchant> response = merchantService.CreateMerchant(new CreateMerchantRequest() { Test = true }); Assert.IsTrue(response.IsError); Assert.IsNotNull(response.ErrorContent); Assert.AreEqual(400, response.ResponseCode); }
public void InviteUserToMerhant_Success() { App createdApp = _appService.CreateApp(new CreateAppRequest()).Content; IPaylikeMerchantService merchantService = new PaylikeMerchantService(createdApp.Key); Merchant createdMerchant = merchantService.CreateMerchant(_createMerchantRequest).Content; var inviteResult = merchantService.InviteUserToMerchant(new InviteUserToMerchantRequest() { MerchantId = createdMerchant.Id, Email = "*****@*****.**" }); Assert.IsNotNull(inviteResult.Content); Assert.IsFalse(inviteResult.IsError); Assert.AreEqual(201, inviteResult.ResponseCode); }
public void GetMerchants_Success() { App createdApp = _appService.CreateApp(new CreateAppRequest()).Content; IPaylikeMerchantService merchantService = new PaylikeMerchantService(createdApp.Key); for (int i = 0; i < 5; i++) { _createMerchantRequest.Name = "TestMerchant_" + DateTime.Now.Ticks.ToString(); merchantService.CreateMerchant(_createMerchantRequest); } ApiResponse <List <Merchant> > merchantsResponse = merchantService.GetMerchants(new GetMerchantsRequest() { AppId = createdApp.Id, Limit = 3 }); Assert.AreEqual(3, merchantsResponse.Content.Count); var beforeMerchants = merchantService.GetMerchants(new GetMerchantsRequest() { AppId = createdApp.Id, Before = merchantsResponse.Content[2].Id, Limit = 2 }); Assert.AreEqual(2, beforeMerchants.Content.Count); var afterMerchants = merchantService.GetMerchants(new GetMerchantsRequest() { AppId = createdApp.Id, After = merchantsResponse.Content[2].Id, Limit = 2 }); Assert.AreEqual(2, beforeMerchants.Content.Count); var firstMerchantsIds = merchantsResponse.Content.Select(m => m.Id); var beforeMerchantsIds = beforeMerchants.Content.Select(m => m.Id); var afterMerchantsIds = afterMerchants.Content.Select(m => m.Id); var beforeIntersection = firstMerchantsIds.Intersect(beforeMerchantsIds); var afterIntersection = firstMerchantsIds.Intersect(afterMerchantsIds); Assert.AreEqual(0, beforeIntersection.Count()); Assert.AreEqual(2, afterIntersection.Count()); }
public void UpdateMerchant_Success() { App createdApp = _appService.CreateApp(new CreateAppRequest()).Content; IPaylikeMerchantService merchantService = new PaylikeMerchantService(createdApp.Key); Merchant createdMerchant = merchantService.CreateMerchant(_createMerchantRequest).Content; merchantService.UpdateMerchant(new UpdateMerchantRequest() { MerchantId = createdMerchant.Id, Email = "*****@*****.**", Name = "new_name", Descriptor = "newDesc" }); Merchant gotMerchant = merchantService.GetMerchant(new GetMerchantRequest() { MerchantId = createdMerchant.Id }).Content; Assert.AreEqual(gotMerchant.Name, "new_name"); Assert.AreEqual(gotMerchant.Email, "*****@*****.**"); Assert.AreEqual(gotMerchant.Descriptor, "newDesc"); }
public void GetMerchant_Success() { App createdApp = _appService.CreateApp(new CreateAppRequest()).Content; IPaylikeMerchantService merchantService = new PaylikeMerchantService(createdApp.Key); Merchant createdMerchant = merchantService.CreateMerchant(_createMerchantRequest).Content; Merchant gotMerchant = merchantService.GetMerchant(new GetMerchantRequest() { MerchantId = createdMerchant.Id }).Content; Assert.AreEqual(gotMerchant.Name, createdMerchant.Name); Assert.AreEqual(gotMerchant.Currency, createdMerchant.Currency); Assert.AreEqual(gotMerchant.Test, createdMerchant.Test); Assert.AreEqual(gotMerchant.Email, createdMerchant.Email); Assert.AreEqual(gotMerchant.Website, createdMerchant.Website); Assert.AreEqual(gotMerchant.Descriptor, createdMerchant.Descriptor); Assert.AreEqual(gotMerchant.Company.Country, createdMerchant.Company.Country); Assert.AreEqual(gotMerchant.Company.Number, createdMerchant.Company.Number); Assert.AreEqual(gotMerchant.Bank.IBAN, createdMerchant.Bank.IBAN); }