Skip to content

Commit 20d0f63

Browse files
taeyzzzThanetpon Kultontikorn
andauthored
gqp codegen plugin (#16)
* plugin work * refactor config codegen * WIP: plugin * WIP: implement result property * WIP: refactor * refactoring * refactoring * WIP: refactor * ready to publish --------- Co-authored-by: Thanetpon Kultontikorn <[email protected]>
1 parent a647ac2 commit 20d0f63

13 files changed

+3777
-16108
lines changed

Agoda.Graphql/BookingQueries/DiscountBreakdown/BookingDiscountsByBookingIds.generated.cs

Lines changed: 25 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,10 @@
44
using Newtonsoft.Json.Converters;
55
using Agoda.Graphql;
66

7-
8-
9-
10-
#region BookingDisountsByBookingIds
11-
12-
namespace Agoda.Graphql.BookingQueries.DiscountBreakdown.BookingDiscountsByBookingIds
7+
namespace Agoda.Graphql.BookingDisountsByBookingIds
138
{
14-
15-
/// <summary>Operation Type</summary>
169
public partial class Query : QueryBase<Data>
17-
{
10+
{
1811
private const string _query = @"query BookingDisountsByBookingIds($bookingIds: [Int!]!) {
1912
result: BookingDetailsByBookingIds(bookingIds: $bookingIds) {
2013
bookingId
@@ -32,84 +25,63 @@ public partial class Query : QueryBase<Data>
3225
}
3326
}";
3427

28+
public List<int> BookingIds { get; }
29+
3530
public Query(List<int> bookingIds, IResultProcessor<Data> resultProcessor = null) : base(resultProcessor)
3631
{
3732
BookingIds = bookingIds;
3833
}
3934

40-
public List<int> BookingIds { get; }
4135
protected override string QueryText => _query;
4236

4337
protected override Dictionary<string, object> Variables => new Dictionary<string, object>
4438
{
45-
{ "bookingIds", BookingIds },
46-
};
39+
{ "bookingIds", BookingIds }
40+
};
4741
}
4842

4943
public sealed class Data
50-
{
51-
52-
53-
[JsonProperty("result")]
54-
public List<Result> Result { get; set; }
55-
}
56-
57-
58-
/// <summary>Inner Model</summary>
59-
public sealed class Result
60-
{
61-
62-
63-
[JsonProperty("bookingId")]
64-
public int BookingId { get; set; }
65-
66-
67-
[JsonProperty("propertyBooking")]
68-
public PropertyBooking PropertyBooking { get; set; }
44+
{
45+
[JsonProperty("BookingDetailsByBookingIds")]
46+
public List<BookingDetailsByBookingIds> BookingDetailsByBookingIds { get; set; }
6947
}
7048

71-
/// <summary>Inner Model</summary>
72-
public sealed class PropertyBooking
73-
{
74-
75-
76-
[JsonProperty("bookingDiscounts")]
77-
public List<BookingDiscounts> BookingDiscounts { get; set; }
78-
}
79-
80-
/// <summary>Inner Model</summary>
8149
public sealed class BookingDiscounts
82-
{
83-
84-
50+
{
8551
[JsonProperty("bookingId")]
8652
public long BookingId { get; set; }
8753

88-
8954
[JsonProperty("discountType")]
9055
public int DiscountType { get; set; }
9156

92-
9357
[JsonProperty("discountId")]
9458
public int DiscountId { get; set; }
9559

96-
9760
[JsonProperty("discountRateType")]
9861
public int DiscountRateType { get; set; }
9962

100-
10163
[JsonProperty("discountRate")]
10264
public decimal DiscountRate { get; set; }
10365

104-
10566
[JsonProperty("discountName")]
10667
public string DiscountName { get; set; }
10768

108-
10969
[JsonProperty("appliedDate")]
11070
public string AppliedDate { get; set; }
11171
}
72+
73+
public sealed class PropertyBooking
74+
{
75+
[JsonProperty("bookingDiscounts")]
76+
public List<BookingDiscounts> BookingDiscounts { get; set; }
77+
}
78+
79+
public sealed class BookingDetailsByBookingIds
80+
{
81+
[JsonProperty("bookingId")]
82+
public int BookingId { get; set; }
83+
84+
[JsonProperty("propertyBooking")]
85+
public PropertyBooking PropertyBooking { get; set; }
86+
}
11287
}
113-
114-
#endregion
115-

Agoda.Graphql/SupplyApi/Queries/Availabilities/GetAvailabilities.generated.cs

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,18 @@
44
using Newtonsoft.Json.Converters;
55
using Agoda.Graphql;
66

7-
8-
9-
10-
#region GetAvailabilities
11-
12-
namespace Agoda.Graphql.SupplyApi.Queries.Availabilities.GetAvailabilities
7+
namespace Agoda.Graphql.GetAvailabilities
138
{
14-
15-
/// <summary>Operation Type</summary>
169
public partial class Query : QueryBase<Data>
17-
{
10+
{
1811
private const string _query = @"query GetAvailabilities($propertyId: String!, $dmcId: Int!, $roomTypeId: String, $startDate: Date!, $endDate: Date!) {
19-
Availabilities(hotelId: $propertyId, dmcId: $dmcId, roomTypeId: $roomTypeId, startDate: $startDate, endDate: $endDate) {
12+
Availabilities(
13+
hotelId: $propertyId
14+
dmcId: $dmcId
15+
roomTypeId: $roomTypeId
16+
startDate: $startDate
17+
endDate: $endDate
18+
) {
2019
propertyId
2120
roomId
2221
dmcId
@@ -54,23 +53,21 @@ public Query(string propertyId, int dmcId, string roomTypeId, DateTime startDate
5453
{ "dmcId", DmcId },
5554
{ "roomTypeId", RoomTypeId },
5655
{ "startDate", StartDate.ToString("yyyy-MM-dd") },
57-
{ "endDate", EndDate.ToString("yyyy-MM-dd") },
58-
};
56+
{ "endDate", EndDate.ToString("yyyy-MM-dd") }
57+
};
5958
}
6059

6160
public sealed class Data
62-
{
63-
61+
{
6462

6563
[JsonProperty("Availabilities")]
6664
public List<Availabilities> Availabilities { get; set; }
6765
}
68-
6966

7067
/// <summary>Inner Model</summary>
7168
public sealed class Availabilities
7269
{
73-
70+
7471

7572
[JsonProperty("propertyId")]
7673
public string PropertyId { get; set; }
@@ -120,6 +117,3 @@ public sealed class Availabilities
120117
public DateTime? ModifiedWhen { get; set; }
121118
}
122119
}
123-
124-
#endregion
125-

Agoda.Graphql/SupplyApi/Queries/Availabilities/UpdateAvailability.generated.cs

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,22 @@
44
using Newtonsoft.Json.Converters;
55
using Agoda.Graphql;
66

7-
8-
9-
10-
#region UpdateAvailability
11-
12-
namespace Agoda.Graphql.SupplyApi.Queries.Availabilities.UpdateAvailability
7+
namespace Agoda.Graphql.UpdateAvailability
138
{
14-
15-
/// <summary>Operation Type</summary>
169
public partial class Mutation : QueryBase<Data>
17-
{
10+
{
1811
private const string _query = @"mutation UpdateAvailability($dmcId: Int!, $hotelId: String!, $roomTypeId: String!, $userId: String!, $startDate: Date!, $endDate: Date!, $regularAllotment: Int, $guaranteedAllotment: Int, $dayOfWeek: [Int!]) {
19-
AvailabilityMutation(dmcId: $dmcId, hotelId: $hotelId, roomTypeId: $roomTypeId, endDate: $endDate, startDate: $startDate, userId: $userId, regularAllotment: $regularAllotment, guaranteedAllotment: $guaranteedAllotment, dayOfWeek: $dayOfWeek) {
12+
AvailabilityMutation(
13+
dmcId: $dmcId
14+
hotelId: $hotelId
15+
roomTypeId: $roomTypeId
16+
endDate: $endDate
17+
startDate: $startDate
18+
userId: $userId
19+
regularAllotment: $regularAllotment
20+
guaranteedAllotment: $guaranteedAllotment
21+
dayOfWeek: $dayOfWeek
22+
) {
2023
regularAllotment
2124
guaranteedAllotment
2225
guaranteedAllotmentUsed
@@ -32,7 +35,17 @@ public partial class Mutation : QueryBase<Data>
3235
}
3336
}";
3437

35-
public Mutation(int dmcId, string hotelId, string roomTypeId, string userId, DateTime startDate, DateTime endDate, int? regularAllotment, int? guaranteedAllotment, List<int?> dayOfWeek, IResultProcessor<Data> resultProcessor = null) : base(resultProcessor)
38+
public int DmcId { get; }
39+
public string HotelId { get; }
40+
public string RoomTypeId { get; }
41+
public string UserId { get; }
42+
public DateTime StartDate { get; }
43+
public DateTime EndDate { get; }
44+
public int? RegularAllotment { get; }
45+
public int? GuaranteedAllotment { get; }
46+
public List<int>? DayOfWeek { get; }
47+
48+
public Mutation(int dmcId, string hotelId, string roomTypeId, string userId, DateTime startDate, DateTime endDate, int? regularAllotment, int? guaranteedAllotment, List<int>? dayOfWeek, IResultProcessor<Data> resultProcessor = null) : base(resultProcessor)
3649
{
3750
DmcId = dmcId;
3851
HotelId = hotelId;
@@ -45,15 +58,6 @@ public Mutation(int dmcId, string hotelId, string roomTypeId, string userId, Dat
4558
DayOfWeek = dayOfWeek;
4659
}
4760

48-
public int DmcId { get; }
49-
public string HotelId { get; }
50-
public string RoomTypeId { get; }
51-
public string UserId { get; }
52-
public DateTime StartDate { get; }
53-
public DateTime EndDate { get; }
54-
public int? RegularAllotment { get; }
55-
public int? GuaranteedAllotment { get; }
56-
public List<int?> DayOfWeek { get; }
5761
protected override string QueryText => _query;
5862

5963
protected override Dictionary<string, object> Variables => new Dictionary<string, object>
@@ -66,23 +70,21 @@ public Mutation(int dmcId, string hotelId, string roomTypeId, string userId, Dat
6670
{ "endDate", EndDate.ToString("yyyy-MM-dd") },
6771
{ "regularAllotment", RegularAllotment },
6872
{ "guaranteedAllotment", GuaranteedAllotment },
69-
{ "dayOfWeek", DayOfWeek },
70-
};
73+
{ "dayOfWeek", DayOfWeek }
74+
};
7175
}
7276

7377
public sealed class Data
74-
{
75-
78+
{
7679

7780
[JsonProperty("AvailabilityMutation")]
78-
public List<AvailabilityMutation> AvailabilityMutation { get; set; }
81+
public AvailabilityMutation AvailabilityMutation { get; set; }
7982
}
80-
8183

8284
/// <summary>Inner Model</summary>
8385
public sealed class AvailabilityMutation
8486
{
85-
87+
8688

8789
[JsonProperty("regularAllotment")]
8890
public int? RegularAllotment { get; set; }
@@ -109,7 +111,7 @@ public sealed class AvailabilityMutation
109111

110112

111113
[JsonProperty("dmcId")]
112-
public int DmcId { get; set; }
114+
public string DmcId { get; set; }
113115

114116

115117
[JsonProperty("roomId")]
@@ -125,13 +127,10 @@ public sealed class AvailabilityMutation
125127

126128

127129
[JsonProperty("modifiedWhen")]
128-
public DateTime? ModifiedWhen { get; set; }
130+
public DateTime ModifiedWhen { get; set; }
129131

130132

131133
[JsonProperty("modifiedBy")]
132134
public string ModifiedBy { get; set; }
133135
}
134136
}
135-
136-
#endregion
137-

0 commit comments

Comments
 (0)