Skip to content

Commit

Permalink
Adds Card Blacklist Feature (#119)
Browse files Browse the repository at this point in the history
* Adds Card Blacklist Feature

* Card Blacklist Endpoint Change
  • Loading branch information
furkanbatuhan authored Sep 7, 2022
1 parent 5d3de7b commit 061aa83
Show file tree
Hide file tree
Showing 5 changed files with 169 additions and 0 deletions.
84 changes: 84 additions & 0 deletions Iyzipay.Samples/CardBlacklistSample.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
using Iyzipay.Model;
using Iyzipay.Request;
using NUnit.Framework;

namespace Iyzipay.Samples
{
public class CardBlacklistSample : Sample
{
[Test]
public void Should_Create_Card_Blacklist()
{
CreateCardBlacklistRequest request = new CreateCardBlacklistRequest();
request.Locale = Locale.TR.ToString();
request.ConversationId = "123456789";
request.CardToken = "";
request.CardUserKey = "";


CardBlacklist cardBlacklist = CardBlacklist.Create(request, options);


PrintResponse<CardBlacklist>(cardBlacklist);

Assert.AreEqual(Status.SUCCESS.ToString(), cardBlacklist.Status);
Assert.AreEqual(Locale.TR.ToString(), cardBlacklist.Locale);
Assert.AreEqual("123456789", cardBlacklist.ConversationId);
Assert.IsNotNull(cardBlacklist.SystemTime);
Assert.IsNull(cardBlacklist.ErrorCode);
Assert.IsNull(cardBlacklist.ErrorMessage);
Assert.IsNull(cardBlacklist.ErrorGroup);
Assert.IsNotNull(cardBlacklist.CardUserKey);
Assert.IsNotNull(cardBlacklist.CardToken);

}

[Test]
public void Should_Update_Card_Blacklist()
{
UpdateCardBlacklistRequest request = new UpdateCardBlacklistRequest();
request.Locale = Locale.TR.ToString();
request.ConversationId = "123456789";
request.CardToken = "";
request.CardUserKey = "";


CardBlacklist cardBlacklist = CardBlacklist.Update(request, options);


PrintResponse<CardBlacklist>(cardBlacklist);

Assert.AreEqual(Status.SUCCESS.ToString(), cardBlacklist.Status);
Assert.AreEqual(Locale.TR.ToString(), cardBlacklist.Locale);
Assert.AreEqual("123456789", cardBlacklist.ConversationId);
Assert.IsNotNull(cardBlacklist.SystemTime);
Assert.IsNull(cardBlacklist.ErrorCode);
Assert.IsNull(cardBlacklist.ErrorMessage);
Assert.IsNull(cardBlacklist.ErrorGroup);
Assert.IsNotNull(cardBlacklist.CardUserKey);
Assert.IsNotNull(cardBlacklist.CardToken);
}

[Test]
public void Should_Retrieve_Blacklist_Cards()
{
RetrieveCardBlacklistRequest request = new RetrieveCardBlacklistRequest();
request.Locale = Locale.TR.ToString();
request.ConversationId = "123456789";
request.CardNumber = "";

CardBlacklist cardBlacklist = CardBlacklist.Retrieve(request, options);

PrintResponse<CardBlacklist>(cardBlacklist);

Assert.AreEqual(Status.SUCCESS.ToString(), cardBlacklist.Status);
Assert.AreEqual(Locale.TR.ToString(), cardBlacklist.Locale);
Assert.IsNotNull(cardBlacklist.SystemTime);
Assert.IsNull(cardBlacklist.ErrorCode);
Assert.IsNull(cardBlacklist.ErrorMessage);
Assert.IsNull(cardBlacklist.ErrorGroup);
Assert.IsNotNull(cardBlacklist.CardNumber);
Assert.IsNotNull(cardBlacklist.Blacklisted);
}
}
}
27 changes: 27 additions & 0 deletions Iyzipay/Model/CardBlacklist.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Iyzipay.Request;
using System;

namespace Iyzipay.Model
{
public class CardBlacklist : IyzipayResource
{
public String CardUserKey { get; set; }
public String CardToken { get; set; }
public String CardNumber { get; set; }
public Boolean Blacklisted { get; set; }
public static CardBlacklist Create(CreateCardBlacklistRequest request, Options options)
{
return RestHttpClient.Create().Post<CardBlacklist>(options.BaseUrl + "/cardstorage/blacklist/card", GetHttpHeaders(request, options), request);
}

public static CardBlacklist Update(UpdateCardBlacklistRequest request, Options options)
{
return RestHttpClient.Create().Post<CardBlacklist>(options.BaseUrl + "/cardstorage/blacklist/card/inactive", GetHttpHeaders(request, options), request);
}

public static CardBlacklist Retrieve(RetrieveCardBlacklistRequest request, Options options)
{
return RestHttpClient.Create().Post<CardBlacklist>(options.BaseUrl + "/cardstorage/blacklist/card/retrieve", GetHttpHeaders(request, options), request);
}
}
}
20 changes: 20 additions & 0 deletions Iyzipay/Request/CreateCardBlacklistRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Iyzipay.Model;
using System;

namespace Iyzipay.Request
{
public class CreateCardBlacklistRequest : BaseRequest
{
public String CardToken { get; set; }
public String CardUserKey { get; set; }

public override String ToPKIRequestString()
{
return ToStringRequestBuilder.NewInstance()
.AppendSuper(base.ToPKIRequestString())
.Append("cardToken", CardToken)
.Append("cardUserKey", CardUserKey)
.GetRequestString();
}
}
}
18 changes: 18 additions & 0 deletions Iyzipay/Request/RetrieveCardBlacklistRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Iyzipay.Model;
using System;

namespace Iyzipay.Request
{
public class RetrieveCardBlacklistRequest : BaseRequest
{
public String CardNumber { get; set; }

public override String ToPKIRequestString()
{
return ToStringRequestBuilder.NewInstance()
.AppendSuper(base.ToPKIRequestString())
.Append("cardNumber", CardNumber)
.GetRequestString();
}
}
}
20 changes: 20 additions & 0 deletions Iyzipay/Request/UpdateCardBlacklistRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Iyzipay.Model;
using System;

namespace Iyzipay.Request
{
public class UpdateCardBlacklistRequest : BaseRequest
{
public String CardToken { get; set; }
public String CardUserKey { get; set; }

public override String ToPKIRequestString()
{
return ToStringRequestBuilder.NewInstance()
.AppendSuper(base.ToPKIRequestString())
.Append("cardToken", CardToken)
.Append("cardUserKey", CardUserKey)
.GetRequestString();
}
}
}

0 comments on commit 061aa83

Please sign in to comment.