44using GoAffPro . Client . Events ;
55using GoAffPro . Client . Exceptions ;
66using GoAffPro . Client . Generated . Models ;
7- using GoAffPro . Client . Generated . User . Feed . Orders ;
87using GoAffPro . Client . Generated . User . Sites ;
98using GoAffPro . Client . Policies ;
109using Microsoft . Extensions . Http ;
1110using Microsoft . Kiota . Abstractions ;
1211using Microsoft . Kiota . Abstractions . Authentication ;
1312using Microsoft . Kiota . Http . HttpClientLibrary ;
14- using GetSiteFieldsQueryParameterType = GoAffPro . Client . Generated . User . Sites . GetFieldsQueryParameterType ;
1513using GetOrderFieldsQueryParameterType = GoAffPro . Client . Generated . User . Feed . Orders . GetFieldsQueryParameterType ;
14+ using GetSiteFieldsQueryParameterType = GoAffPro . Client . Generated . User . Sites . GetFieldsQueryParameterType ;
1615
1716namespace GoAffPro . Client ;
1817
@@ -241,9 +240,9 @@ await Api.User.Sites.GetAsync(config =>
241240 config . QueryParameters . StatusAsGetStatusQueryParameterType = status . ToUpperInvariant ( ) switch
242241 {
243242 "APPROVED" => GetStatusQueryParameterType . Approved ,
244- "PENDING" => GetStatusQueryParameterType . Pending ,
245- "BLOCKED" => GetStatusQueryParameterType . Blocked ,
246- _ => null ,
243+ "PENDING" => GetStatusQueryParameterType . Pending ,
244+ "BLOCKED" => GetStatusQueryParameterType . Blocked ,
245+ _ => null ,
247246 } ;
248247 }
249248 } , cancellationToken ) . ConfigureAwait ( false )
@@ -310,25 +309,34 @@ public async Task StartEventObserverAsync(
310309
311310 _ = RewardDetected ; // keep obsolete member in compiled output
312311
313- DateTimeOffset lastOrderPoll = OrderObserverStartTime ?? DateTimeOffset . UtcNow ;
312+ DateTimeOffset lastOrderPoll = OrderObserverStartTime ?? DateTimeOffset . UtcNow ;
314313 DateTimeOffset lastTrafficPoll = TrafficObserverStartTime ?? DateTimeOffset . UtcNow ;
315- DateTimeOffset lastPayoutPoll = PayoutObserverStartTime ?? DateTimeOffset . UtcNow ;
314+ DateTimeOffset lastPayoutPoll = PayoutObserverStartTime ?? DateTimeOffset . UtcNow ;
316315
317316 while ( ! cancellationToken . IsCancellationRequested )
318317 {
319318 DateTimeOffset orderTo = DateTimeOffset . UtcNow ;
320319 foreach ( UserOrderFeedItem order in await PollOrdersAsync ( lastOrderPoll , orderTo , validatedPageSize , cancellationToken ) . ConfigureAwait ( false ) )
320+ {
321321 OrderDetected ? . Invoke ( this , new OrderDetectedEventArgs ( order ) ) ;
322+ }
323+
322324 lastOrderPoll = orderTo ;
323325
324326 DateTimeOffset trafficTo = DateTimeOffset . UtcNow ;
325327 foreach ( UserTrafficFeedItem item in await PollTrafficAsync ( lastTrafficPoll , trafficTo , validatedPageSize , cancellationToken ) . ConfigureAwait ( false ) )
328+ {
326329 TrafficDetected ? . Invoke ( this , new TrafficDetectedEventArgs ( item ) ) ;
330+ }
331+
327332 lastTrafficPoll = trafficTo ;
328333
329334 DateTimeOffset payoutTo = DateTimeOffset . UtcNow ;
330335 foreach ( UserPayoutFeedItem payout in await PollPayoutsAsync ( lastPayoutPoll , payoutTo , validatedPageSize , cancellationToken ) . ConfigureAwait ( false ) )
336+ {
331337 PayoutDetected ? . Invoke ( this , new PayoutDetectedEventArgs ( payout ) ) ;
338+ }
339+
332340 lastPayoutPoll = payoutTo ;
333341
334342 await Task . Delay ( interval , cancellationToken ) . ConfigureAwait ( false ) ;
@@ -353,7 +361,10 @@ public async IAsyncEnumerable<UserOrderFeedItem> NewOrdersAsync(
353361 {
354362 DateTimeOffset to = DateTimeOffset . UtcNow ;
355363 foreach ( UserOrderFeedItem order in await PollOrdersAsync ( lastPoll , to , size , cancellationToken ) . ConfigureAwait ( false ) )
364+ {
356365 yield return order ;
366+ }
367+
357368 lastPoll = to ;
358369 await Task . Delay ( interval , cancellationToken ) . ConfigureAwait ( false ) ;
359370 }
@@ -373,7 +384,10 @@ public async IAsyncEnumerable<UserTrafficFeedItem> NewTrafficAsync(
373384 {
374385 DateTimeOffset to = DateTimeOffset . UtcNow ;
375386 foreach ( UserTrafficFeedItem item in await PollTrafficAsync ( lastPoll , to , size , cancellationToken ) . ConfigureAwait ( false ) )
387+ {
376388 yield return item ;
389+ }
390+
377391 lastPoll = to ;
378392 await Task . Delay ( interval , cancellationToken ) . ConfigureAwait ( false ) ;
379393 }
@@ -393,7 +407,10 @@ public async IAsyncEnumerable<UserPayoutFeedItem> NewPayoutsAsync(
393407 {
394408 DateTimeOffset to = DateTimeOffset . UtcNow ;
395409 foreach ( UserPayoutFeedItem payout in await PollPayoutsAsync ( lastPoll , to , size , cancellationToken ) . ConfigureAwait ( false ) )
410+ {
396411 yield return payout ;
412+ }
413+
397414 lastPoll = to ;
398415 await Task . Delay ( interval , cancellationToken ) . ConfigureAwait ( false ) ;
399416 }
@@ -414,7 +431,10 @@ public async IAsyncEnumerable<UserProductFeedItem> NewProductsAsync(
414431 ( IReadOnlyList < UserProductFeedItem > products , int ? nextId ) = await PollProductsAsync ( lastId , size , cancellationToken ) . ConfigureAwait ( false ) ;
415432 lastId = nextId ;
416433 foreach ( UserProductFeedItem product in products )
434+ {
417435 yield return product ;
436+ }
437+
418438 await Task . Delay ( interval , cancellationToken ) . ConfigureAwait ( false ) ;
419439 }
420440 }
@@ -434,7 +454,10 @@ public async IAsyncEnumerable<UserTransactionItem> NewTransactionsAsync(
434454 ( IReadOnlyList < UserTransactionItem > transactions , int ? nextId ) = await PollTransactionsAsync ( lastId , size , cancellationToken ) . ConfigureAwait ( false ) ;
435455 lastId = nextId ;
436456 foreach ( UserTransactionItem tx in transactions )
457+ {
437458 yield return tx ;
459+ }
460+
438461 await Task . Delay ( interval , cancellationToken ) . ConfigureAwait ( false ) ;
439462 }
440463 }
@@ -456,7 +479,11 @@ public async IAsyncEnumerable<UserRewardFeedItem> NewRewardsAsync(
456479 /// <summary>Disposes resources owned by this client.</summary>
457480 public void Dispose ( )
458481 {
459- if ( ! _disposeHttpClient ) return ;
482+ if ( ! _disposeHttpClient )
483+ {
484+ return ;
485+ }
486+
460487 ( _requestAdapter as IDisposable ) ? . Dispose ( ) ;
461488 _httpClient . Dispose ( ) ;
462489 }
@@ -551,15 +578,19 @@ await Api.User.Feed.Products.GetAsync(config =>
551578 ?? new UserProductFeedResponse ( ) ) . ConfigureAwait ( false ) ;
552579
553580 if ( response . Products is not { Count : > 0 } )
581+ {
554582 return ( [ ] , lastId ) ;
583+ }
555584
556585 int ? maxId = response . Products
557586 . Select ( p => ToNullableInt ( p . ProductId ) ?? ToNullableInt ( p . Id ) )
558587 . Where ( v => v . HasValue ) . Select ( v => v ! . Value )
559588 . DefaultIfEmpty ( lastId ?? int . MinValue ) . Max ( ) ;
560589
561590 if ( ! lastId . HasValue )
591+ {
562592 return ( [ ] , maxId == int . MinValue ? null : maxId ) ;
593+ }
563594
564595 var newItems = response . Products
565596 . Where ( p => { int ? id = ToNullableInt ( p . ProductId ) ?? ToNullableInt ( p . Id ) ; return id > lastId ; } )
@@ -581,14 +612,18 @@ await Api.User.Feed.Transactions.GetAsync(config =>
581612 ?? new UserTransactionFeedResponse ( ) ) . ConfigureAwait ( false ) ;
582613
583614 if ( response . Transactions is not { Count : > 0 } )
615+ {
584616 return ( [ ] , lastId ) ;
617+ }
585618
586619 int ? maxId = response . Transactions
587620 . Select ( t => t . TxId ) . Where ( v => v . HasValue ) . Select ( v => v ! . Value )
588621 . DefaultIfEmpty ( lastId ?? int . MinValue ) . Max ( ) ;
589622
590623 if ( ! lastId . HasValue )
624+ {
591625 return ( [ ] , maxId == int . MinValue ? null : maxId ) ;
626+ }
592627
593628 var newItems = response . Transactions
594629 . Where ( t => t . TxId > lastId )
@@ -598,11 +633,15 @@ await Api.User.Feed.Transactions.GetAsync(config =>
598633 return ( newItems , maxId == int . MinValue ? lastId : maxId ) ;
599634 }
600635
601- private static int ? ToNullableInt ( UserProductFeedItem . UserProductFeedItem_product_id ? v ) =>
602- v ? . Integer ?? ( int . TryParse ( v ? . String , NumberStyles . Integer , CultureInfo . InvariantCulture , out int p ) ? p : null ) ;
636+ private static int ? ToNullableInt ( UserProductFeedItem . UserProductFeedItem_product_id ? v )
637+ {
638+ return v ? . Integer ?? ( int . TryParse ( v ? . String , NumberStyles . Integer , CultureInfo . InvariantCulture , out int p ) ? p : null ) ;
639+ }
603640
604- private static int ? ToNullableInt ( UserProductFeedItem . UserProductFeedItem_id ? v ) =>
605- v ? . Integer ?? ( int . TryParse ( v ? . String , NumberStyles . Integer , CultureInfo . InvariantCulture , out int p ) ? p : null ) ;
641+ private static int ? ToNullableInt ( UserProductFeedItem . UserProductFeedItem_id ? v )
642+ {
643+ return v ? . Integer ?? ( int . TryParse ( v ? . String , NumberStyles . Integer , CultureInfo . InvariantCulture , out int p ) ? p : null ) ;
644+ }
606645
607646 private static HttpClient CreateHttpClient ( GoAffProClientOptions options )
608647 {
@@ -625,8 +664,10 @@ private static GoAffProClientOptions ValidateOptions(GoAffProClientOptions optio
625664 return options ;
626665 }
627666
628- private static int ValidatePageSize ( int pageSize ) =>
629- pageSize > 0 ? pageSize : throw new ArgumentOutOfRangeException ( nameof ( pageSize ) , pageSize , "Page size must be greater than zero." ) ;
667+ private static int ValidatePageSize ( int pageSize )
668+ {
669+ return pageSize > 0 ? pageSize : throw new ArgumentOutOfRangeException ( nameof ( pageSize ) , pageSize , "Page size must be greater than zero." ) ;
670+ }
630671
631672 private static async Task < T > ExecuteAsync < T > ( Func < Task < T > > action )
632673 {
0 commit comments