Skip to content
This repository has been archived by the owner on Apr 27, 2021. It is now read-only.

Commit

Permalink
LevelUp Public C# SDK Version v9.3.0
Browse files Browse the repository at this point in the history
* Add GrantMerchantFundedCredit and GetLocationUserCredit
* INSTORE-502, INSTORE-527 add GrantMerchantFundedCredit and GetLocationUserCredit
* Changed the .NET requirement to 4.0 and changed dependencies (#167)
  • Loading branch information
klickyfan authored and Navid Matin committed Jul 11, 2019
1 parent 63c3f6b commit 8c153b6
Show file tree
Hide file tree
Showing 32 changed files with 640 additions and 125 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,4 @@ tools/**

#Code Coverage
coverage*
/LevelUp.Api.Client.Tests/Config/test_config_settings.xml
5 changes: 0 additions & 5 deletions Directory.Build.targets

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ internal static T GetMockedLevelUpModule<T>(RestResponse expectedResponse,
/// <param name="requestUrlBase">The url that is expected to retrieve the first page.</param>
internal static T GetMockedLevelUpModuleWithPaging<T>(RestResponse[] expectedResponses,
string requestUrlBase)
where T : IQueryOrders
where T : IListOrders
{
return GetMockedLevelUpModuleWithPaging<T>(expectedResponses, requestUrlBase, LevelUpEnvironment.Sandbox);
}
Expand All @@ -204,7 +204,7 @@ internal static T GetMockedLevelUpModuleWithPaging<T>(RestResponse[] expectedRes
internal static T GetMockedLevelUpModuleWithPaging<T>(RestResponse[] expectedResponses,
string requestUrlBase,
LevelUpEnvironment environmentToUse)
where T : IQueryOrders
where T : IListOrders
{
var len = expectedResponses.Length;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void CreateDetachedRefundShouldSucceed()
const string identifier_from_merchant = "001001";
const string internal_reason = "Andrew didn't like his coffee";
const string manager_confirmation = "12345";
const string payment_token_data = "LU020000029080KFZ02I9A8V030000LU";
const string payment_token_data = "LU020000000THISISFAKE000000000LU";
const string register = "03";
const string refunded_at = "2014-01-01T00:00:00-04:00";
const int credit_amount = 743;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void GiftCardAddValueShouldSucceed()
{
const string accessToken = "abc";
const int merchant_id = 3554;
const string payment_token_data = "LU020000029080KFZ02I9A8V030000LU";
const string payment_token_data = "LU020000000THISISFAKE000000000LU";
const int value_amount = 1000;
const int location_id = 1234;
const string order_uuid = "a7e23820d56802321bb64ab3b58dfe6c";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class IDestroyGiftCardValueFunctionalTests
[Test]
public void GiftCardDestroyValueShouldSucceed()
{
string paymentTokenData = "LU020000029080KFZ02I9A8V030000LU";
string paymentTokenData = "LU020000000THISISFAKE000000000LU";
int merchantId = 3;
int valueAmountCents = 100;
int initialTotalValueAtMerchantCents = 202;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void CreateProposedOrderShouldSucceed()

string expectedRequest = "{" +
"\"proposed_order\": {" +
"\"payment_token_data\": \"LU02000008ZS9OJFUBNEL6ZM030000LU\"," +
"\"payment_token_data\": \"LU020000000THISISFAKE000000000LU\"," +
"\"cashier\": \"Bob\"," +
"\"exemption_amount\": 0," +
"\"receipt_message_html\": null," +
Expand All @@ -60,7 +60,7 @@ public void CreateProposedOrderShouldSucceed()

IManageProposedOrders client = ClientModuleFunctionalTestingUtilities.GetMockedLevelUpModule<IManageProposedOrders, CreateProposedOrderRequest>(
expectedResponse, expectedRequest, expectedRequestUrl: expectedRequestUrl);
var proposedOrder = client.CreateProposedOrder("not_checking_this", 19, "LU02000008ZS9OJFUBNEL6ZM030000LU",
var proposedOrder = client.CreateProposedOrder("not_checking_this", 19, "LU020000000THISISFAKE000000000LU",
110, 110, 10, 0, "3", "Bob", "001001", null, true, false, items);

Assert.AreEqual(proposedOrder.ProposedOrderIdentifier, "1b3b3c4d5e6f7g8a9i9h8g7f6e5d4c3b2a1");
Expand All @@ -75,7 +75,7 @@ public void CreateProposedOrderShouldSucceedForSplitTender()

string expectedRequest = "{" +
"\"proposed_order\": {" +
"\"payment_token_data\": \"LU02000008ZS9OJFUBNEL6ZM030000LU\"," +
"\"payment_token_data\": \"LU020000000THISISFAKE000000000LU\"," +
"\"cashier\": \"Bob\"," +
"\"exemption_amount\": 40," +
"\"receipt_message_html\": null," +
Expand All @@ -99,7 +99,7 @@ public void CreateProposedOrderShouldSucceedForSplitTender()

IManageProposedOrders client = ClientModuleFunctionalTestingUtilities.GetMockedLevelUpModule<IManageProposedOrders, CreateProposedOrderRequest>(
expectedResponse, expectedRequest, expectedRequestUrl: expectedRequestUrl);
var proposedOrder = client.CreateProposedOrder("not_checking_this", 19, "LU02000008ZS9OJFUBNEL6ZM030000LU",
var proposedOrder = client.CreateProposedOrder("not_checking_this", 19, "LU020000000THISISFAKE000000000LU",
200, 100, 10, 130, "3", "Bob", "001001", null, true, false, items);

Assert.AreEqual(proposedOrder.ProposedOrderIdentifier, "1b3b3c4d5e6f7g8a9i9h8g7f6e5d4c3b2a1");
Expand All @@ -119,7 +119,7 @@ public void CompleteProposedOrderShouldSucceed()
"\"identifier_from_merchant\": \"001001\"," +
"\"location_id\": 19," +
"\"partial_authorization_allowed\": false," +
"\"payment_token_data\": \"LU02000008ZS9OJFUBNEL6ZM030000LU\"," +
"\"payment_token_data\": \"LU020000000THISISFAKE000000000LU\"," +
"\"proposed_order_uuid\": \"1b3b3c4d5e6f7g8a9i9h8g7f6e5d4c3b2a1\"," +
"\"receipt_message_html\": \"Pick up your order at <strong>counter #4</strong>\"," +
"\"register\": \"3\"," +
Expand Down Expand Up @@ -148,7 +148,7 @@ public void CompleteProposedOrderShouldSucceed()

IManageProposedOrders client = ClientModuleFunctionalTestingUtilities.GetMockedLevelUpModule<IManageProposedOrders, CompleteProposedOrderRequest>(
expectedResponse, expectedRequest, expectedRequestUrl: expectedRequestUrl);
var completedOrder = client.CompleteProposedOrder("not_checking_this", 19, "LU02000008ZS9OJFUBNEL6ZM030000LU",
var completedOrder = client.CompleteProposedOrder("not_checking_this", 19, "LU020000000THISISFAKE000000000LU",
"1b3b3c4d5e6f7g8a9i9h8g7f6e5d4c3b2a1", 110, 110, 10, 0, 100, "3", "Bob", "001001",
"Pick up your order at <strong>counter #4</strong>", false, false, items);

Expand All @@ -173,7 +173,7 @@ public void CompleteProposedOrderShouldSucceedForSplitTender()
"\"identifier_from_merchant\": \"001001\"," +
"\"location_id\": 19," +
"\"partial_authorization_allowed\": false," +
"\"payment_token_data\": \"LU02000008ZS9OJFUBNEL6ZM030000LU\"," +
"\"payment_token_data\": \"LU020000000THISISFAKE000000000LU\"," +
"\"proposed_order_uuid\": \"1b3b3c4d5e6f7g8a9i9h8g7f6e5d4c3b2a1\"," +
"\"receipt_message_html\": \"Pick up your order at <strong>counter #4</strong>\"," +
"\"register\": \"3\"," +
Expand Down Expand Up @@ -202,7 +202,7 @@ public void CompleteProposedOrderShouldSucceedForSplitTender()

IManageProposedOrders client = ClientModuleFunctionalTestingUtilities.GetMockedLevelUpModule<IManageProposedOrders, CompleteProposedOrderRequest>(
expectedResponse, expectedRequest, expectedRequestUrl: expectedRequestUrl);
var completedOrder = client.CompleteProposedOrder("not_checking_this", 19, "LU02000008ZS9OJFUBNEL6ZM030000LU",
var completedOrder = client.CompleteProposedOrder("not_checking_this", 19, "LU020000000THISISFAKE000000000LU",
"1b3b3c4d5e6f7g8a9i9h8g7f6e5d4c3b2a1", 300, 200, 10, 130, 100, "3", "Bob", "001001",
"Pick up your order at <strong>counter #4</strong>", false, false, items);

Expand All @@ -227,7 +227,7 @@ public void CompleteProposedOrderShouldSucceedForDiscountsDisabled()
"\"identifier_from_merchant\": \"001001\"," +
"\"location_id\": 19," +
"\"partial_authorization_allowed\": false," +
"\"payment_token_data\": \"LU02000008ZS9OJFUBNEL6ZM030000LU\"," +
"\"payment_token_data\": \"LU020000000THISISFAKE000000000LU\"," +
"\"proposed_order_uuid\": \"1b3b3c4d5e6f7g8a9i9h8g7f6e5d4c3b2a1\"," +
"\"receipt_message_html\": \"Pick up your order at <strong>counter #4</strong>\"," +
"\"register\": \"3\"," +
Expand Down Expand Up @@ -256,7 +256,7 @@ public void CompleteProposedOrderShouldSucceedForDiscountsDisabled()

IManageProposedOrders client = ClientModuleFunctionalTestingUtilities.GetMockedLevelUpModule<IManageProposedOrders, CompleteProposedOrderRequest>(
expectedResponse, expectedRequest, expectedRequestUrl: expectedRequestUrl);
var completedOrder = client.CompleteProposedOrder("not_checking_this", 19, "LU02000008ZS9OJFUBNEL6ZM030000LU",
var completedOrder = client.CompleteProposedOrder("not_checking_this", 19, "LU020000000THISISFAKE000000000LU",
"1b3b3c4d5e6f7g8a9i9h8g7f6e5d4c3b2a1", 300, 200, 10, 130, null, "3", "Bob", "001001",
"Pick up your order at <strong>counter #4</strong>", false, false, items);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class IRetrieveMerchantFundedGiftCardCreditFunctionalTests
public void RetrieveMerchantFundedGiftCardCreditShouldPass()
{
const int locationId = 19;
const string qr_code = "LU02000008ZS9OJFUBNEL6ZM030000LU";
const string qr_code = "LU020000000THISISFAKE000000000LU";
const int gift_card_total = 2000;
const string auth_Token = "example_auth_token";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void GetPaymentTokenShouldSucceed()
Content =
"{" +
"\"payment_token\": {" +
"\"data\": \"LU02000008ZS9OJFUBNEL6ZM\"," +
"\"data\": \"LU020000000THISISFAKE000\"," +
"\"id\": 323" +
"}" +
"}"
Expand All @@ -48,7 +48,7 @@ public void GetPaymentTokenShouldSucceed()
expectedResponse, expectedRequestUrl: expectedRequestUrl);
var paymentToken = client.GetPaymentToken("not_checking_this");
Assert.AreEqual(paymentToken.Id, 323);
Assert.AreEqual(paymentToken.Data, "LU02000008ZS9OJFUBNEL6ZM");
Assert.AreEqual(paymentToken.Data, "LU020000000THISISFAKE000");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
namespace LevelUp.Api.Client.Tests.Client.FunctionalTests
{
[TestFixture]
public class IQueryOrdersFunctionalTests
public class ListOrdersFunctionalTests
{
private const int locationId = 19;
private string expectedRequestBaseUrl = string.Format(ClientModuleFunctionalTestingUtilities.SANDBOX_URL_PREFIX + "/v14/locations/{0}/orders", locationId);
private string expectedRequestBaseUrl = string.Format(ClientModuleFunctionalTestingUtilities.SANDBOX_URL_PREFIX + "/v15/apps/orders");

private const string orderUnitJson =
"\"order\": {{" +
Expand Down Expand Up @@ -64,8 +64,8 @@ private static RestResponse GetOrderResponseWithThreeElements(string id1, string
[Test]
public void ListOrdersShouldSucceedWhenAllPagesQueried()
{
IQueryOrders client = ClientModuleFunctionalTestingUtilities.GetMockedLevelUpModuleWithPaging<IQueryOrders>(successfulResponses, expectedRequestBaseUrl);
var orders = client.ListOrders("not_checking_this", locationId, 1, 3);
IListOrders client = ClientModuleFunctionalTestingUtilities.GetMockedLevelUpModuleWithPaging<IListOrders>(successfulResponses, expectedRequestBaseUrl);
var orders = client.ListOrders("not_checking_this", 1, 3);

Assert.AreEqual(orders.Count, 9);
Assert.AreEqual(orders[0].OrderIdentifier, "a");
Expand All @@ -82,67 +82,67 @@ public void ListOrdersShouldSucceedWhenAllPagesQueried()
[Test]
public void ListOrdersShouldSucceedWhenMorePagesQueriedThanExist()
{
IQueryOrders client = ClientModuleFunctionalTestingUtilities.GetMockedLevelUpModuleWithPaging<IQueryOrders>(successfulResponses, expectedRequestBaseUrl);
var orders = client.ListOrders("not_checking_this", locationId, 1, 10); // Note that we specify pages 1-10 when only 3 pages exist
IListOrders client = ClientModuleFunctionalTestingUtilities.GetMockedLevelUpModuleWithPaging<IListOrders>(successfulResponses, expectedRequestBaseUrl);
var orders = client.ListOrders("not_checking_this", 1, 10); // Note that we specify pages 1-10 when only 3 pages exist

Assert.AreEqual(orders.Count, 9);
}

[Test]
public void ListOrdersShouldSucceedAndAreThereMorePagesShouldBeValid()
{
IQueryOrders client = ClientModuleFunctionalTestingUtilities.GetMockedLevelUpModuleWithPaging<IQueryOrders>(successfulResponses, expectedRequestBaseUrl);
IListOrders client = ClientModuleFunctionalTestingUtilities.GetMockedLevelUpModuleWithPaging<IListOrders>(successfulResponses, expectedRequestBaseUrl);
bool areThereMorePages;

var orders = client.ListOrders("not_checking_this", locationId, 1, 1, out areThereMorePages);
var orders = client.ListOrders("not_checking_this", 1, 1, out areThereMorePages);
Assert.IsTrue(areThereMorePages);

orders = client.ListOrders("not_checking_this", locationId, 1, 3, out areThereMorePages);
orders = client.ListOrders("not_checking_this", 1, 3, out areThereMorePages);
Assert.IsFalse(areThereMorePages);

orders = client.ListOrders("not_checking_this", locationId, 3, 3, out areThereMorePages);
orders = client.ListOrders("not_checking_this", 3, 3, out areThereMorePages);
Assert.IsFalse(areThereMorePages);

orders = client.ListOrders("not_checking_this", locationId, 2, 5, out areThereMorePages);
orders = client.ListOrders("not_checking_this", 2, 5, out areThereMorePages);
Assert.IsFalse(areThereMorePages);
}

[Test]
public void ListOrdersShouldSucceedDespiteInvalidEndPageNumbers()
{
IQueryOrders client = ClientModuleFunctionalTestingUtilities.GetMockedLevelUpModuleWithPaging<IQueryOrders>(successfulResponses, expectedRequestBaseUrl);
IListOrders client = ClientModuleFunctionalTestingUtilities.GetMockedLevelUpModuleWithPaging<IListOrders>(successfulResponses, expectedRequestBaseUrl);

var orders = client.ListOrders("not_checking_this", locationId, 1, 10);
var orders = client.ListOrders("not_checking_this", 1, 10);
Assert.AreEqual(orders.Count, 9);

orders = client.ListOrders("not_checking_this", locationId, 3, 11);
orders = client.ListOrders("not_checking_this", 3, 11);
Assert.AreEqual(orders.Count, 3);
}

[Test]
public void ListOrdersShouldFailWith204ForInvalidStartPageNumbers()
{
IQueryOrders client = ClientModuleFunctionalTestingUtilities.GetMockedLevelUpModuleWithPaging<IQueryOrders>(
IListOrders client = ClientModuleFunctionalTestingUtilities.GetMockedLevelUpModuleWithPaging<IListOrders>(
successfulResponses, expectedRequestBaseUrl);
var orders = client.ListOrders("not_checking_this", locationId, 5, 10);
var orders = client.ListOrders("not_checking_this", 5, 10);
Assert.AreEqual(orders.Count, 0);
}

[Test]
public void ListFilteredOrdersShouldSucceedWithNoModifierFunctions()
{
IQueryOrders client = ClientModuleFunctionalTestingUtilities.GetMockedLevelUpModuleWithPaging<IQueryOrders>(
IListOrders client = ClientModuleFunctionalTestingUtilities.GetMockedLevelUpModuleWithPaging<IListOrders>(
successfulResponses, expectedRequestBaseUrl);
var orders = client.ListFilteredOrders("not_checking_this", locationId, 1, 3);
var orders = client.ListFilteredOrders("not_checking_this", 1, 3);
Assert.AreEqual(orders.Count, 9);
}

[Test]
public void ListFilteredOrdersShouldSucceedWithAFilterFunction()
{
IQueryOrders client = ClientModuleFunctionalTestingUtilities.GetMockedLevelUpModuleWithPaging<IQueryOrders>(
IListOrders client = ClientModuleFunctionalTestingUtilities.GetMockedLevelUpModuleWithPaging<IListOrders>(
successfulResponses, expectedRequestBaseUrl);
var orders = client.ListFilteredOrders("not_checking_this", locationId, 1, 3,
var orders = client.ListFilteredOrders("not_checking_this", 1, 3,
(x => (x.OrderIdentifier == "c" || x.OrderIdentifier == "i")), null);
Assert.AreEqual(orders.Count, 2);
Assert.AreEqual(orders[0].OrderIdentifier, "c");
Expand All @@ -152,9 +152,9 @@ public void ListFilteredOrdersShouldSucceedWithAFilterFunction()
[Test]
public void ListFilteredOrdersShouldSucceedWithAnOrderingFunction()
{
IQueryOrders client = ClientModuleFunctionalTestingUtilities.GetMockedLevelUpModuleWithPaging<IQueryOrders>(
IListOrders client = ClientModuleFunctionalTestingUtilities.GetMockedLevelUpModuleWithPaging<IListOrders>(
successfulResponses, expectedRequestBaseUrl);
var orders = client.ListFilteredOrders("not_checking_this", locationId, 1, 3, null,
var orders = client.ListFilteredOrders("not_checking_this", 1, 3, null,
((x, y) => ( 0 - string.Compare(x.OrderIdentifier, y.OrderIdentifier) ))); // i.e. orderbydecending
Assert.AreEqual(orders.Count, 9);
Assert.AreEqual(orders[0].OrderIdentifier, "i");
Expand Down
Loading

0 comments on commit 8c153b6

Please sign in to comment.