Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class ScanStatsPayloadAPIBindingsTests: XCTestCase {
/// Check that scan stats tasks is encoded properly
func testScanStatsTasks() throws {
/// Check that scan stats tasks is encoded properly
let jsonDictionary = try scanStatsTasks.encodeJSONDictionary()
let jsonDictionary = try StripeJSONEncoder().encodeJSONDictionary(scanStatsTasks)
let tasksDictionary = jsonDictionary["tasks"] as! [String: Any]
let repeatingTaskDictionary = jsonDictionary["repeating_tasks"] as! [String: Any]

Expand All @@ -85,7 +85,7 @@ class ScanStatsPayloadAPIBindingsTests: XCTestCase {
/// Check that non repeating tasks are encoded properly
func testNonRepeatingTasks() throws {
/// Check that the JSON dictionary is formed properly
let jsonDictionary = try nonRepeatingTasks.encodeJSONDictionary()
let jsonDictionary = try StripeJSONEncoder().encodeJSONDictionary(nonRepeatingTasks)
let jsonCameraPermissions = jsonDictionary["camera_permission"] as! [[String: Any]]
XCTAssertEqual(jsonCameraPermissions.count, 1)
XCTAssertEqual(jsonCameraPermissions[0]["result"] as! String, "success")
Expand All @@ -111,7 +111,7 @@ class ScanStatsPayloadAPIBindingsTests: XCTestCase {
/// Check that repeating tasks are encoded properly
func testRepeatingTasks() throws {
/// Check that the JSON dictionary is formed properly
let jsonDictionary = try repeatingTasks.encodeJSONDictionary()
let jsonDictionary = try StripeJSONEncoder().encodeJSONDictionary(repeatingTasks)
let jsonMainLoop = jsonDictionary["main_loop_images_processed"] as! [String: Any]
XCTAssertEqual(jsonMainLoop["executions"] as? Int, -1)
}
Expand All @@ -130,7 +130,7 @@ class ScanStatsPayloadAPIBindingsTests: XCTestCase {
scanStats: scanStatsTasks
)
)
let jsonDictionary = try scanStatsPayload.encodeJSONDictionary()
let jsonDictionary = try StripeJSONEncoder().encodeJSONDictionary(scanStatsPayload)
/// Create query string
let queryString = URLEncoder.queryString(from: jsonDictionary)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class VerifyFramesAPIBindingsTests: XCTestCase {
)

/// encodeJSONDictionary used when forming the request body
let jsonDictionary = try verifyFrames.encodeJSONDictionary()
let jsonDictionary = try StripeJSONEncoder().encodeJSONDictionary(verifyFrames)

XCTAssertEqual(jsonDictionary["client_secret"] as! String, CIVIntentMockData.clientSecret)
XCTAssertEqual(
Expand Down Expand Up @@ -59,7 +59,7 @@ class VerifyFramesAPIBindingsTests: XCTestCase {
)

/// encodeJSONDictionary used when forming the request body
let jsonDictionary = try verificationFramesData.encodeJSONDictionary()
let jsonDictionary = try StripeJSONEncoder().encodeJSONDictionary(verificationFramesData)
let jsonDictionaryViewfinderMargins = jsonDictionary["viewfinder_margins"] as! [String: Any]

XCTAssertEqual(jsonDictionary["image_data"] as! String, "aW1hZ2VfZGF0YQ==")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ extension STPAPIClient {
completion: @escaping (Result<O, Error>) -> Void
) {
do {
let jsonDictionary = try object.encodeJSONDictionary()
let jsonDictionary = try StripeJSONEncoder().encodeJSONDictionary(object)
let formData = URLEncoder.queryString(from: jsonDictionary).data(using: .utf8)
var request = configuredRequest(
for: url,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

/// Error codes returned from STPAPIClient.
@_spi(STP) public enum StripeError: Error {
@_spi(STP) @frozen public enum StripeError: Error {
/// The server returned an API error.
case apiError(StripeAPIError)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

/// Enumeration of all the analytic events logged by our SDK.
@_spi(STP) public enum STPAnalyticEvent: String {
@_spi(STP) @frozen public enum STPAnalyticEvent: String {
// MARK: - Payment Creation
case tokenCreation = "stripeios.token_creation"

Expand Down
14 changes: 0 additions & 14 deletions StripeCore/StripeCore/Source/Coder/StripeCodable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ extension UnknownFieldsDecodable {
self._allResponseFieldsStorage!.storage = newValue
}
}

static func decodedObject(jsonData: Data) throws -> Self {
return try StripeJSONDecoder.decode(jsonData: jsonData)
}
}

extension UnknownFieldsEncodable {
Expand Down Expand Up @@ -97,16 +93,6 @@ extension UnknownFieldsEncodable {
}
}

extension Encodable {
@_spi(STP) public func encodeJSONDictionary(includingUnknownFields: Bool = true) throws -> [String: Any] {
let encoder = StripeJSONEncoder()
return try encoder.encodeJSONDictionary(
self,
includingUnknownFields: includingUnknownFields
)
}
}

@_spi(STP) public enum UnknownFieldsCodableFloats: String {
case PositiveInfinity = "Inf"
case NegativeInfinity = "-Inf"
Expand Down
Loading
Loading