Skip to content

Commit f969f6e

Browse files
authored
Merge pull request #8554 from woocommerce/feat/8550-orders-migrate
REST API: Migrate orders endpoint
2 parents 49eb924 + 2f9d67d commit f969f6e

17 files changed

+569
-33
lines changed

Networking/Networking.xcodeproj/project.pbxproj

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,10 @@
690690
DE34051B28BDF12C00CF0D97 /* jetpack-connection-url.json in Resources */ = {isa = PBXBuildFile; fileRef = DE34051A28BDF12C00CF0D97 /* jetpack-connection-url.json */; };
691691
DE34051D28BDF1C900CF0D97 /* JetpackConnectionURLMapperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE34051C28BDF1C900CF0D97 /* JetpackConnectionURLMapperTests.swift */; };
692692
DE34051F28BDFB0B00CF0D97 /* JetpackConnectionRemoteTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE34051E28BDFB0B00CF0D97 /* JetpackConnectionRemoteTests.swift */; };
693+
DE42F95D2966CB6A00D514C2 /* order-notes-without-data.json in Resources */ = {isa = PBXBuildFile; fileRef = DE42F95C2966CB6A00D514C2 /* order-notes-without-data.json */; };
694+
DE42F9602967C88400D514C2 /* report-orders-total-without-data.json in Resources */ = {isa = PBXBuildFile; fileRef = DE42F95E2967C88400D514C2 /* report-orders-total-without-data.json */; };
695+
DE42F9612967C88400D514C2 /* report-orders-total.json in Resources */ = {isa = PBXBuildFile; fileRef = DE42F95F2967C88400D514C2 /* report-orders-total.json */; };
696+
DE42F9632967C8B900D514C2 /* ReportOrderTotalsMapperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE42F9622967C8B900D514C2 /* ReportOrderTotalsMapperTests.swift */; };
693697
DE50295928C5BD0200551736 /* JetpackUser.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE50295828C5BD0200551736 /* JetpackUser.swift */; };
694698
DE50295B28C5F99700551736 /* DotcomUser.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE50295A28C5F99700551736 /* DotcomUser.swift */; };
695699
DE50295D28C6068B00551736 /* JetpackUserMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE50295C28C6068B00551736 /* JetpackUserMapper.swift */; };
@@ -725,6 +729,8 @@
725729
DEF13C562965689F0024A02B /* LeaderboardListMapperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEF13C552965689F0024A02B /* LeaderboardListMapperTests.swift */; };
726730
DEF13C5A296571150024A02B /* leaderboards-year-without-data.json in Resources */ = {isa = PBXBuildFile; fileRef = DEF13C59296571150024A02B /* leaderboards-year-without-data.json */; };
727731
DEF13C5C2965812D0024A02B /* order-stats-v4-year-without-data.json in Resources */ = {isa = PBXBuildFile; fileRef = DEF13C5B2965812D0024A02B /* order-stats-v4-year-without-data.json */; };
732+
DEF13C5E296686AB0024A02B /* orders-load-all-without-data.json in Resources */ = {isa = PBXBuildFile; fileRef = DEF13C5D296686AB0024A02B /* orders-load-all-without-data.json */; };
733+
DEF13C6029668C420024A02B /* order-without-data.json in Resources */ = {isa = PBXBuildFile; fileRef = DEF13C5F29668C420024A02B /* order-without-data.json */; };
728734
DEFBA74E29485A7600C35BA9 /* RESTRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEFBA74D29485A7600C35BA9 /* RESTRequest.swift */; };
729735
DEFBA7542949CE6600C35BA9 /* RequestProcessor.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEFBA7532949CE6600C35BA9 /* RequestProcessor.swift */; };
730736
DEFBA7562949D17400C35BA9 /* DefaultRequestAuthenticatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEFBA7552949D17300C35BA9 /* DefaultRequestAuthenticatorTests.swift */; };
@@ -1493,6 +1499,10 @@
14931499
DE34051A28BDF12C00CF0D97 /* jetpack-connection-url.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "jetpack-connection-url.json"; sourceTree = "<group>"; };
14941500
DE34051C28BDF1C900CF0D97 /* JetpackConnectionURLMapperTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JetpackConnectionURLMapperTests.swift; sourceTree = "<group>"; };
14951501
DE34051E28BDFB0B00CF0D97 /* JetpackConnectionRemoteTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JetpackConnectionRemoteTests.swift; sourceTree = "<group>"; };
1502+
DE42F95C2966CB6A00D514C2 /* order-notes-without-data.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "order-notes-without-data.json"; sourceTree = "<group>"; };
1503+
DE42F95E2967C88400D514C2 /* report-orders-total-without-data.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = "report-orders-total-without-data.json"; path = "NetworkingTests/Responses/report-orders-total-without-data.json"; sourceTree = SOURCE_ROOT; };
1504+
DE42F95F2967C88400D514C2 /* report-orders-total.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = "report-orders-total.json"; path = "NetworkingTests/Responses/report-orders-total.json"; sourceTree = SOURCE_ROOT; };
1505+
DE42F9622967C8B900D514C2 /* ReportOrderTotalsMapperTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReportOrderTotalsMapperTests.swift; sourceTree = "<group>"; };
14961506
DE50295828C5BD0200551736 /* JetpackUser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JetpackUser.swift; sourceTree = "<group>"; };
14971507
DE50295A28C5F99700551736 /* DotcomUser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DotcomUser.swift; sourceTree = "<group>"; };
14981508
DE50295C28C6068B00551736 /* JetpackUserMapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JetpackUserMapper.swift; sourceTree = "<group>"; };
@@ -1528,6 +1538,8 @@
15281538
DEF13C552965689F0024A02B /* LeaderboardListMapperTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LeaderboardListMapperTests.swift; sourceTree = "<group>"; };
15291539
DEF13C59296571150024A02B /* leaderboards-year-without-data.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "leaderboards-year-without-data.json"; sourceTree = "<group>"; };
15301540
DEF13C5B2965812D0024A02B /* order-stats-v4-year-without-data.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "order-stats-v4-year-without-data.json"; sourceTree = "<group>"; };
1541+
DEF13C5D296686AB0024A02B /* orders-load-all-without-data.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "orders-load-all-without-data.json"; sourceTree = "<group>"; };
1542+
DEF13C5F29668C420024A02B /* order-without-data.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "order-without-data.json"; sourceTree = "<group>"; };
15311543
DEFBA74D29485A7600C35BA9 /* RESTRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RESTRequest.swift; sourceTree = "<group>"; };
15321544
DEFBA7532949CE6600C35BA9 /* RequestProcessor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RequestProcessor.swift; sourceTree = "<group>"; };
15331545
DEFBA7552949D17300C35BA9 /* DefaultRequestAuthenticatorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultRequestAuthenticatorTests.swift; sourceTree = "<group>"; };
@@ -2114,6 +2126,8 @@
21142126
EE80A24B29556F1D003591E4 /* Coupon */,
21152127
EE338A0A294AF92A00183934 /* AppliicationPassword */,
21162128
DE9DEEF4291CF1B40070AD7C /* site-plugin-without-envelope.json */,
2129+
DE42F95E2967C88400D514C2 /* report-orders-total-without-data.json */,
2130+
DE42F95F2967C88400D514C2 /* report-orders-total.json */,
21172131
DE2E8EA8295416C9002E4B14 /* wordpress-site-info.json */,
21182132
028CB714290223CB00331C09 /* account-username-suggestions.json */,
21192133
028CB71C2902589E00331C09 /* create-account-error-email-exists.json */,
@@ -2200,10 +2214,13 @@
22002214
B554FA8C2180B59700C54DFF /* notifications-load-hashes.json */,
22012215
AE2D6624272A941C004A2C3A /* null-data.json */,
22022216
B5C6FCD520A3768900A4F8E4 /* order.json */,
2217+
DEF13C5F29668C420024A02B /* order-without-data.json */,
22032218
034480C227A42F9100DFACD2 /* order-with-charge.json */,
22042219
02C254D62563999200A04423 /* order-shipping-labels.json */,
22052220
B559EBA920A0B5CD00836CD4 /* orders-load-all.json */,
2221+
DEF13C5D296686AB0024A02B /* orders-load-all-without-data.json */,
22062222
74C8F06520EEB76400B6EDC9 /* order-notes.json */,
2223+
DE42F95C2966CB6A00D514C2 /* order-notes-without-data.json */,
22072224
CEF88DAA233E911A00BED485 /* order-fully-refunded.json */,
22082225
CEF88DAE233E9F7D00BED485 /* order-details-partially-refunded.json */,
22092226
D8FBFF2322D52815006E3336 /* order-stats-v4-daily.json */,
@@ -2615,6 +2632,7 @@
26152632
68CB801328D8A05200E169F8 /* CustomerMapperTests.swift */,
26162633
68F48B1028E3BBC60045C15B /* WCAnalyticsCustomerMapperTests.swift */,
26172634
EE338A0D294AF9BD00183934 /* ApplicationPasswordMapperTests.swift */,
2635+
DE42F9622967C8B900D514C2 /* ReportOrderTotalsMapperTests.swift */,
26182636
EEA658412966C41A00112DF0 /* ProductIDMapperTests.swift */,
26192637
EEA658472966CBAD00112DF0 /* EntityIDMapperTests.swift */,
26202638
);
@@ -2881,6 +2899,7 @@
28812899
D865CE5F278CA183002C8520 /* stripe-payment-intent-requires-action.json in Resources */,
28822900
CCF48B2C2628AE160034EA83 /* shipping-label-account-settings.json in Resources */,
28832901
31A451D927863A2E00FE81AA /* stripe-account-live-test.json in Resources */,
2902+
DE42F9602967C88400D514C2 /* report-orders-total-without-data.json in Resources */,
28842903
DE9DEEF5291CF1B40070AD7C /* site-plugin-without-envelope.json in Resources */,
28852904
0261F5A928D4641500B7AC72 /* products-sku-search.json in Resources */,
28862905
EE80A24829547F8B003591E4 /* coupon-without-data.json in Resources */,
@@ -2938,6 +2957,7 @@
29382957
3158FE6C26129D2E00E566B9 /* wcpay-account-rejected-terms-of-service.json in Resources */,
29392958
E16C59B928F927CA007D55BB /* iap-order-create.json in Resources */,
29402959
31054728262E2FEE00C5C02B /* wcpay-payment-intent-canceled.json in Resources */,
2960+
DE42F9612967C88400D514C2 /* report-orders-total.json in Resources */,
29412961
31A451CC27863A2E00FE81AA /* stripe-account-rejected-fraud.json in Resources */,
29422962
31A451D827863A2E00FE81AA /* stripe-account-restricted-overdue.json in Resources */,
29432963
D865CE69278CA245002C8520 /* stripe-payment-intent-unknown-status.json in Resources */,
@@ -3007,6 +3027,7 @@
30073027
EE80A24729547F8B003591E4 /* coupons-all-without-data.json in Resources */,
30083028
7412A8F021B6E416005D182A /* report-orders.json in Resources */,
30093029
CCF4346A2906C9C300B4475A /* products-ids-only-empty.json in Resources */,
3030+
DEF13C5E296686AB0024A02B /* orders-load-all-without-data.json in Resources */,
30103031
4515282B257A8C010076B03C /* product-attribute-delete.json in Resources */,
30113032
020C907B24C6E108001E2BEB /* product-variation-update.json in Resources */,
30123033
D8FBFF1822D4DDB9006E3336 /* order-stats-v4-hour.json in Resources */,
@@ -3018,6 +3039,7 @@
30183039
261CF2CB255C50010090D8D3 /* payment-gateway-list-half.json in Resources */,
30193040
02C254D72563999300A04423 /* order-shipping-labels.json in Resources */,
30203041
45B204BC24890B1200FE6526 /* category.json in Resources */,
3042+
DEF13C6029668C420024A02B /* order-without-data.json in Resources */,
30213043
022902D422E2436400059692 /* stats_module_disabled_error.json in Resources */,
30223044
4513382827A96DE700AE5E78 /* inbox-note.json in Resources */,
30233045
31A451D227863A2E00FE81AA /* stripe-account-restricted-pending.json in Resources */,
@@ -3062,6 +3084,7 @@
30623084
D8FBFF1522D3BE09006E3336 /* order-stats-v4-defaults.json in Resources */,
30633085
7495AACF225D366D00801A89 /* variation-as-product.json in Resources */,
30643086
0272E3FB254AABB800436277 /* order-with-line-item-attributes-before-API-support.json in Resources */,
3087+
DE42F95D2966CB6A00D514C2 /* order-notes-without-data.json in Resources */,
30653088
31723C892787A299007F1405 /* stripe-connection-token.json in Resources */,
30663089
74A1D266211898F000931DFA /* site-visits-year.json in Resources */,
30673090
743BF8BE21191B63008A9D87 /* site-visits.json in Resources */,
@@ -3642,6 +3665,7 @@
36423665
74CF0A8C22414D7800DB993F /* ProductMapperTests.swift in Sources */,
36433666
45152815257A83DD0076B03C /* ProductAttributesRemoteTests.swift in Sources */,
36443667
B505F6D720BEE58800BB1B69 /* AccountRemoteTests.swift in Sources */,
3668+
DE42F9632967C8B900D514C2 /* ReportOrderTotalsMapperTests.swift in Sources */,
36453669
453305EB2459E01A00264E50 /* PostMapperTests.swift in Sources */,
36463670
CE0A0F1D22398D520075ED8D /* ProductListMapperTests.swift in Sources */,
36473671
2670C3FC270F4E06002FE931 /* SiteListMapperTests.swift in Sources */,

Networking/Networking/Mapper/OrderListMapper.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ struct OrderListMapper: Mapper {
2121
.siteID: siteID
2222
]
2323

24-
return try decoder.decode(OrderListEnvelope.self, from: response).orders
24+
do {
25+
return try decoder.decode(OrderListEnvelope.self, from: response).orders
26+
} catch {
27+
return try decoder.decode([Order].self, from: response)
28+
}
2529
}
2630
}
2731

Networking/Networking/Mapper/OrderMapper.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ struct OrderMapper: Mapper {
2020
decoder.userInfo = [
2121
.siteID: siteID
2222
]
23-
24-
return try decoder.decode(OrderEnvelope.self, from: response).order
23+
do {
24+
return try decoder.decode(OrderEnvelope.self, from: response).order
25+
} catch {
26+
return try decoder.decode(Order.self, from: response)
27+
}
2528
}
2629
}
2730

Networking/Networking/Mapper/OrderNoteMapper.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ class OrderNoteMapper: Mapper {
1111
let decoder = JSONDecoder()
1212
decoder.dateDecodingStrategy = .formatted(DateFormatter.Defaults.dateTimeFormatter)
1313

14-
return try decoder.decode(OrderNoteEnvelope.self, from: response).orderNote
14+
do {
15+
return try decoder.decode(OrderNoteEnvelope.self, from: response).orderNote
16+
} catch {
17+
return try decoder.decode(OrderNote.self, from: response)
18+
}
1519
}
1620
}
1721

Networking/Networking/Mapper/OrderNotesMapper.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ class OrderNotesMapper: Mapper {
1111
let decoder = JSONDecoder()
1212
decoder.dateDecodingStrategy = .formatted(DateFormatter.Defaults.dateTimeFormatter)
1313

14-
return try decoder.decode(OrderNotesEnvelope.self, from: response).orderNotes
14+
do {
15+
return try decoder.decode(OrderNotesEnvelope.self, from: response).orderNotes
16+
} catch {
17+
return try decoder.decode([OrderNote].self, from: response)
18+
}
1519
}
1620
}
1721

Networking/Networking/Mapper/ReportOrderTotalsMapper.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ struct ReportOrderTotalsMapper: Mapper {
1919
decoder.userInfo = [
2020
.siteID: siteID
2121
]
22-
return try decoder.decode(ReportOrderTotalsEnvelope.self, from: response).data
22+
do {
23+
return try decoder.decode(ReportOrderTotalsEnvelope.self, from: response).data
24+
} catch {
25+
return try decoder.decode([OrderStatus].self, from: response)
26+
}
2327
}
2428
}
2529

0 commit comments

Comments
 (0)