Skip to content

Added @IgnoreDecodeErrors property wrapper#1541

Merged
NachoSoto merged 1 commit into
mainfrom
ignore-decode-errors
May 10, 2022
Merged

Added @IgnoreDecodeErrors property wrapper#1541
NachoSoto merged 1 commit into
mainfrom
ignore-decode-errors

Conversation

@NachoSoto

Copy link
Copy Markdown
Contributor

Follow up to #1537. This will be needed for several properties of CustomerInfo's response, like managementURL.

@NachoSoto NachoSoto requested a review from a team April 26, 2022 19:24
@NachoSoto NachoSoto force-pushed the default-value-decoder branch from ff8f417 to 3a9ec92 Compare April 26, 2022 23:36
@NachoSoto NachoSoto force-pushed the ignore-decode-errors branch from b114763 to 177e79e Compare April 26, 2022 23:36
@NachoSoto NachoSoto force-pushed the default-value-decoder branch from 3a9ec92 to f7a3452 Compare April 26, 2022 23:56
@NachoSoto NachoSoto force-pushed the ignore-decode-errors branch from 177e79e to ba4dadf Compare April 26, 2022 23:58
@NachoSoto NachoSoto force-pushed the default-value-decoder branch from 77ef317 to a9b4a53 Compare April 28, 2022 21:25
@NachoSoto NachoSoto force-pushed the ignore-decode-errors branch from ba4dadf to 258721e Compare April 28, 2022 21:26
NachoSoto added a commit that referenced this pull request Apr 28, 2022
- Removed all custom deserialization code thanks to #1537, #1541, and #1543.
- The format of the customer info response is now very concise and only in one place (`CustomerInfoResponse`) instead of being passed through dictionaries and magic strings everywhere.
- `CustomerInfo` was combining the dictionaries inside of `"subscriptions"` and `"non_subscriptions"`, despite them having different formats. This is now made explicit through type conversions between the two, (see `CustomerInfoResponse.allTransactionsByProductId`).
- Removed all custom `CustomerInfo` errors since deserialization is automatic, and the underlying `Error` information will be provided thanks to `ErrorUtils.logDecodingError`.
- `CustomerInfo` deserialization always wraps errors into `ErrorCode.customerInfoError`, which is now also covered in a new test.
- Added a new snapshot test that covers `CustomerInfo` serialization by storing the result in a JSON file.

- `CustomerInfo` equality is now automatic through the `CustomerInfoResponse` `Equatable` conformance.
- Simplified `schemaVersion` handling
- All tests still use `CustomerInfo(data: [String: Any])`, but that method is only visible for tests now, and it uses the underlying `Decodable` implementation (see `CustomerInfo+TestExtensions.swift`).
- Added extra tests for `CustomerInfoResponse` that use a fixture `CustomerInfo.json`, which is easier to maintain than having JSON in code.

- Improved definition of the protocol so that our types only have to implement one method:
```swift
extension CustomerInfo: RawDataContainer {
    @available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.2, *)
    public var underlyingData: some Encodable {
        return self.data.response
    }
}
```

- The protocol will provide the `rawData` public method through the default implementation automatically.
- The only downside is that this needs to be iOS 13+ only because of `some Encodable`, which allows us to implement this without needing to leak the underlying type.
@NachoSoto NachoSoto force-pushed the default-value-decoder branch 2 times, most recently from 4d23d75 to e0b26ce Compare May 10, 2022 15:50
Base automatically changed from default-value-decoder to main May 10, 2022 17:26
Follow up to #1537. This will be needed for several properties of `CustomerInfo`'s response, like `managementURL`.
@NachoSoto NachoSoto force-pushed the ignore-decode-errors branch from 258721e to d93db85 Compare May 10, 2022 17:29
@NachoSoto NachoSoto merged commit 0864119 into main May 10, 2022
@NachoSoto NachoSoto deleted the ignore-decode-errors branch May 10, 2022 17:30
NachoSoto added a commit that referenced this pull request May 12, 2022
- Removed all custom deserialization code thanks to #1537, #1541, and #1543.
- The format of the customer info response is now very concise and only in one place (`CustomerInfoResponse`) instead of being passed through dictionaries and magic strings everywhere.
- `CustomerInfo` was combining the dictionaries inside of `"subscriptions"` and `"non_subscriptions"`, despite them having different formats. This is now made explicit through type conversions between the two, (see `CustomerInfoResponse.allTransactionsByProductId`).
- Removed all custom `CustomerInfo` errors since deserialization is automatic, and the underlying `Error` information will be provided thanks to `ErrorUtils.logDecodingError`.
- `CustomerInfo` deserialization always wraps errors into `ErrorCode.customerInfoError`, which is now also covered in a new test.
- Added a new snapshot test that covers `CustomerInfo` serialization by storing the result in a JSON file.

- `CustomerInfo` equality is now automatic through the `CustomerInfoResponse` `Equatable` conformance.
- Simplified `schemaVersion` handling
- All tests still use `CustomerInfo(data: [String: Any])`, but that method is only visible for tests now, and it uses the underlying `Decodable` implementation (see `CustomerInfo+TestExtensions.swift`).
- Added extra tests for `CustomerInfoResponse` that use a fixture `CustomerInfo.json`, which is easier to maintain than having JSON in code.

- Improved definition of the protocol so that our types only have to implement one method:
```swift
extension CustomerInfo: RawDataContainer {
    @available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.2, *)
    public var underlyingData: some Encodable {
        return self.data.response
    }
}
```

- The protocol will provide the `rawData` public method through the default implementation automatically.
- The only downside is that this needs to be iOS 13+ only because of `some Encodable`, which allows us to implement this without needing to leak the underlying type.
NachoSoto added a commit that referenced this pull request May 20, 2022
- Removed all custom deserialization code thanks to #1537, #1541, and #1543.
- The format of the customer info response is now very concise and only in one place (`CustomerInfoResponse`) instead of being passed through dictionaries and magic strings everywhere.
- `CustomerInfo` was combining the dictionaries inside of `"subscriptions"` and `"non_subscriptions"`, despite them having different formats. This is now made explicit through type conversions between the two, (see `CustomerInfoResponse.allTransactionsByProductId`).
- Removed all custom `CustomerInfo` errors since deserialization is automatic, and the underlying `Error` information will be provided thanks to `ErrorUtils.logDecodingError`.
- `CustomerInfo` deserialization always wraps errors into `ErrorCode.customerInfoError`, which is now also covered in a new test.
- Added a new snapshot test that covers `CustomerInfo` serialization by storing the result in a JSON file.

- `CustomerInfo` equality is now automatic through the `CustomerInfoResponse` `Equatable` conformance.
- Simplified `schemaVersion` handling
- All tests still use `CustomerInfo(data: [String: Any])`, but that method is only visible for tests now, and it uses the underlying `Decodable` implementation (see `CustomerInfo+TestExtensions.swift`).
- Added extra tests for `CustomerInfoResponse` that use a fixture `CustomerInfo.json`, which is easier to maintain than having JSON in code.

- Improved definition of the protocol so that our types only have to implement one method:
```swift
extension CustomerInfo: RawDataContainer {
    @available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.2, *)
    public var underlyingData: some Encodable {
        return self.data.response
    }
}
```

- The protocol will provide the `rawData` public method through the default implementation automatically.
- The only downside is that this needs to be iOS 13+ only because of `some Encodable`, which allows us to implement this without needing to leak the underlying type.
NachoSoto added a commit that referenced this pull request May 24, 2022
- Removed all custom deserialization code thanks to #1537, #1541, and #1543.
- The format of the customer info response is now very concise and only in one place (`CustomerInfoResponse`) instead of being passed through dictionaries and magic strings everywhere.
- `CustomerInfo` was combining the dictionaries inside of `"subscriptions"` and `"non_subscriptions"`, despite them having different formats. This is now made explicit through type conversions between the two, (see `CustomerInfoResponse.allTransactionsByProductId`).
- Removed all custom `CustomerInfo` errors since deserialization is automatic, and the underlying `Error` information will be provided thanks to `ErrorUtils.logDecodingError`.
- `CustomerInfo` deserialization always wraps errors into `ErrorCode.customerInfoError`, which is now also covered in a new test.
- Added a new snapshot test that covers `CustomerInfo` serialization by storing the result in a JSON file.

- `CustomerInfo` equality is now automatic through the `CustomerInfoResponse` `Equatable` conformance.
- Simplified `schemaVersion` handling
- All tests still use `CustomerInfo(data: [String: Any])`, but that method is only visible for tests now, and it uses the underlying `Decodable` implementation (see `CustomerInfo+TestExtensions.swift`).
- Added extra tests for `CustomerInfoResponse` that use a fixture `CustomerInfo.json`, which is easier to maintain than having JSON in code.

- Improved definition of the protocol so that our types only have to implement one method:
```swift
extension CustomerInfo: RawDataContainer {
    @available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.2, *)
    public var underlyingData: some Encodable {
        return self.data.response
    }
}
```

- The protocol will provide the `rawData` public method through the default implementation automatically.
- The only downside is that this needs to be iOS 13+ only because of `some Encodable`, which allows us to implement this without needing to leak the underlying type.
NachoSoto added a commit that referenced this pull request May 24, 2022
### Depends on:
- #1537
- #1540
- #1541
- #1543
- #1546
- #1547
- #1550
- #1551,
- #1565

### Changes

- Removed all custom deserialization code thanks to #1537, #1541, and #1543.
- The format of the customer info response is now very concise and only in one place (`CustomerInfoResponse`) instead of being passed through dictionaries and magic strings everywhere.
- `CustomerInfo` was combining the dictionaries inside of `"subscriptions"` and `"non_subscriptions"`, despite them having different formats. This is now made explicit through type conversions between the two, (see `CustomerInfoResponse.allTransactionsByProductId`).
- Removed all custom `CustomerInfo` errors since deserialization is automatic, and the underlying `Error` information will be provided thanks to `ErrorUtils.logDecodingError`.
- `CustomerInfo` deserialization always wraps errors into `ErrorCode.customerInfoError`, which is now also covered in a new test.
- Added a new snapshot test that covers `CustomerInfo` serialization by storing the result in a JSON file.

### Other changes:
- `CustomerInfo` equality is now automatic through the `CustomerInfoResponse` `Equatable` conformance.
- Simplified `schemaVersion` handling
- All tests still use `CustomerInfo(data: [String: Any])`, but that method is only visible for tests now, and it uses the underlying `Decodable` implementation (see `CustomerInfo+TestExtensions.swift`).
- Added extra tests for `CustomerInfoResponse` that use a fixture `CustomerInfo.json`, which is easier to maintain than having JSON in code.
- `RawDataContainer` implementation is changed in #1565.

### TODO:
- [x] Fix all tests
- [x] Update `RawValueContainer`
- [x] Consider recovering `CustomerInfoError`
- [x] Look at all previously logged errors
- [x] Finish `CustomerInfoResponseTests`
- [x] Handle all TODOs
- [x] Make `RawDataContainer` actually store all the original data: #1565
@joshdholtz joshdholtz mentioned this pull request May 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants