Skip to content

Commit

Permalink
Revert "Switch to Flight-School's AnyCodable from my own CodableAny"
Browse files Browse the repository at this point in the history
This reverts commit abd1d1d.
  • Loading branch information
amirsaam committed Jul 15, 2024
1 parent abd1d1d commit 21e9d6a
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
}
},
{
"identity" : "anycodable",
"identity" : "codableany",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Flight-School/AnyCodable.git",
"location" : "https://github.com/amirsaam/CodableAny.git",
"state" : {
"revision" : "862808b2070cd908cb04f9aafe7de83d35f81b05",
"version" : "0.6.7"
"revision" : "eec6d8e967ff9489e9a20a83d081585e6799bd70",
"version" : "0.1.0"
}
},
{
Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let package = Package(
dependencies: [
.package(url: "https://github.com/Alamofire/Alamofire.git", from: "5.6.1"),
.package(url: "https://github.com/groue/Semaphore.git", from: "0.0.6"),
.package(url: "https://github.com/Flight-School/AnyCodable.git", from: "0.6.0")
.package(url: "https://github.com/amirsaam/CodableAny.git", from: "0.1.0")
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
Expand All @@ -29,7 +29,7 @@ let package = Package(
dependencies: [
"Alamofire",
"Semaphore",
"AnyCodable"
"CodableAny"
]
),
.testTarget(
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ then you can pass `patreonCallbackCode` to the `getOAuthTokens` function.
## A Problem in Patreon's API

Unfortunately, when I was trying to retrieve all data about Creator's campaign, I have encountered a bizarre situation where returning data with same name with no any distinguishing ability could have various structures and I needed to just use them with native Swift experience with decoding structs.
So I made something called [AnyCodable](https://github.com/Flight-School/AnyCodable) from Flight-School for fixing my own issue.
So I made something called [CodableAny](https://github.com/amirsaam/CodableAny) (that is in this package's dependencies) for fixing my own issue.
Basically when we call `getDataForCampaign` function, we will return:
```swift
public struct PatreonCampaignInfo: Codable {
Expand All @@ -103,7 +103,7 @@ public struct PatreonCampaignInfo: Codable {
and `CampaignIncludedAny` is:
```swift
public struct CampaignIncludedAny: Codable {
public let attributes: [String: AnyCodable]
public let attributes: [String: CodableAny]
public let id: String
public let type: String
}
Expand Down Expand Up @@ -164,7 +164,7 @@ For more information about decoding structs please go to [this directory](https:

- [Alamofire](https://github.com/Alamofire/Alamofire)
- [Semaphore](https://github.com/groue/Semaphore)
- [AnyCodable](https://github.com/Flight-School/AnyCodable)
- [CodableAny](https://github.com/amirsaam/CodableAny)

## Meta

Expand Down
4 changes: 2 additions & 2 deletions Sources/PatreonAPI/Patreon Data Structs/CampaignData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//

import Foundation
import AnyCodable
import CodableAny

// MARK: - Campaigns owned by a User
public struct PatronOwnedCampaigns: Codable {
Expand Down Expand Up @@ -72,7 +72,7 @@ public struct CampaignDataRelationships: Codable {

/// Used to retrive both `CampaignIncludedTier` and `CampaignIncludedBenefit` at the same time.
public struct CampaignIncludedAny: Codable {
public let attributes: [String: AnyCodable]
public let attributes: [String: CodableAny]
public let id: String
public let relationships: CampaignIncludedRelationship?
public let type: String
Expand Down
4 changes: 2 additions & 2 deletions Sources/PatreonAPI/Patreon Data Structs/CampaignPatrons.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//

import Foundation
import AnyCodable
import CodableAny

// MARK: - Campaign's Patrons List
public struct PatreonCampaignMembers: Codable {
Expand Down Expand Up @@ -60,7 +60,7 @@ public struct MembershipDataRelationships: Codable {

// MARK: - Members' Included Data
public struct CampaignMemberIncluded: Codable {
public let attributes: [String: AnyCodable]?
public let attributes: [String: CodableAny]?
public let id: String
public let type: String
}
4 changes: 2 additions & 2 deletions Sources/PatreonAPI/Patreon Data Structs/UserIdentity.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//

import Foundation
import AnyCodable
import CodableAny

// MARK: - Identity of a Signed In User
public struct PatreonUserIdentity: Codable {
Expand Down Expand Up @@ -69,7 +69,7 @@ public struct UserIdentityData: Codable {

/// Used to retrive both `UserIdentityIncludedMembership` and `UserIdentityIncludedCampaign` at the same time.
public struct UserIdentityIncludedAny: Codable {
public let attributes: [String: AnyCodable]
public let attributes: [String: CodableAny]
public let id: String
public let relationships: UserIdentityIncludedRelationships?
public let type: String
Expand Down

0 comments on commit 21e9d6a

Please sign in to comment.