Skip to content

Commit

Permalink
Merge pull request #2340 from CruGlobal/GT-2445-remove-shared-codable…
Browse files Browse the repository at this point in the history
…-structs-for-json-api

GT-2445 Remove Share/Common/JsonApi these structs have been moved to RequestOperation
  • Loading branch information
levieggertcru authored Nov 8, 2024
2 parents d44ac82 + 8a47372 commit 06b2bf6
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 88 deletions.
20 changes: 0 additions & 20 deletions godtools.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,6 @@
4581696F2CDD011600039D03 /* PersistUserToolLanguageSettingsDataLayerDependencies.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4581696C2CDD011600039D03 /* PersistUserToolLanguageSettingsDataLayerDependencies.swift */; };
458169702CDD011600039D03 /* PersistUserToolLanguageSettingsDiContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4581696D2CDD011600039D03 /* PersistUserToolLanguageSettingsDiContainer.swift */; };
458169712CDD011600039D03 /* PersistUserToolLanguageSettingsDomainLayerDependencies.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4581696E2CDD011600039D03 /* PersistUserToolLanguageSettingsDomainLayerDependencies.swift */; };
4581D97F297AD21E00D056D6 /* JsonApiResponseData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4581D97E297AD21E00D056D6 /* JsonApiResponseData.swift */; };
4581EAA32BFBE194008115FF /* RealmSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 4581EAA22BFBE194008115FF /* RealmSwift */; };
4581EAA52BFBE257008115FF /* RealmSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 4581EAA42BFBE257008115FF /* RealmSwift */; };
4581EAA72BFBE2B9008115FF /* RealmSwift in Embed Frameworks */ = {isa = PBXBuildFile; productRef = 4581EAA22BFBE194008115FF /* RealmSwift */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
Expand Down Expand Up @@ -1381,8 +1380,6 @@
45EB9B8429F16CF200CA74A8 /* Image+OptionalUIImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45EB9B6E29F16CF200CA74A8 /* Image+OptionalUIImage.swift */; };
45EC429B272C87430052F2AA /* PassthroughValue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45EC429A272C87430052F2AA /* PassthroughValue.swift */; };
45EC5CF228CA2A4A0000AA2E /* ResourceModel+LanguageSupportable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45EC5CF128CA2A4A0000AA2E /* ResourceModel+LanguageSupportable.swift */; };
45EF23AC2B37314400E49716 /* JsonApiResponseBaseData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45EF23AB2B37314400E49716 /* JsonApiResponseBaseData.swift */; };
45EF23AE2B3731A300E49716 /* JsonApiResponseDataArray.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45EF23AD2B3731A300E49716 /* JsonApiResponseDataArray.swift */; };
45F1CE212B7D1F210008A3BC /* ToolLanguageDownloader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45F1CE202B7D1F210008A3BC /* ToolLanguageDownloader.swift */; };
45F267A128907F5D006679F2 /* RealmResourcesCacheSync.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45F267A028907F5D006679F2 /* RealmResourcesCacheSync.swift */; };
45F267A328907F67006679F2 /* RealmResourcesCacheSyncResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45F267A228907F67006679F2 /* RealmResourcesCacheSyncResult.swift */; };
Expand Down Expand Up @@ -2301,7 +2298,6 @@
4581696C2CDD011600039D03 /* PersistUserToolLanguageSettingsDataLayerDependencies.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PersistUserToolLanguageSettingsDataLayerDependencies.swift; sourceTree = "<group>"; };
4581696D2CDD011600039D03 /* PersistUserToolLanguageSettingsDiContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PersistUserToolLanguageSettingsDiContainer.swift; sourceTree = "<group>"; };
4581696E2CDD011600039D03 /* PersistUserToolLanguageSettingsDomainLayerDependencies.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PersistUserToolLanguageSettingsDomainLayerDependencies.swift; sourceTree = "<group>"; };
4581D97E297AD21E00D056D6 /* JsonApiResponseData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JsonApiResponseData.swift; sourceTree = "<group>"; };
45828BC7279CCB5300F6B5F3 /* MobileContentCardView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MobileContentCardView.swift; sourceTree = "<group>"; };
45828BC9279CCB6900F6B5F3 /* MobileContentCardViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MobileContentCardViewModel.swift; sourceTree = "<group>"; };
45828BCE279CCBD200F6B5F3 /* MobileContentFlowView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MobileContentFlowView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3035,8 +3031,6 @@
45EB9B6E29F16CF200CA74A8 /* Image+OptionalUIImage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Image+OptionalUIImage.swift"; sourceTree = "<group>"; };
45EC429A272C87430052F2AA /* PassthroughValue.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PassthroughValue.swift; sourceTree = "<group>"; };
45EC5CF128CA2A4A0000AA2E /* ResourceModel+LanguageSupportable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ResourceModel+LanguageSupportable.swift"; sourceTree = "<group>"; };
45EF23AB2B37314400E49716 /* JsonApiResponseBaseData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JsonApiResponseBaseData.swift; sourceTree = "<group>"; };
45EF23AD2B3731A300E49716 /* JsonApiResponseDataArray.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JsonApiResponseDataArray.swift; sourceTree = "<group>"; };
45F1CE202B7D1F210008A3BC /* ToolLanguageDownloader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToolLanguageDownloader.swift; sourceTree = "<group>"; };
45F267A028907F5D006679F2 /* RealmResourcesCacheSync.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RealmResourcesCacheSync.swift; sourceTree = "<group>"; };
45F267A228907F67006679F2 /* RealmResourcesCacheSyncResult.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RealmResourcesCacheSyncResult.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -6718,16 +6712,6 @@
path = ToolTraining;
sourceTree = "<group>";
};
4581D97D297AD16300D056D6 /* JsonApi */ = {
isa = PBXGroup;
children = (
45EF23AB2B37314400E49716 /* JsonApiResponseBaseData.swift */,
4581D97E297AD21E00D056D6 /* JsonApiResponseData.swift */,
45EF23AD2B3731A300E49716 /* JsonApiResponseDataArray.swift */,
);
path = JsonApi;
sourceTree = "<group>";
};
45828BC4279CCB3D00F6B5F3 /* ContentCard */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -8510,7 +8494,6 @@
4585E4B32B05738600223A9B /* BCP47LanguageIdentifier */,
45AD20AC25938EE500A096A0 /* FileCache */,
45AD20E8259391B000A096A0 /* Json */,
4581D97D297AD16300D056D6 /* JsonApi */,
45AD207725938B6A00A096A0 /* KeyboardObserver */,
45AF070D2B066266000EACF2 /* LocaleLanguageName */,
453E00052B29FB6B00029402 /* LocaleLanguageRegionName */,
Expand Down Expand Up @@ -13389,7 +13372,6 @@
45BDA6482954FF08007E259B /* HTMLDocumentData.swift in Sources */,
453F84DA2A02A0390005101E /* ArticleManifestAemRepository.swift in Sources */,
45D63E6E288F698C009B4610 /* RealmLanguage.swift in Sources */,
45EF23AC2B37314400E49716 /* JsonApiResponseBaseData.swift in Sources */,
45043F9F2BFB871400324573 /* ViewDeleteAccountProgressDomainModel.swift in Sources */,
45AD20B225938EE500A096A0 /* FileCache.swift in Sources */,
4556CEA829F2D57800643BBC /* RealmDatabaseProductionConfiguration.swift in Sources */,
Expand All @@ -13399,7 +13381,6 @@
45D95CCE271F3F1100263D46 /* MobileContentRendererEventAnalyticsTracking.swift in Sources */,
D4C2A58A2C35DA350035AB4D /* UserLessonLanguageFilterDataModel.swift in Sources */,
453D2F802AD88C1D001C44E3 /* GetLanguageSettingsInterfaceStringsRepositoryInterface.swift in Sources */,
4581D97F297AD21E00D056D6 /* JsonApiResponseData.swift in Sources */,
45920D592A8D4F2800E336A8 /* ToolCardLayout.swift in Sources */,
D4AFA44B2BAD0A1B00318023 /* ToolFilterCategoriesInterfaceStringsDomainModel.swift in Sources */,
454ADAD62ABDD9D400037C27 /* AppInterfaceLanguageButtonView.swift in Sources */,
Expand Down Expand Up @@ -13736,7 +13717,6 @@
45D63E52288F67CE009B4610 /* AppDomainLayerDependencies.swift in Sources */,
458CFE8F29D4E0B9007B423C /* ArticleWebViewModelFlowType.swift in Sources */,
45A835282AD1AE12004F5593 /* ToolDetailsFeatureDiContainer.swift in Sources */,
45EF23AE2B3731A300E49716 /* JsonApiResponseDataArray.swift in Sources */,
455EE8312AEC576F00C3205C /* DownloadToolProgressViewModel.swift in Sources */,
45192F4C2C470AD4005740E5 /* UserCountersAPIType.swift in Sources */,
45965D4D2B4488BD001C9AA5 /* GetDashboardInterfaceStringsRepositoryInterface.swift in Sources */,
Expand Down
20 changes: 0 additions & 20 deletions godtools/App/Share/Common/JsonApi/JsonApiResponseBaseData.swift

This file was deleted.

18 changes: 0 additions & 18 deletions godtools/App/Share/Common/JsonApi/JsonApiResponseData.swift

This file was deleted.

18 changes: 0 additions & 18 deletions godtools/App/Share/Common/JsonApi/JsonApiResponseDataArray.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import Foundation
import Combine
import RequestOperation

class LanguagesJsonFileCache {

Expand Down Expand Up @@ -36,8 +37,8 @@ class LanguagesJsonFileCache {
}

do {
let responseData: JsonApiResponseData<[LanguageModel]> = try JSONDecoder().decode(JsonApiResponseData<[LanguageModel]>.self, from: data)
return .success(responseData.data)
let responseData: JsonApiResponseDataArray<LanguageModel> = try JSONDecoder().decode(JsonApiResponseDataArray<LanguageModel>.self, from: data)
return .success(responseData.dataArray)
}
catch let error {
return .failure(error)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import Foundation
import RequestOperation

struct ResourceModel: ResourceModelType, Decodable, Identifiable {

Expand Down Expand Up @@ -159,16 +160,16 @@ struct ResourceModel: ResourceModelType, Decodable, Identifiable {
attachmentIds = attachments.map({$0.id})

do {
let metatool = try relationshipsContainer?.decodeIfPresent(JsonApiResponseData<JsonApiResponseBaseData>.self, forKey: .metatool)
metatoolId = metatool?.data.id
let metatool = try relationshipsContainer?.decodeIfPresent(JsonApiResponseDataObject<JsonApiResponseBaseData>.self, forKey: .metatool)
metatoolId = metatool?.dataObject.id
}
catch {
metatoolId = nil
}

do {
let defaultVariant = try relationshipsContainer?.decodeIfPresent(JsonApiResponseData<JsonApiResponseBaseData>.self, forKey: .defaultVariant)
defaultVariantId = defaultVariant?.data.id
let defaultVariant = try relationshipsContainer?.decodeIfPresent(JsonApiResponseDataObject<JsonApiResponseBaseData>.self, forKey: .defaultVariant)
defaultVariantId = defaultVariant?.dataObject.id
}
catch {
defaultVariantId = nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ class UserCountersAPI: UserCountersAPIType {
let fetchRequest = getUserCountersRequest()

return authSession.sendAuthenticatedRequest(urlRequest: fetchRequest, urlSession: ignoreCacheSession)
.decode(type: JsonApiResponseData<[UserCounterDecodable]>.self, decoder: JSONDecoder())
.decode(type: JsonApiResponseDataArray<UserCounterDecodable>.self, decoder: JSONDecoder())
.map {
return $0.data
return $0.dataArray
}
.eraseToAnyPublisher()
}
Expand All @@ -41,9 +41,9 @@ class UserCountersAPI: UserCountersAPIType {
let incrementRequest = getIncrementUserCountersRequest(id: id, increment: increment)

return authSession.sendAuthenticatedRequest(urlRequest: incrementRequest, urlSession: ignoreCacheSession)
.decode(type: JsonApiResponseData<UserCounterDecodable>.self, decoder: JSONDecoder())
.decode(type: JsonApiResponseDataObject<UserCounterDecodable>.self, decoder: JSONDecoder())
.map {
return $0.data
return $0.dataObject
}
.eraseToAnyPublisher()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ class UserDetailsAPI {
let urlRequest: URLRequest = getAuthUserDetailsRequest()

return authSession.sendAuthenticatedRequest(urlRequest: urlRequest, urlSession: ignoreCacheSession)
.decode(type: JsonApiResponseData<MobileContentApiUsersMeCodable>.self, decoder: JSONDecoder())
.decode(type: JsonApiResponseDataObject<MobileContentApiUsersMeCodable>.self, decoder: JSONDecoder())
.map {
return $0.data
return $0.dataObject
}
.eraseToAnyPublisher()
}
Expand Down

0 comments on commit 06b2bf6

Please sign in to comment.