Skip to content

Commit b2860a9

Browse files
committed
Added the task overview and moved files
1 parent a205bfa commit b2860a9

16 files changed

+158
-78
lines changed

Minimal Order Api.sln MinimalOrderApi.sln

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Minimal Order Api", "Minimal Order Api\Minimal Order Api.csproj", "{946405AC-2D35-484A-8F04-E7218FC8D4D1}"
3+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MinimalOrderApi", "MinimalOrderApi\MinimalOrderApi.csproj", "{946405AC-2D35-484A-8F04-E7218FC8D4D1}"
44
EndProject
55
Global
66
GlobalSection(SolutionConfigurationPlatforms) = preSolution

Minimal Order Api/Address.cs MinimalOrderApi/Address.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace Minimal_Order_Api
1+
namespace Billbee.MinimalOrderApi
22
{
33
public class Address
44
{

Minimal Order Api/IOrderAPI.cs MinimalOrderApi/IOrderAPI.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
using System;
22
using System.Collections.Generic;
33

4-
namespace Minimal_Order_Api
4+
namespace Billbee.MinimalOrderApi
55
{
66
public interface IOrderAPI : IDisposable
77
{
88
IEnumerable<Order> GetOrderList(DateTime? startDate,
9-
decimal vatRateRegular,
10-
decimal vatRateReduced,
11-
out int totalNumberOfOrders,
12-
out int totalNumberOfPages,
13-
int page = 1,
14-
int pageSize = 50
9+
decimal vatRateRegular,
10+
decimal vatRateReduced,
11+
out int totalNumberOfOrders,
12+
out int totalNumberOfPages,
13+
int page = 1,
14+
int pageSize = 50
1515
);
1616

1717
/// <summary>Deserialize the stored access token.</summary>

MinimalOrderApi/Implementation/.gitkeep

Whitespace-only changes.

Minimal Order Api/Minimal Order Api.csproj MinimalOrderApi/MinimalOrderApi.csproj

+8-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
<ProjectGuid>{946405AC-2D35-484A-8F04-E7218FC8D4D1}</ProjectGuid>
88
<OutputType>Exe</OutputType>
99
<AppDesignerFolder>Properties</AppDesignerFolder>
10-
<RootNamespace>Minimal_Order_Api</RootNamespace>
11-
<AssemblyName>Minimal_Order_Api</AssemblyName>
10+
<RootNamespace>Billbee.MinimalOrderApi</RootNamespace>
11+
<AssemblyName>Billbee.MinimalOrderApi</AssemblyName>
1212
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
1313
<FileAlignment>512</FileAlignment>
1414
</PropertyGroup>
@@ -50,15 +50,21 @@
5050
<Compile Include="Address.cs" />
5151
<Compile Include="Order.cs" />
5252
<Compile Include="IOrderAPI.cs" />
53+
<Compile Include="OrderItem.cs" />
54+
<Compile Include="OrderItemAttribute.cs" />
5355
<Compile Include="OrderStateEnum.cs" />
5456
<Compile Include="PaymentTypeEnum.cs" />
5557
<Compile Include="Program.cs" />
5658
<Compile Include="Properties\AssemblyInfo.cs" />
5759
<Compile Include="RestClientBaseClass.cs" />
60+
<Compile Include="SoldProduct.cs" />
5861
</ItemGroup>
5962
<ItemGroup>
6063
<None Include="packages.config" />
6164
</ItemGroup>
65+
<ItemGroup>
66+
<Content Include="Implementation\.gitkeep" />
67+
</ItemGroup>
6268
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
6369
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
6470
Other similar extension points exist, see Microsoft.Common.targets.

Minimal Order Api/Order.cs MinimalOrderApi/Order.cs

+1-62
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Collections.Generic;
33
using System.Linq;
44

5-
namespace Minimal_Order_Api
5+
namespace Billbee.MinimalOrderApi
66
{
77
public class Order
88
{
@@ -61,65 +61,4 @@ public class Order
6161

6262
public string PaymentReference { get; set; }
6363
}
64-
public class OrderItem
65-
{
66-
/// <summary>
67-
/// Id der Einzeltransaktion. Wird nur von Ebay benötigt, um zusammengefasste Bestellungen zu erkennen OR Id of the individual transaction. Only required by Ebay to detect aggregated orders
68-
/// </summary>
69-
public string TransactionId { get; set; }
70-
71-
public SoldProduct Product { get; set; }
72-
public decimal Quantity { get; set; }
73-
74-
/// <summary>
75-
/// gross price for the ordered <see cref="Quantity"/> including tax
76-
/// </summary>
77-
public decimal TotalPrice { get; set; }
78-
79-
/// <summary>
80-
/// tax amount applied to this order item
81-
/// </summary>
82-
public decimal TaxAmount { get; set; }
83-
84-
/// <summary>
85-
/// 0: tax free, 1: normal tax, 2: reduced tax
86-
/// </summary>
87-
public byte? TaxIndex { get; set; }
88-
89-
public List<OrderItemAttribute> Attributes { get; set; }
90-
91-
92-
public bool IsCoupon { get; set; }
93-
94-
public bool IsDiscount { get; set; }
95-
96-
/// <summary>
97-
/// Sets the discount in percent
98-
/// </summary>
99-
public decimal Discount { get; set; }
100-
101-
public decimal DiscountedPrice => Math.Round(Discount != 0 ? TotalPrice * (100 - Discount) / 100 : TotalPrice,
102-
2, MidpointRounding.AwayFromZero);
103-
104-
public override string ToString()
105-
{
106-
return $"Q:{Quantity} TP:{TotalPrice} Tax:{TaxIndex} Discount:{Discount}";
107-
}
108-
}
109-
110-
public class OrderItemAttribute
111-
{
112-
public string Id { get; set; }
113-
public string Name { get; set; }
114-
public string Value { get; set; }
115-
}
116-
117-
public class SoldProduct
118-
{
119-
public string Id { get; set; }
120-
public string Title { get; set; }
121-
122-
public string SKU { get; set; }
123-
}
124-
12564
}

MinimalOrderApi/OrderItem.cs

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
using System;
2+
using System.Collections.Generic;
3+
4+
namespace Billbee.MinimalOrderApi
5+
{
6+
public class OrderItem
7+
{
8+
/// <summary>
9+
/// Id der Einzeltransaktion. Wird nur von Ebay benötigt, um zusammengefasste Bestellungen zu erkennen OR Id of the individual transaction. Only required by Ebay to detect aggregated orders
10+
/// </summary>
11+
public string TransactionId { get; set; }
12+
13+
public SoldProduct Product { get; set; }
14+
public decimal Quantity { get; set; }
15+
16+
/// <summary>
17+
/// gross price for the ordered <see cref="Quantity"/> including tax
18+
/// </summary>
19+
public decimal TotalPrice { get; set; }
20+
21+
/// <summary>
22+
/// tax amount applied to this order item
23+
/// </summary>
24+
public decimal TaxAmount { get; set; }
25+
26+
/// <summary>
27+
/// 0: tax free, 1: normal tax, 2: reduced tax
28+
/// </summary>
29+
public byte? TaxIndex { get; set; }
30+
31+
public List<OrderItemAttribute> Attributes { get; set; }
32+
33+
34+
public bool IsCoupon { get; set; }
35+
36+
public bool IsDiscount { get; set; }
37+
38+
/// <summary>
39+
/// Sets the discount in percent
40+
/// </summary>
41+
public decimal Discount { get; set; }
42+
43+
public decimal DiscountedPrice => Math.Round(Discount != 0 ? TotalPrice * (100 - Discount) / 100 : TotalPrice,
44+
2, MidpointRounding.AwayFromZero);
45+
46+
public override string ToString()
47+
{
48+
return $"Q:{Quantity} TP:{TotalPrice} Tax:{TaxIndex} Discount:{Discount}";
49+
}
50+
}
51+
}

MinimalOrderApi/OrderItemAttribute.cs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Billbee.MinimalOrderApi
2+
{
3+
public class OrderItemAttribute
4+
{
5+
public string Id { get; set; }
6+
public string Name { get; set; }
7+
public string Value { get; set; }
8+
}
9+
}

Minimal Order Api/OrderStateEnum.cs MinimalOrderApi/OrderStateEnum.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace Minimal_Order_Api
1+
namespace Billbee.MinimalOrderApi
22
{
33
public enum OrderStateEnum
44
{

Minimal Order Api/PaymentTypeEnum.cs MinimalOrderApi/PaymentTypeEnum.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace Minimal_Order_Api
1+
namespace Billbee.MinimalOrderApi
22
{
33
public enum PaymentTypeEnum
44
{

Minimal Order Api/Program.cs MinimalOrderApi/Program.cs

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Collections.Generic;
33
using System.Linq;
44

5-
namespace Minimal_Order_Api
5+
namespace Billbee.MinimalOrderApi
66
{
77
internal class Program
88
{
@@ -48,6 +48,11 @@ public static void Main(string[] args)
4848
throw;
4949
}
5050
} while (++currentPage <= numberOfPages);
51+
52+
if (api.SerializeAccessToken() != accessToken)
53+
{
54+
Console.WriteLine("The access token was modified.");
55+
}
5156
}
5257

5358
Console.WriteLine($"Loaded {orders.Count} order(s).");

Minimal Order Api/RestClientBaseClass.cs MinimalOrderApi/RestClientBaseClass.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
using RestSharp.Deserializers;
1515
using RestSharp.Serializers;
1616

17-
namespace Minimal_Order_Api
17+
namespace Billbee.MinimalOrderApi
1818
{
1919
public delegate string PreProcessString(string xml);
2020

@@ -302,7 +302,6 @@ protected IRestResponse patchForResponse(string resource, NameValueCollection pa
302302

303303
protected virtual string parseError(RestSharp.IRestResponse response)
304304
{
305-
// Default handling. Works for inventorum, Debitoor and some other
306305
string errMsg = null;
307306
try
308307
{

MinimalOrderApi/SoldProduct.cs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace Billbee.MinimalOrderApi
2+
{
3+
public class SoldProduct
4+
{
5+
public string Id { get; set; }
6+
public string Title { get; set; }
7+
8+
public string SKU { get; set; }
9+
}
10+
}
File renamed without changes.

README.md

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
Read the following document carefully.
2+
It contains important information about the task itself and how to submit your solution.
3+
4+
## Task overview
5+
6+
Create a implementation of the [IOrderAPI](./MinimalOrderApi/IOrderAPI.cs).
7+
8+
Priorities:
9+
- The Implementation can be used with any access token (no hardcoded strings etc.)
10+
- If possible: All fields in the models should be filled by the implementation
11+
- Calculated prices are correct
12+
- Tax is correct calculated
13+
- Discounts (per position) should set to the `OrderItem.Discount` property.
14+
- The calculated total of the order must equal the `Order.TotalCost` (gross) which comes from the external system.
15+
16+
### `IOrderAPI.GetOrderList`
17+
This method is used for querying a list of orders which are created or modified after the the `startDate`.
18+
`vatRateRegular` and `vatRateReduced` are the default vat rates of the client. You can use this for calculating the tax amount
19+
if the API doesn't provide this information.
20+
You also need those to specify the `Order.TaxRateRegular`, `Order.TaxRateReduced` and `OrderItem.TaxIndex`.
21+
22+
Possible values for the tax index:
23+
- 0 = No vat applicable
24+
- 1 = Regular vat
25+
- 2 = Reduced vat.
26+
27+
`totalNumberOfOrders` and `totalNumberOfPages`: This parameters are used for pagination. Set them to the corresponding values.
28+
29+
### `IOrderAPI.DeserializeAccessToken` and `IOrderAPI.SerializeAccessToken`
30+
`IOrderAPI.DeserializeAccessToken` is called by the client before `IOrderAPI.GetOrderList`.
31+
Use this to setup your implementation for any api related authorization.
32+
33+
`IOrderAPI.SerializeAccessToken` is called by the client for storing the access token in a persistent storage.
34+
35+
## How to start
36+
1. Download the source of this repository
37+
```bash
38+
$ git clone https://github.com/billbeeio/order-api-implementation-test.git
39+
$ cd order-api-implementation-test
40+
$ git remote remove origin
41+
$ git checkout -b my-implementation
42+
```
43+
2. Create a implementation class `{NameOfTheImplementation}Api` inside the [`Billbee.MinimalOrderApi.Implementation`](./MinimalOrderApi/Implementation) namespace.
44+
3. Edit the [Program.cs](./MinimalOrderApi/Program.cs) and set the variables:
45+
```C#
46+
IOrderAPI api = null; // Your implementation
47+
string accessToken = null; // Your access token
48+
```
49+
4. Add the logic to your implementation.
50+
5. Run the console application to test your implementation.
51+
52+
### HTTP Interaction
53+
To interact with a HTTP service, your implementation can derive from the [RestClientBaseClass](./MinimalOrderApi/RestClientBaseClass.cs).
54+
55+
## Submit your solution
56+
1. Commit your changes using `git commit`
57+
2. Create a zip of the changed files using the following command in the git bash:
58+
```bash
59+
$ git archive --format=zip HEAD `git diff master HEAD --name-only` > `git branch --show-current`.zip
60+
````
61+
3. Send the generated zip file (named as `{BranchName}.zip`) attached to a mail to your contact at Billbee.

0 commit comments

Comments
 (0)