@@ -22,32 +22,32 @@ public partial class TaskInput : AbstractSchema
2222{
2323 /// <summary>
2424 /// Initializes a new instance of the TaskInput class
25- /// with a StreamingInput
25+ /// with a ShopifyInput
2626 /// </summary>
27- /// <param name="actualInstance">An instance of StreamingInput .</param>
28- public TaskInput ( StreamingInput actualInstance )
27+ /// <param name="actualInstance">An instance of ShopifyInput .</param>
28+ public TaskInput ( ShopifyInput actualInstance )
2929 {
3030 ActualInstance =
3131 actualInstance ?? throw new ArgumentException ( "Invalid instance found. Must not be null." ) ;
3232 }
3333
3434 /// <summary>
3535 /// Initializes a new instance of the TaskInput class
36- /// with a DockerStreamsInput
36+ /// with a StreamingInput
3737 /// </summary>
38- /// <param name="actualInstance">An instance of DockerStreamsInput .</param>
39- public TaskInput ( DockerStreamsInput actualInstance )
38+ /// <param name="actualInstance">An instance of StreamingInput .</param>
39+ public TaskInput ( StreamingInput actualInstance )
4040 {
4141 ActualInstance =
4242 actualInstance ?? throw new ArgumentException ( "Invalid instance found. Must not be null." ) ;
4343 }
4444
4545 /// <summary>
4646 /// Initializes a new instance of the TaskInput class
47- /// with a ShopifyInput
47+ /// with a DockerStreamsInput
4848 /// </summary>
49- /// <param name="actualInstance">An instance of ShopifyInput .</param>
50- public TaskInput ( ShopifyInput actualInstance )
49+ /// <param name="actualInstance">An instance of DockerStreamsInput .</param>
50+ public TaskInput ( DockerStreamsInput actualInstance )
5151 {
5252 ActualInstance =
5353 actualInstance ?? throw new ArgumentException ( "Invalid instance found. Must not be null." ) ;
@@ -58,6 +58,16 @@ public TaskInput(ShopifyInput actualInstance)
5858 /// </summary>
5959 public sealed override object ActualInstance { get ; set ; }
6060
61+ /// <summary>
62+ /// Get the actual instance of `ShopifyInput`. If the actual instance is not `ShopifyInput`,
63+ /// the InvalidClassException will be thrown
64+ /// </summary>
65+ /// <returns>An instance of ShopifyInput</returns>
66+ public ShopifyInput AsShopifyInput ( )
67+ {
68+ return ( ShopifyInput ) ActualInstance ;
69+ }
70+
6171 /// <summary>
6272 /// Get the actual instance of `StreamingInput`. If the actual instance is not `StreamingInput`,
6373 /// the InvalidClassException will be thrown
@@ -79,13 +89,12 @@ public DockerStreamsInput AsDockerStreamsInput()
7989 }
8090
8191 /// <summary>
82- /// Get the actual instance of `ShopifyInput`. If the actual instance is not `ShopifyInput`,
83- /// the InvalidClassException will be thrown
92+ /// Check if the actual instance is of `ShopifyInput` type.
8493 /// </summary>
85- /// <returns>An instance of ShopifyInput </returns>
86- public ShopifyInput AsShopifyInput ( )
94+ /// <returns>Whether or not the instance is the type </returns>
95+ public bool IsShopifyInput ( )
8796 {
88- return ( ShopifyInput ) ActualInstance ;
97+ return ActualInstance . GetType ( ) == typeof ( ShopifyInput ) ;
8998 }
9099
91100 /// <summary>
@@ -106,15 +115,6 @@ public bool IsDockerStreamsInput()
106115 return ActualInstance . GetType ( ) == typeof ( DockerStreamsInput ) ;
107116 }
108117
109- /// <summary>
110- /// Check if the actual instance is of `ShopifyInput` type.
111- /// </summary>
112- /// <returns>Whether or not the instance is the type</returns>
113- public bool IsShopifyInput ( )
114- {
115- return ActualInstance . GetType ( ) == typeof ( ShopifyInput ) ;
116- }
117-
118118 /// <summary>
119119 /// Returns the string presentation of the object
120120 /// </summary>
@@ -198,44 +198,48 @@ JsonSerializerOptions options
198198 {
199199 var jsonDocument = JsonDocument . ParseValue ( ref reader ) ;
200200 var root = jsonDocument . RootElement ;
201- if ( root . ValueKind == JsonValueKind . Object && root . TryGetProperty ( "mapping" , out _ ) )
201+ if (
202+ root . ValueKind == JsonValueKind . Object
203+ && root . TryGetProperty ( "market" , out _ )
204+ && root . TryGetProperty ( "metafields" , out _ )
205+ )
202206 {
203207 try
204208 {
205- return new TaskInput ( jsonDocument . Deserialize < StreamingInput > ( JsonConfig . Options ) ) ;
209+ return new TaskInput ( jsonDocument . Deserialize < ShopifyInput > ( JsonConfig . Options ) ) ;
206210 }
207211 catch ( Exception exception )
208212 {
209213 // deserialization failed, try the next one
210- System . Diagnostics . Debug . WriteLine (
211- $ "Failed to deserialize into StreamingInput: { exception } "
212- ) ;
214+ System . Diagnostics . Debug . WriteLine ( $ "Failed to deserialize into ShopifyInput: { exception } ") ;
213215 }
214216 }
215- if ( root . ValueKind == JsonValueKind . Object && root . TryGetProperty ( "streams " , out _ ) )
217+ if ( root . ValueKind == JsonValueKind . Object && root . TryGetProperty ( "mapping " , out _ ) )
216218 {
217219 try
218220 {
219- return new TaskInput ( jsonDocument . Deserialize < DockerStreamsInput > ( JsonConfig . Options ) ) ;
221+ return new TaskInput ( jsonDocument . Deserialize < StreamingInput > ( JsonConfig . Options ) ) ;
220222 }
221223 catch ( Exception exception )
222224 {
223225 // deserialization failed, try the next one
224226 System . Diagnostics . Debug . WriteLine (
225- $ "Failed to deserialize into DockerStreamsInput : { exception } "
227+ $ "Failed to deserialize into StreamingInput : { exception } "
226228 ) ;
227229 }
228230 }
229- if ( root . ValueKind == JsonValueKind . Object )
231+ if ( root . ValueKind == JsonValueKind . Object && root . TryGetProperty ( "streams" , out _ ) )
230232 {
231233 try
232234 {
233- return new TaskInput ( jsonDocument . Deserialize < ShopifyInput > ( JsonConfig . Options ) ) ;
235+ return new TaskInput ( jsonDocument . Deserialize < DockerStreamsInput > ( JsonConfig . Options ) ) ;
234236 }
235237 catch ( Exception exception )
236238 {
237239 // deserialization failed, try the next one
238- System . Diagnostics . Debug . WriteLine ( $ "Failed to deserialize into ShopifyInput: { exception } ") ;
240+ System . Diagnostics . Debug . WriteLine (
241+ $ "Failed to deserialize into DockerStreamsInput: { exception } "
242+ ) ;
239243 }
240244 }
241245 throw new InvalidDataException (
0 commit comments