Skip to content

Commit 9fb6b5d

Browse files
taeyzzzThanetpon Kultontikorn
andauthored
add more type mapping (#28)
Co-authored-by: Thanetpon Kultontikorn <thanetpon.kultontikorn@agoda.com>
1 parent 2ada80f commit 9fb6b5d

File tree

5 files changed

+151
-2
lines changed

5 files changed

+151
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using Newtonsoft.Json;
4+
using Newtonsoft.Json.Converters;
5+
using Newtonsoft.Json.Linq;
6+
using Agoda.Graphql;
7+
8+
namespace Agoda.Graphql.SupplyApi.Queries.Promotion.GetHotelPromotionSuggestionSettingByCity
9+
{
10+
public class Query : QueryBase<Data>
11+
{
12+
private const string _query = @"query GetHotelPromotionSuggestionSettingByCity($cityId: Int!) {
13+
PromotionSuggestionSettingsByCityPromotionType(cityId: $cityId) {
14+
id
15+
cityId
16+
promotionTypeId
17+
startDate
18+
endDate
19+
startMonth
20+
endMonth
21+
discountValue
22+
promotionDiscountTypeId
23+
minAdvPurchase
24+
maxAdvPurchase
25+
stayOn
26+
minNightsStay
27+
bookTimeFrom
28+
bookTimeTo
29+
isActive
30+
lastUpdatedBy
31+
lastUpdatedWhen
32+
PromotionSuggestion {
33+
cityId
34+
promotionTypeId
35+
rank
36+
lastUpdatedBy
37+
lastUpdatedWhen
38+
}
39+
}
40+
}";
41+
42+
public int CityId { get; }
43+
44+
public Query(int cityId, IResultProcessor<Data> resultProcessor = null) : base(resultProcessor)
45+
{
46+
CityId = cityId;
47+
}
48+
49+
protected override string QueryText => _query;
50+
51+
protected override Dictionary<string, object> Variables => new Dictionary<string, object>
52+
{
53+
{ "cityId", CityId }
54+
};
55+
}
56+
57+
public sealed class Data
58+
{
59+
[JsonProperty("PromotionSuggestionSettingsByCityPromotionType")]
60+
public List<PromotionSuggestionSettingsByCityPromotionType> PromotionSuggestionSettingsByCityPromotionType { get; set; }
61+
}
62+
63+
public sealed class PromotionSuggestion
64+
{
65+
[JsonProperty("cityId")]
66+
public int CityId { get; set; }
67+
[JsonProperty("promotionTypeId")]
68+
public int PromotionTypeId { get; set; }
69+
[JsonProperty("rank")]
70+
public int Rank { get; set; }
71+
[JsonProperty("lastUpdatedBy")]
72+
public string LastUpdatedBy { get; set; }
73+
[JsonProperty("lastUpdatedWhen")]
74+
public DateTime? LastUpdatedWhen { get; set; }
75+
}
76+
77+
public sealed class PromotionSuggestionSettingsByCityPromotionType
78+
{
79+
[JsonProperty("id")]
80+
public int Id { get; set; }
81+
[JsonProperty("cityId")]
82+
public int CityId { get; set; }
83+
[JsonProperty("promotionTypeId")]
84+
public int PromotionTypeId { get; set; }
85+
[JsonProperty("startDate")]
86+
public int StartDate { get; set; }
87+
[JsonProperty("endDate")]
88+
public int EndDate { get; set; }
89+
[JsonProperty("startMonth")]
90+
public int StartMonth { get; set; }
91+
[JsonProperty("endMonth")]
92+
public int EndMonth { get; set; }
93+
[JsonProperty("discountValue")]
94+
public double DiscountValue { get; set; }
95+
[JsonProperty("promotionDiscountTypeId")]
96+
public int PromotionDiscountTypeId { get; set; }
97+
[JsonProperty("minAdvPurchase")]
98+
public int? MinAdvPurchase { get; set; }
99+
[JsonProperty("maxAdvPurchase")]
100+
public int? MaxAdvPurchase { get; set; }
101+
[JsonProperty("stayOn")]
102+
public string StayOn { get; set; }
103+
[JsonProperty("minNightsStay")]
104+
public int? MinNightsStay { get; set; }
105+
[JsonProperty("bookTimeFrom")]
106+
public DateTime? BookTimeFrom { get; set; }
107+
[JsonProperty("bookTimeTo")]
108+
public DateTime? BookTimeTo { get; set; }
109+
[JsonProperty("isActive")]
110+
public bool IsActive { get; set; }
111+
[JsonProperty("lastUpdatedBy")]
112+
public string LastUpdatedBy { get; set; }
113+
[JsonProperty("lastUpdatedWhen")]
114+
public DateTime? LastUpdatedWhen { get; set; }
115+
[JsonProperty("PromotionSuggestion")]
116+
public PromotionSuggestion PromotionSuggestion { get; set; }
117+
}
118+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
query GetHotelPromotionSuggestionSettingByCity($cityId: Int!) {
2+
PromotionSuggestionSettingsByCityPromotionType(cityId: $cityId){
3+
id,
4+
cityId,
5+
promotionTypeId,
6+
startDate,
7+
endDate,
8+
startMonth,
9+
endMonth,
10+
discountValue,
11+
promotionDiscountTypeId,
12+
minAdvPurchase,
13+
maxAdvPurchase,
14+
stayOn,
15+
minNightsStay,
16+
bookTimeFrom,
17+
bookTimeTo,
18+
isActive,
19+
lastUpdatedBy,
20+
lastUpdatedWhen,
21+
PromotionSuggestion {
22+
cityId,
23+
promotionTypeId,
24+
rank,
25+
lastUpdatedBy,
26+
lastUpdatedWhen
27+
}
28+
}
29+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "agoda-graphql-csharp-generator",
3-
"version": "2.1.9",
3+
"version": "2.1.10",
44
"main": "dist/agoda-csharp-operation.js",
55
"exports": {
66
"./shared-types": "./dist/agoda-csharp-shared-types.js",

src/constants.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ export const SCALAR_TYPES = [
88
'DateTime',
99
'LocalDate',
1010
'LocalDateTime',
11+
'LocalTime',
1112
'BigInt',
1213
'BigDecimal',
1314
'Long',
14-
'Json'
15+
'Json',
1516
];

src/naming.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const mapGraphQLTypeToCSharp = (typeName: string): string => {
1818
case 'ID': csharpType = 'string'; break;
1919
case 'LocalDate': csharpType = 'DateTime'; break;
2020
case 'LocalDateTime': csharpType = 'DateTime'; break;
21+
case 'LocalTime': csharpType = 'DateTime'; break;
2122
case 'Json': csharpType = 'JToken'; break;
2223
default:
2324
csharpType = toPascalCase(typeName);

0 commit comments

Comments
 (0)