forked from dotnet-architecture/eShopOnContainers
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAPI.cs
More file actions
107 lines (90 loc) · 3.27 KB
/
Copy pathAPI.cs
File metadata and controls
107 lines (90 loc) · 3.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
namespace WebMVC.Infrastructure
{
public static class API
{
public static class Purchase
{
public static string AddItemToBasket(string baseUri) => $"{baseUri}/basket/items";
public static string UpdateBasketItem(string baseUri) => $"{baseUri}/basket/items";
public static string GetOrderDraft(string baseUri, string basketId) => $"{baseUri}/order/draft/{basketId}";
}
public static class Basket
{
public static string GetBasket(string baseUri, string basketId) => $"{baseUri}/{basketId}";
public static string UpdateBasket(string baseUri) => baseUri;
public static string CheckoutBasket(string baseUri) => $"{baseUri}/checkout";
public static string CleanBasket(string baseUri, string basketId) => $"{baseUri}/{basketId}";
}
public static class Order
{
public static string GetOrder(string baseUri, string orderId)
{
return $"{baseUri}/{orderId}";
}
public static string GetAllMyOrders(string baseUri)
{
return baseUri;
}
public static string AddNewOrder(string baseUri)
{
return $"{baseUri}/new";
}
public static string CancelOrder(string baseUri)
{
return $"{baseUri}/cancel";
}
public static string ShipOrder(string baseUri)
{
return $"{baseUri}/ship";
}
}
public static class Catalog
{
public static string GetAllCatalogItems(string baseUri, int page, int take, int? brand, int? type)
{
var filterQs = "";
if (type.HasValue)
{
var brandQs = (brand.HasValue) ? brand.Value.ToString() : string.Empty;
filterQs = $"/type/{type.Value}/brand/{brandQs}";
}
else if (brand.HasValue)
{
var brandQs = (brand.HasValue) ? brand.Value.ToString() : string.Empty;
filterQs = $"/type/all/brand/{brandQs}";
}
else
{
filterQs = string.Empty;
}
return $"{baseUri}items{filterQs}?pageIndex={page}&pageSize={take}";
}
public static string GetAllBrands(string baseUri)
{
return $"{baseUri}catalogBrands";
}
public static string GetAllTypes(string baseUri)
{
return $"{baseUri}catalogTypes";
}
}
public static class Marketing
{
public static string GetAllCampaigns(string baseUri, int take, int page)
{
return $"{baseUri}user?pageSize={take}&pageIndex={page}";
}
public static string GetAllCampaignById(string baseUri, int id)
{
return $"{baseUri}{id}";
}
}
public static class Locations
{
public static string CreateOrUpdateUserLocation(string baseUri)
{
return baseUri;
}
}
}
}