@@ -329,7 +329,11 @@ public virtual async Task<ICollection<Build>> GetBuildsAsync(
329329 using ( var response = await Client . SendAsync ( request , cancellationToken ) . ConfigureAwait ( false ) )
330330 {
331331 await EnsureSuccessAsync ( response ) . ConfigureAwait ( false ) ;
332- return await DeserializeAsync < List < Build > > ( response ) . ConfigureAwait ( false ) ;
332+ var builds = await DeserializeAsync < List < AutomationBuild > > ( response ) . ConfigureAwait ( false ) ;
333+
334+ return builds
335+ . Select ( ( p ) => p . Build )
336+ . ToList ( ) ;
333337 }
334338 }
335339 }
@@ -403,7 +407,9 @@ public virtual async Task<SessionDetail> GetSessionAsync(string sessionId, Cance
403407 using ( var response = await Client . SendAsync ( request , cancellationToken ) . ConfigureAwait ( false ) )
404408 {
405409 await EnsureSuccessAsync ( response ) . ConfigureAwait ( false ) ;
406- return await DeserializeAsync < SessionDetail > ( response ) . ConfigureAwait ( false ) ;
410+ var result = await DeserializeAsync < AutomationSessionDetail > ( response ) . ConfigureAwait ( false ) ;
411+
412+ return result ? . SessionDetail ;
407413 }
408414 }
409415 }
@@ -523,7 +529,11 @@ public virtual async Task<ICollection<Session>> GetSessionsAsync(
523529 using ( var response = await Client . SendAsync ( request , cancellationToken ) . ConfigureAwait ( false ) )
524530 {
525531 await EnsureSuccessAsync ( response ) . ConfigureAwait ( false ) ;
526- return await DeserializeAsync < List < Session > > ( response ) . ConfigureAwait ( false ) ;
532+ var sessions = await DeserializeAsync < List < AutomationSession > > ( response ) . ConfigureAwait ( false ) ;
533+
534+ return sessions
535+ . Select ( ( p ) => p . Session )
536+ . ToList ( ) ;
527537 }
528538 }
529539 }
@@ -708,7 +718,9 @@ public virtual async Task<Session> SetSessionStatusAsync(
708718 using ( var response = await Client . SendAsync ( request , cancellationToken ) . ConfigureAwait ( false ) )
709719 {
710720 await EnsureSuccessAsync ( response ) . ConfigureAwait ( false ) ;
711- return await DeserializeAsync < Session > ( response ) . ConfigureAwait ( false ) ;
721+ var session = await DeserializeAsync < AutomationSession > ( response ) . ConfigureAwait ( false ) ;
722+
723+ return session ? . Session ;
712724 }
713725 }
714726 }
@@ -942,5 +954,41 @@ private async Task<T> SetNameAsync<T>(
942954 }
943955 }
944956 }
957+
958+ /// <summary>
959+ /// A class representing a BrowserStack Automate build. This class cannot be inherited.
960+ /// </summary>
961+ private sealed class AutomationBuild
962+ {
963+ /// <summary>
964+ /// Gets or sets the build.
965+ /// </summary>
966+ [ JsonProperty ( "automation_build" ) ]
967+ public Build Build { get ; set ; }
968+ }
969+
970+ /// <summary>
971+ /// A class representing a BrowserStack Automate session. This class cannot be inherited.
972+ /// </summary>
973+ private sealed class AutomationSession
974+ {
975+ /// <summary>
976+ /// Gets or sets the session.
977+ /// </summary>
978+ [ JsonProperty ( "automation_session" ) ]
979+ public Session Session { get ; set ; }
980+ }
981+
982+ /// <summary>
983+ /// A class representing a BrowserStack Automate session's details. This class cannot be inherited.
984+ /// </summary>
985+ private sealed class AutomationSessionDetail
986+ {
987+ /// <summary>
988+ /// Gets or sets the session.
989+ /// </summary>
990+ [ JsonProperty ( "automation_session" ) ]
991+ public SessionDetail SessionDetail { get ; set ; }
992+ }
945993 }
946994}
0 commit comments