@@ -18,8 +18,7 @@ public struct NetworkService: Sendable {
1818 underlyingClient: Client (
1919 serverURL: try ! Servers . Server1. url ( ) ,
2020 transport: URLSessionTransport ( )
21- )
22- )
21+ ) )
2322 }
2423
2524 public func fetchApps( ) async -> Result < [ Components . Schemas . App ] , AppError > {
@@ -29,7 +28,7 @@ public struct NetworkService: Sendable {
2928 case let . ok( okResponse) :
3029 switch okResponse. body {
3130 case let . json( apps) :
32- return . success( apps)
31+ return . success( apps. apps )
3332 }
3433 default :
3534 return . failure( . network( type: . unknown) )
@@ -39,9 +38,43 @@ public struct NetworkService: Sendable {
3938 }
4039 }
4140
42- public func fetchInfo ( ) async -> Result < Components . Schemas . Info , AppError > {
41+ public func fetchCompany ( ) async -> Result < Components . Schemas . Company , AppError > {
4342 do {
44- let response = try await client. fetchInfo ( . init( ) )
43+ let response = try await client. getInfo ( . init( ) )
44+ switch response {
45+ case let . ok( okResponse) :
46+ switch okResponse. body {
47+ case let . json( info) :
48+ return . success( info. company)
49+ }
50+ default :
51+ return . failure( . network( type: . unknown) )
52+ }
53+ } catch {
54+ return . failure( . network( type: . unknown) )
55+ }
56+ }
57+
58+ public func fetchDeveloper( ) async -> Result < Components . Schemas . Developer , AppError > {
59+ do {
60+ let response = try await client. getInfo ( . init( ) )
61+ switch response {
62+ case let . ok( okResponse) :
63+ switch okResponse. body {
64+ case let . json( info) :
65+ return . success( info. developer)
66+ }
67+ default :
68+ return . failure( . network( type: . unknown) )
69+ }
70+ } catch {
71+ return . failure( . network( type: . unknown) )
72+ }
73+ }
74+
75+ public func fetchInfo( ) async -> Result < InfoResponse , AppError > {
76+ do {
77+ let response = try await client. getInfo ( . init( ) )
4578 switch response {
4679 case let . ok( okResponse) :
4780 switch okResponse. body {
@@ -62,8 +95,8 @@ public struct NetworkService: Sendable {
6295 switch response {
6396 case let . ok( okResponse) :
6497 switch okResponse. body {
65- case let . json( info ) :
66- return . success( info )
98+ case let . json( app ) :
99+ return . success( app . app )
67100 }
68101 default :
69102 return . failure( . network( type: . unknown) )
@@ -80,7 +113,7 @@ public struct NetworkService: Sendable {
80113 case let . ok( okResponse) :
81114 switch okResponse. body {
82115 case let . json( ads) :
83- return . success( ads)
116+ return . success( ads. ads )
84117 }
85118 default :
86119 return . failure( . network( type: . unknown) )
@@ -97,7 +130,7 @@ public struct NetworkService: Sendable {
97130 case let . ok( okResponse) :
98131 switch okResponse. body {
99132 case let . json( ads) :
100- return . success( ads)
133+ return . success( ads. ad )
101134 }
102135 default :
103136 return . failure( . network( type: . unknown) )
@@ -107,16 +140,16 @@ public struct NetworkService: Sendable {
107140 }
108141 }
109142
110- public func fetchSpecialOffers( ) async -> Result < [ Components . Schemas . SaleOffer ] , AppError > {
143+ public func fetchSpecialOffers( ) async -> Result < [ Components . Schemas . InAppPurchaseOffer ] , AppError > {
111144 do {
112- let response = try await client. getSaleOffers ( )
145+ let response = try await client. getInAppPurchaseOffers ( )
113146 switch response {
114147 case let . ok( okResponse) :
115148 switch okResponse. body {
116149 case let . json( offers) :
117- return . success( offers)
150+ return . success( offers. offers )
118151 }
119- case . undocumented, . badRequest:
152+ case . undocumented, . badRequest, . internalServerError , . notFound :
120153 return . failure( . network( type: . unexpectedStatusCode) )
121154 }
122155 } catch {
@@ -126,12 +159,12 @@ public struct NetworkService: Sendable {
126159
127160 public func fetchAppStoreProductIds( appId: String ) async -> Result < [ String ] , AppError > {
128161 do {
129- let response = try await client. GetAppStoreProductIds ( . init( path: . init( id: appId) ) )
162+ let response = try await client. getInAppPurchases ( . init( path: . init( id: appId) ) )
130163 switch response {
131164 case let . ok( okResponse) :
132165 switch okResponse. body {
133166 case let . json( productIds) :
134- return . success( productIds)
167+ return . success( productIds. productIds )
135168 }
136169 default :
137170 return . failure( . network( type: . unexpectedStatusCode) )
@@ -141,14 +174,31 @@ public struct NetworkService: Sendable {
141174 }
142175 }
143176
144- public func fetchAppStoreProducts ( appId: String ) async -> Result < Components . Schemas . AppStoreProducts , AppError > {
177+ public func fetchAppStoreBanner ( appId: String ) async -> Result < Components . Schemas . InAppPurchaseBanner , AppError > {
145178 do {
146- let response = try await client. GetAppStoreProducts ( . init( path: . init( id: appId) ) )
179+ let response = try await client. getInAppPurchases ( . init( path: . init( id: appId) ) )
147180 switch response {
148181 case let . ok( okResponse) :
149182 switch okResponse. body {
150183 case let . json( productIds) :
151- return . success( productIds)
184+ return . success( productIds. banner)
185+ }
186+ default :
187+ return . failure( . network( type: . unexpectedStatusCode) )
188+ }
189+ } catch {
190+ return . failure( . network( type: . unknown) )
191+ }
192+ }
193+
194+ public func fetchInAppPurchases( appId: String ) async -> Result < InAppPurchaseResponse , AppError > {
195+ do {
196+ let response = try await client. getInAppPurchases ( . init( path: . init( id: appId) ) )
197+ switch response {
198+ case let . ok( okResponse) :
199+ switch okResponse. body {
200+ case let . json( body) :
201+ return . success( body)
152202 }
153203 default :
154204 return . failure( . network( type: . unexpectedStatusCode) )
@@ -165,7 +215,7 @@ public struct NetworkService: Sendable {
165215 case let . ok( okResponse) :
166216 switch okResponse. body {
167217 case let . json( productIds) :
168- return . success( productIds)
218+ return . success( productIds. features )
169219 }
170220 default :
171221 return . failure( . network( type: . unexpectedStatusCode) )
0 commit comments