Skip to content

Commit

Permalink
LTQR Bulk push support
Browse files Browse the repository at this point in the history
  • Loading branch information
wvdhaute committed Dec 10, 2015
1 parent 9709b75 commit b3185bb
Show file tree
Hide file tree
Showing 10 changed files with 251 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,28 @@ public void testPush()
Assert.NotNull(session);
}

[Test]
public void testPushBulk()
{
LinkIDLTQRContent content = new LinkIDLTQRContent();
content.authenticationMessage = "foo";
content.finishedMessage = "bar";
content.paymentContext = new LinkIDPaymentContext(new LinkIDPaymentAmount(20000, LinkIDCurrency.EUR, null),
"blaat", null, null);
content.expiryDate = DateTime.Now.AddMonths(3);

List<LinkIDLTQRPushContent> requests = new List<LinkIDLTQRPushContent>();
for (int i = 0; i < 5; i++)
{
requests.Add(new LinkIDLTQRPushContent(content, null, LinkIDLTQRLockType.NEVER));
}

List<LinkIDLTQRPushResponse> results = client.ltqrBulkPush(requests);

Assert.NotNull(results);
Assert.AreEqual(requests.Count, results.Count);
}

[Test]
public void testChange()
{
Expand Down
Binary file modified linkid-sdk-dotnet/linkid-sdk-dotnet.suo
Binary file not shown.
3 changes: 3 additions & 0 deletions linkid-sdk-dotnet/linkid-sdk-dotnet/linkid-sdk-dotnet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
<Compile Include="src\main\cs\api\LinkIDLTQRContent.cs" />
<Compile Include="src\main\cs\api\LinkIDLTQRLockType.cs" />
<Compile Include="src\main\cs\api\LinkIDLTQRPollingConfiguration.cs" />
<Compile Include="src\main\cs\api\LinkIDLTQRPushContent.cs" />
<Compile Include="src\main\cs\api\LinkIDLTQRPushResponse.cs" />
<Compile Include="src\main\cs\api\LinkIDLTQRSession.cs" />
<Compile Include="src\main\cs\api\LinkIDNotificationConstants.cs" />
<Compile Include="src\main\cs\api\LinkIDNotificationMessage.cs" />
Expand Down Expand Up @@ -127,6 +129,7 @@
<Compile Include="src\main\cs\ws\linkid\configuration\LinkIDLocalizationException.cs" />
<Compile Include="src\main\cs\ws\linkid\LinkIDServiceClient.cs" />
<Compile Include="src\main\cs\ws\linkid\LinkIDServiceClientImpl.cs" />
<Compile Include="src\main\cs\ws\linkid\ltqr\LinkIDLTQRBulkPushException.cs" />
<Compile Include="src\main\cs\ws\linkid\ltqr\LinkIDLTQRInfoException.cs" />
<Compile Include="src\main\cs\ws\linkid\ltqr\LinkIDLTQRRemoveException.cs" />
<Compile Include="src\main\cs\ws\linkid\ltqr\LinkIDLTQRPullException.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;

namespace safe_online_sdk_dotnet
{
public class LinkIDLTQRPushContent
{
public LinkIDLTQRContent content { get; set; }
public String userAgent { get; set; }
public LinkIDLTQRLockType lockType { get; set; }

public LinkIDLTQRPushContent(LinkIDLTQRContent content, String userAgent, LinkIDLTQRLockType lockType)
{
this.content = content;
this.userAgent = userAgent;
this.lockType = lockType;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using LinkIDWSNameSpace;

namespace safe_online_sdk_dotnet
{
public class LinkIDLTQRPushResponse
{
public LinkIDLTQRSession ltqrSession { get; set; }

public LTQRPushErrorCode errorCode { get; set; }
public String errorMessage { get; set; }

public LinkIDLTQRPushResponse(LinkIDLTQRSession ltqrSession)
{
this.ltqrSession = ltqrSession;
}

public LinkIDLTQRPushResponse(LTQRPushErrorCode errorCode, String errorMessage)
{
this.errorCode = errorCode;
this.errorMessage = errorMessage;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ public interface LinkIDServiceClient
/// <exception cref="LinkIDLTQRPushException">something went wrong, check the error code</exception>
LinkIDLTQRSession ltqrPush(LinkIDLTQRContent content, String userAgent, LinkIDLTQRLockType lockType);

/// <summary>
/// Bulk push long term QR sessions to linkID
/// </summary>
/// <param name="contents">the LTQR request contents</param>
/// <returns>list of responses for the LTQR requests</returns>
/// <exception cref="LinkIDLTQRBulkPushException">something went wrong, check the error code</exception>
List<LinkIDLTQRPushResponse> ltqrBulkPush(List<LinkIDLTQRPushContent> contents);

/// <summary>
/// Change an existing long term QR code
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,48 @@ public LinkIDLTQRSession ltqrPush(LinkIDLTQRContent content, String userAgent, L
throw new RuntimeException("No success nor error element in the response ?!");
}

public List<LinkIDLTQRPushResponse> ltqrBulkPush(List<LinkIDLTQRPushContent> contents)
{
List<LTQRPushContent> requests = new List<LTQRPushContent>();
foreach (LinkIDLTQRPushContent content in contents)
{
LTQRPushContent ltqrPushContent = new LTQRPushContent();
ltqrPushContent.content = convert(content.content);
ltqrPushContent.userAgent = content.userAgent;
ltqrPushContent.lockType = convert(content.lockType);

requests.Add(ltqrPushContent);
}

// operate
LTQRBulkPushResponse response = client.ltqrBulkPush(requests.ToArray());

if (null != response.error)
{
throw new LinkIDLTQRBulkPushException(response.error.errorCode, response.error.errorMessage);
}

if (null != response.success)
{
List<LinkIDLTQRPushResponse> results = new List<LinkIDLTQRPushResponse>();
foreach (LTQRPushResponse2 ltqrPushResponse in response.success)
{
if (null != ltqrPushResponse.success)
{
results.Add(new LinkIDLTQRPushResponse(new LinkIDLTQRSession(ltqrPushResponse.success.ltqrReference,
convert(ltqrPushResponse.success.qrCodeInfo), ltqrPushResponse.success.paymentOrderReference)));
}
else
{
results.Add(new LinkIDLTQRPushResponse(ltqrPushResponse.error.errorCode, ltqrPushResponse.error.errorMessage));
}
}
return results;
}

throw new RuntimeException("No success nor error element in the response ?!");
}

public LinkIDLTQRSession ltqrChange(String ltqrReference, LinkIDLTQRContent content, String userAgent, Boolean unlock, Boolean unblock)
{
LTQRChangeRequest request = new LTQRChangeRequest();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using LinkIDWSNameSpace;

namespace safe_online_sdk_dotnet
{
public class LinkIDLTQRBulkPushException : System.Exception
{
public LTQRBulkPushErrorCode errorCode { get; set; }

public LinkIDLTQRBulkPushException(LTQRBulkPushErrorCode errorCode, String message)
: base(message)
{
this.errorCode = errorCode;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@
<message name="ltqrPushResponse">
<part name="response" element="tns:LTQRPushResponse" />
</message>
<message name="ltqrBulkPushRequest">
<part name="request" element="tns:LTQRBulkPushRequest" />
</message>
<message name="ltqrBulkPushResponse">
<part name="response" element="tns:LTQRBulkPushResponse" />
</message>
<message name="ltqrChangeRequest">
<part name="request" element="tns:LTQRChangeRequest" />
</message>
Expand Down Expand Up @@ -231,6 +237,10 @@
<input message="tns:ltqrPushRequest" />
<output message="tns:ltqrPushResponse" />
</operation>
<operation name="ltqrBulkPush">
<input message="tns:ltqrBulkPushRequest" />
<output message="tns:ltqrBulkPushResponse" />
</operation>
<operation name="ltqrChange">
<input message="tns:ltqrChangeRequest" />
<output message="tns:ltqrChangeResponse" />
Expand Down Expand Up @@ -396,6 +406,15 @@
<soap:body use="literal" />
</output>
</operation>
<operation name="ltqrBulkPush">
<soap:operation soapAction="urn:net:lin-k:linkid:3.1:ltqrBulkPush" />
<input>
<soap:body use="literal" />
</input>
<output>
<soap:body use="literal" />
</output>
</operation>
<operation name="ltqrChange">
<soap:operation soapAction="urn:net:lin-k:linkid:3.1:ltqrChange" />
<input>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,29 @@
</complexType>
</element>

<!-- LTQR: Bulk Push request -->

<element name="LTQRBulkPushRequest">
<complexType>
<sequence>
<element name="requests" type="tns:LTQRPushContent" minOccurs="1" maxOccurs="unbounded">
<annotation>
<documentation>The LTQR Push requests</documentation>
</annotation>
</element>
</sequence>
</complexType>
</element>

<element name="LTQRBulkPushResponse">
<complexType>
<sequence>
<element name="success" type="tns:LTQRBulkPushSuccess" minOccurs="0" maxOccurs="1" />
<element name="error" type="tns:LTQRBulkPushError" minOccurs="0" maxOccurs="1" />
</sequence>
</complexType>
</element>

<!-- LTQR: Change request -->

<element name="LTQRChangeRequest">
Expand Down Expand Up @@ -1188,6 +1211,82 @@
<attribute name="errorCode" type="tns:LTQRPushErrorCode" use="required" />
</complexType>

<complexType name="LTQRPushContent">
<sequence>
<element name="content" type="tns:LTQRContent" minOccurs="1" maxOccurs="1">
<annotation>
<documentation>The content of this LTQR</documentation>
</annotation>
</element>
</sequence>
<attribute name="userAgent" type="string" use="optional">
<annotation>
<documentation>Optional user agent string, for adding e.g. callback params to the QR code URL, android chrome URL needs to be http://linkidmauthurl/MAUTH/2/zUC8oA/eA==, ...</documentation>
</annotation>
</attribute>
<attribute name="lockType" type="tns:LTQRLockType" use="required">
<annotation>
<documentation>LTQR lock type</documentation>
</annotation>
</attribute>
</complexType>

<complexType name="LTQRBulkPushSuccess">
<sequence>
<element name="responses" type="tns:LTQRPushResponse2" minOccurs="1" maxOccurs="unbounded">
<annotation>
<documentation>The LTQR codes or error response if one failed</documentation>
</annotation>
</element>
</sequence>
</complexType>

<complexType name="LTQRPushResponse2">
<sequence>
<element name="success" type="tns:LTQRPushSuccess" minOccurs="0" maxOccurs="1" />
<element name="error" type="tns:LTQRPushError" minOccurs="0" maxOccurs="1" />
</sequence>
</complexType>

<complexType name="LTQRBulkPushError">
<sequence>
<element name="errorMessage" type="string" minOccurs="0" maxOccurs="1">
<annotation>
<documentation>Optional error message containing additional info</documentation>
</annotation>
</element>
</sequence>
<attribute name="errorCode" type="tns:LTQRBulkPushErrorCode" use="required" />
</complexType>

<simpleType name="LTQRBulkPushErrorCode">
<annotation>
<documentation>Error codes</documentation>
</annotation>
<restriction base="string">
<enumeration value="error.credentials.invalid">
<annotation>
<documentation>The provided Service Provider credentials are not correct.</documentation>
</annotation>
</enumeration>
<enumeration value="error.too.many.requests">
<annotation>
<documentation>Too many requests, please send less in one bulk</documentation>
</annotation>
</enumeration>
<enumeration value="error.unexpected">
<annotation>
<documentation>Something unexpected happened.</documentation>
</annotation>
</enumeration>
<enumeration value="error.maintenance">
<annotation>
<documentation>linkID is down for maintenance.</documentation>
</annotation>
</enumeration>
</restriction>
</simpleType>

<complexType name="LTQRChangeSuccess">
<sequence>
<element name="ltqrReference" type="string" minOccurs="1" maxOccurs="1">
Expand Down

0 comments on commit b3185bb

Please sign in to comment.