Skip to content

Commit 1069c9a

Browse files
committed
Merge branch 'trunk' into issue/71-woo-version-in-settings
2 parents 23c7a56 + 401163e commit 1069c9a

File tree

57 files changed

+2076
-97
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+2076
-97
lines changed

Experiments/Experiments/DefaultFeatureFlagService.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ public struct DefaultFeatureFlagService: FeatureFlagService {
3333
return true
3434
case .promptToEnableCodInIppOnboarding:
3535
return true
36+
case .searchProductsBySKU:
37+
return true
3638
case .orderCreationSearchCustomers:
3739
return buildConfig == .localDeveloper || buildConfig == .alpha
3840
default:

Experiments/Experiments/FeatureFlag.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ public enum FeatureFlag: Int {
7070
///
7171
case promptToEnableCodInIppOnboarding
7272

73+
/// Enables searching products by partial SKU for WC version 6.6+.
74+
///
75+
case searchProductsBySKU
76+
7377
/// Enables the Search Customers functionality in the Order Creation screen
7478
///
7579
case orderCreationSearchCustomers

Fakes/Fakes/Networking.generated.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,20 @@ extension CreateProductVariation {
181181
)
182182
}
183183
}
184+
extension Customer {
185+
/// Returns a "ready to use" type filled with fake values.
186+
///
187+
public static func fake() -> Customer {
188+
.init(
189+
customerID: .fake(),
190+
email: .fake(),
191+
firstName: .fake(),
192+
lastName: .fake(),
193+
billing: .fake(),
194+
shipping: .fake()
195+
)
196+
}
197+
}
184198
extension DotcomError {
185199
/// Returns a "ready to use" type filled with fake values.
186200
///

Networking/Networking.xcodeproj/project.pbxproj

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
025CA2C4238EBC4300B05C81 /* ProductShippingClassRemote.swift in Sources */ = {isa = PBXBuildFile; fileRef = 025CA2C3238EBC4300B05C81 /* ProductShippingClassRemote.swift */; };
3131
025CA2C6238F4F3500B05C81 /* ProductShippingClassRemoteTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 025CA2C5238F4F3500B05C81 /* ProductShippingClassRemoteTests.swift */; };
3232
025CA2C8238F4FF400B05C81 /* product-shipping-classes-load-all.json in Resources */ = {isa = PBXBuildFile; fileRef = 025CA2C7238F4FF400B05C81 /* product-shipping-classes-load-all.json */; };
33+
0261F5A928D4641500B7AC72 /* products-sku-search.json in Resources */ = {isa = PBXBuildFile; fileRef = 0261F5A828D4641500B7AC72 /* products-sku-search.json */; };
3334
02698CF624C17FC1005337C4 /* product-alternative-types.json in Resources */ = {isa = PBXBuildFile; fileRef = 02698CF524C17FC1005337C4 /* product-alternative-types.json */; };
3435
02698CF824C183A5005337C4 /* ProductVariationListMapperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02698CF724C183A5005337C4 /* ProductVariationListMapperTests.swift */; };
3536
02698CFA24C188E9005337C4 /* product-variations-load-all-alternative-types.json in Resources */ = {isa = PBXBuildFile; fileRef = 02698CF924C188E8005337C4 /* product-variations-load-all-alternative-types.json */; };
@@ -323,7 +324,13 @@
323324
57BE08D82409B63800F6DCED /* reviews-missing-avatar-urls.json in Resources */ = {isa = PBXBuildFile; fileRef = 57BE08D72409B63700F6DCED /* reviews-missing-avatar-urls.json */; };
324325
57E8FED3246616AC0057CD68 /* Result+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 57E8FED2246616AC0057CD68 /* Result+Extensions.swift */; };
325326
6647C0161DAC6AB6570C53A7 /* Pods_Networking.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F3F25DC15EC1D7C631169CB5 /* Pods_Networking.framework */; };
327+
68BD37B328D9B8BD00C2A517 /* CustomerRemoteTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68BD37B228D9B8BD00C2A517 /* CustomerRemoteTests.swift */; };
326328
68C87B342862D40E00A99054 /* setting-all-except-countries.json in Resources */ = {isa = PBXBuildFile; fileRef = 68C87B332862D40E00A99054 /* setting-all-except-countries.json */; };
329+
68CB800C28D87BC800E169F8 /* Customer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68CB800B28D87BC800E169F8 /* Customer.swift */; };
330+
68CB800E28D8901B00E169F8 /* CustomerMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68CB800D28D8901B00E169F8 /* CustomerMapper.swift */; };
331+
68CB801028D89A0400E169F8 /* CustomerRemote.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68CB800F28D89A0400E169F8 /* CustomerRemote.swift */; };
332+
68CB801428D8A05200E169F8 /* CustomerMapperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68CB801328D8A05200E169F8 /* CustomerMapperTests.swift */; };
333+
68CB801628D8A39700E169F8 /* customer.json in Resources */ = {isa = PBXBuildFile; fileRef = 68CB801528D8A39700E169F8 /* customer.json */; };
327334
68FBC5B828928C8C00A05461 /* WooFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 68FBC5B728928C8C00A05461 /* WooFoundation.framework */; };
328335
74002D6A2118B26100A63C19 /* SiteVisitStatsMapperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74002D692118B26000A63C19 /* SiteVisitStatsMapperTests.swift */; };
329336
74002D6C2118B88200A63C19 /* SiteVisitStatsRemoteTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74002D6B2118B88200A63C19 /* SiteVisitStatsRemoteTests.swift */; };
@@ -721,6 +728,7 @@
721728
025CA2C3238EBC4300B05C81 /* ProductShippingClassRemote.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductShippingClassRemote.swift; sourceTree = "<group>"; };
722729
025CA2C5238F4F3500B05C81 /* ProductShippingClassRemoteTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductShippingClassRemoteTests.swift; sourceTree = "<group>"; };
723730
025CA2C7238F4FF400B05C81 /* product-shipping-classes-load-all.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "product-shipping-classes-load-all.json"; sourceTree = "<group>"; };
731+
0261F5A828D4641500B7AC72 /* products-sku-search.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "products-sku-search.json"; sourceTree = "<group>"; };
724732
02698CF524C17FC1005337C4 /* product-alternative-types.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "product-alternative-types.json"; sourceTree = "<group>"; };
725733
02698CF724C183A5005337C4 /* ProductVariationListMapperTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductVariationListMapperTests.swift; sourceTree = "<group>"; };
726734
02698CF924C188E8005337C4 /* product-variations-load-all-alternative-types.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "product-variations-load-all-alternative-types.json"; sourceTree = "<group>"; };
@@ -1010,7 +1018,13 @@
10101018
5726F7332460A8F00031CAAC /* CopiableTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CopiableTests.swift; sourceTree = "<group>"; };
10111019
57BE08D72409B63700F6DCED /* reviews-missing-avatar-urls.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "reviews-missing-avatar-urls.json"; sourceTree = "<group>"; };
10121020
57E8FED2246616AC0057CD68 /* Result+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Result+Extensions.swift"; sourceTree = "<group>"; };
1021+
68BD37B228D9B8BD00C2A517 /* CustomerRemoteTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomerRemoteTests.swift; sourceTree = "<group>"; };
10131022
68C87B332862D40E00A99054 /* setting-all-except-countries.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = "setting-all-except-countries.json"; sourceTree = "<group>"; };
1023+
68CB800B28D87BC800E169F8 /* Customer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Customer.swift; sourceTree = "<group>"; };
1024+
68CB800D28D8901B00E169F8 /* CustomerMapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomerMapper.swift; sourceTree = "<group>"; };
1025+
68CB800F28D89A0400E169F8 /* CustomerRemote.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomerRemote.swift; sourceTree = "<group>"; };
1026+
68CB801328D8A05200E169F8 /* CustomerMapperTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomerMapperTests.swift; sourceTree = "<group>"; };
1027+
68CB801528D8A39700E169F8 /* customer.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = customer.json; sourceTree = "<group>"; };
10141028
68FBC5B728928C8C00A05461 /* WooFoundation.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = WooFoundation.framework; sourceTree = BUILT_PRODUCTS_DIR; };
10151029
69314EDE650855CAF927057E /* Pods_NetworkingTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_NetworkingTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
10161030
74002D692118B26000A63C19 /* SiteVisitStatsMapperTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SiteVisitStatsMapperTests.swift; sourceTree = "<group>"; };
@@ -1616,6 +1630,7 @@
16161630
FE28F6EB268436C9004465C7 /* UserRemoteTests.swift */,
16171631
077F39D926A58ED700ABEADC /* SystemStatusRemoteTests.swift */,
16181632
DE34051E28BDFB0B00CF0D97 /* JetpackConnectionRemoteTests.swift */,
1633+
68BD37B228D9B8BD00C2A517 /* CustomerRemoteTests.swift */,
16191634
);
16201635
path = Remote;
16211636
sourceTree = "<group>";
@@ -1748,6 +1763,7 @@
17481763
FE28F6E5268429B6004465C7 /* UserRemote.swift */,
17491764
077F39D526A58E4500ABEADC /* SystemStatusRemote.swift */,
17501765
AEF94584272974F2001DCCFB /* TelemetryRemote.swift */,
1766+
68CB800F28D89A0400E169F8 /* CustomerRemote.swift */,
17511767
);
17521768
path = Remote;
17531769
sourceTree = "<group>";
@@ -1855,6 +1871,7 @@
18551871
FE28F6E126840DED004465C7 /* User.swift */,
18561872
DE50295828C5BD0200551736 /* JetpackUser.swift */,
18571873
DE50295A28C5F99700551736 /* DotcomUser.swift */,
1874+
68CB800B28D87BC800E169F8 /* Customer.swift */,
18581875
);
18591876
path = Model;
18601877
sourceTree = "<group>";
@@ -1984,6 +2001,7 @@
19842001
451274A525276C82009911FF /* product-variation.json */,
19852002
CE0A0F1E223998A00075ED8D /* products-load-all.json */,
19862003
0282DD90233A120A006A5FDB /* products-search-photo.json */,
2004+
0261F5A828D4641500B7AC72 /* products-sku-search.json */,
19872005
45D685F923D0C3CF005F87D0 /* product-search-sku.json */,
19882006
4599FC5B24A6276F0056157A /* product-tags-all.json */,
19892007
45AF57A824AB42CD0088E2F7 /* product-tags-extra.json */,
@@ -2089,6 +2107,7 @@
20892107
4513382727A96DE700AE5E78 /* inbox-note.json */,
20902108
0205021B27C86B9700FB1C6B /* inbox-note-without-isRead.json */,
20912109
68C87B332862D40E00A99054 /* setting-all-except-countries.json */,
2110+
68CB801528D8A39700E169F8 /* customer.json */,
20922111
);
20932112
path = Responses;
20942113
sourceTree = "<group>";
@@ -2181,6 +2200,7 @@
21812200
02C112772742862600F4F0B4 /* WordPressSiteSettingsMapper.swift */,
21822201
0359EA1C27AADE000048DE2D /* WCPayChargeMapper.swift */,
21832202
DE34051828BDEE6A00CF0D97 /* JetpackConnectionURLMapper.swift */,
2203+
68CB800D28D8901B00E169F8 /* CustomerMapper.swift */,
21842204
);
21852205
path = Mapper;
21862206
sourceTree = "<group>";
@@ -2303,6 +2323,7 @@
23032323
DE34051C28BDF1C900CF0D97 /* JetpackConnectionURLMapperTests.swift */,
23042324
DE50296428C60A8000551736 /* JetpackUserMapperTests.swift */,
23052325
0359EA1E27AAE4680048DE2D /* WCPayChargeMapperTests.swift */,
2326+
68CB801328D8A05200E169F8 /* CustomerMapperTests.swift */,
23062327
);
23072328
path = Mapper;
23082329
sourceTree = "<group>";
@@ -2500,6 +2521,7 @@
25002521
D865CE5F278CA183002C8520 /* stripe-payment-intent-requires-action.json in Resources */,
25012522
CCF48B2C2628AE160034EA83 /* shipping-label-account-settings.json in Resources */,
25022523
31A451D927863A2E00FE81AA /* stripe-account-live-test.json in Resources */,
2524+
0261F5A928D4641500B7AC72 /* products-sku-search.json in Resources */,
25032525
09885C8027C3FFD200910A62 /* product-variations-bulk-update.json in Resources */,
25042526
31054734262E36AB00C5C02B /* wcpay-payment-intent-error.json in Resources */,
25052527
02AF07EE27493AE700B2D81E /* media-upload-to-wordpress-site.json in Resources */,
@@ -2684,6 +2706,7 @@
26842706
7497376A2141F2BE0008C490 /* top-performers-week-alt.json in Resources */,
26852707
D865CE61278CA1AE002C8520 /* stripe-payment-intent-processing.json in Resources */,
26862708
743E84F222172D0A00FAC9D7 /* shipment_tracking_plugin_not_active.json in Resources */,
2709+
68CB801628D8A39700E169F8 /* customer.json in Resources */,
26872710
451A97DE260B59870059D135 /* shipping-label-packages-success.json in Resources */,
26882711
31D27C8F2602B553002EDB1D /* plugins.json in Resources */,
26892712
261CF1B4255AD6B30090D8D3 /* payment-gateway-list.json in Resources */,
@@ -2982,6 +3005,7 @@
29823005
B518662220A097C200037A38 /* Network.swift in Sources */,
29833006
B572F69A21AC475C003EEFF0 /* DevicesRemote.swift in Sources */,
29843007
3192F220260D33BB0067FEF9 /* WCPayAccount.swift in Sources */,
3008+
68CB800E28D8901B00E169F8 /* CustomerMapper.swift in Sources */,
29853009
45CCFCE227A2C9BF0012E8CB /* InboxNote.swift in Sources */,
29863010
311D412C2783BF7400052F64 /* StripeAccount.swift in Sources */,
29873011
B518662420A099BF00037A38 /* AlamofireNetwork.swift in Sources */,
@@ -3030,6 +3054,7 @@
30303054
020D07BE23D8570800FD9580 /* MediaListMapper.swift in Sources */,
30313055
0359EA1327AAC6D00048DE2D /* WCPayCardPaymentDetails.swift in Sources */,
30323056
CCB2CA9E262091CB00285CA0 /* SuccessDataResultMapper.swift in Sources */,
3057+
68CB801028D89A0400E169F8 /* CustomerRemote.swift in Sources */,
30333058
DE50295B28C5F99700551736 /* DotcomUser.swift in Sources */,
30343059
74C8F06820EEB7BD00B6EDC9 /* OrderNotesMapper.swift in Sources */,
30353060
24F98C582502EA8800F49B68 /* FeatureFlagMapper.swift in Sources */,
@@ -3039,6 +3064,7 @@
30393064
74046E1D217A6989007DD7BF /* SiteSetting.swift in Sources */,
30403065
B5BB1D1020A237FB00112D92 /* Address.swift in Sources */,
30413066
CE43066A23465F340073CBFF /* Refund.swift in Sources */,
3067+
68CB800C28D87BC800E169F8 /* Customer.swift in Sources */,
30423068
DE50295D28C6068B00551736 /* JetpackUserMapper.swift in Sources */,
30433069
B524194121AC60A700D6FC0A /* DotcomDevice.swift in Sources */,
30443070
D8EDFE2225EE88C9003D2213 /* ReaderConnectionToken.swift in Sources */,
@@ -3124,6 +3150,7 @@
31243150
CEC4BF8F234E382F008D9195 /* RefundMapperTests.swift in Sources */,
31253151
24F98C5E2502EDCF00F49B68 /* BundleWooTests.swift in Sources */,
31263152
74AB0ACA21948CE4008220CD /* CommentResultMapperTests.swift in Sources */,
3153+
68CB801428D8A05200E169F8 /* CustomerMapperTests.swift in Sources */,
31273154
02698CF824C183A5005337C4 /* ProductVariationListMapperTests.swift in Sources */,
31283155
B524194921AC659500D6FC0A /* DevicesRemoteTests.swift in Sources */,
31293156
2685C0DA263B551300D9EE97 /* AddOnGroupMapperTests.swift in Sources */,
@@ -3198,6 +3225,7 @@
31983225
45CCFCE827A2E5020012E8CB /* InboxNoteListMapperTests.swift in Sources */,
31993226
74002D6C2118B88200A63C19 /* SiteVisitStatsRemoteTests.swift in Sources */,
32003227
0212683524C046CB00F8A892 /* MockNetwork+Path.swift in Sources */,
3228+
68BD37B328D9B8BD00C2A517 /* CustomerRemoteTests.swift in Sources */,
32013229
B554FA932180C17200C54DFF /* NoteHashListMapperTests.swift in Sources */,
32023230
CC07866526790B1100BA9AC1 /* ShippingLabelPurchaseMapperTests.swift in Sources */,
32033231
74002D6A2118B26100A63C19 /* SiteVisitStatsMapperTests.swift in Sources */,
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import Foundation
2+
3+
/// Mapper: Customer
4+
///
5+
struct CustomerMapper: Mapper {
6+
/// We're injecting this field by copying it in after parsing responses, because `siteID` is not returned in any of the Customer endpoints.
7+
///
8+
let siteID: Int64
9+
10+
/// (Attempts) to convert a dictionary into a `Customer` entity
11+
///
12+
func map(response: Data) throws -> Customer {
13+
let decoder = JSONDecoder()
14+
decoder.userInfo = [.siteID: siteID]
15+
let customer = try decoder.decode(CustomerEnvelope.self, from: response).customer
16+
return customer
17+
}
18+
}
19+
20+
private struct CustomerEnvelope: Decodable {
21+
let customer: Customer
22+
23+
private enum CodingKeys: String, CodingKey {
24+
case customer = "data"
25+
}
26+
}

Networking/Networking/Model/Copiable/Models+Copiable.generated.swift

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,33 @@ extension CouponReport {
169169
}
170170
}
171171

172+
extension Customer {
173+
func copy(
174+
customerID: CopiableProp<Int64> = .copy,
175+
email: CopiableProp<String> = .copy,
176+
firstName: NullableCopiableProp<String> = .copy,
177+
lastName: NullableCopiableProp<String> = .copy,
178+
billing: NullableCopiableProp<Address> = .copy,
179+
shipping: NullableCopiableProp<Address> = .copy
180+
) -> Customer {
181+
let customerID = customerID ?? self.customerID
182+
let email = email ?? self.email
183+
let firstName = firstName ?? self.firstName
184+
let lastName = lastName ?? self.lastName
185+
let billing = billing ?? self.billing
186+
let shipping = shipping ?? self.shipping
187+
188+
return Customer(
189+
customerID: customerID,
190+
email: email,
191+
firstName: firstName,
192+
lastName: lastName,
193+
billing: billing,
194+
shipping: shipping
195+
)
196+
}
197+
}
198+
172199
extension DotcomUser {
173200
public func copy(
174201
id: CopiableProp<Int64> = .copy,
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import Foundation
2+
import Codegen
3+
4+
/// Represents a Customer entity:
5+
/// https://woocommerce.github.io/woocommerce-rest-api-docs/#customer-properties
6+
///
7+
public struct Customer: Codable, GeneratedCopiable, GeneratedFakeable {
8+
9+
/// Unique identifier for the customer
10+
public let customerID: Int64
11+
12+
/// The email address for the customer
13+
public let email: String
14+
15+
/// Customer first name
16+
public let firstName: String?
17+
18+
/// Customer last name
19+
public let lastName: String?
20+
21+
/// List of billing address data
22+
public let billing: Address?
23+
24+
/// List of shipping address data
25+
public let shipping: Address?
26+
27+
/// Customer struct initializer
28+
///
29+
public init(customerID: Int64,
30+
email: String,
31+
firstName: String?,
32+
lastName: String?,
33+
billing: Address?,
34+
shipping: Address?) {
35+
self.customerID = customerID
36+
self.email = email
37+
self.firstName = firstName
38+
self.lastName = lastName
39+
self.billing = billing
40+
self.shipping = shipping
41+
}
42+
43+
/// Public initializer for the Customer
44+
///
45+
public init(from decoder: Decoder) throws {
46+
let container = try decoder.container(keyedBy: CodingKeys.self)
47+
48+
let customerID = try container.decode(Int64.self, forKey: .customerID)
49+
let email = try container.decode(String.self, forKey: .email)
50+
let firstName = try container.decodeIfPresent(String.self, forKey: .firstName)
51+
let lastName = try container.decodeIfPresent(String.self, forKey: .lastName)
52+
let billing = try? container.decode(Address.self, forKey: .billing)
53+
let shipping = try? container.decode(Address.self, forKey: .shipping)
54+
55+
self.init(customerID: customerID,
56+
email: email,
57+
firstName: firstName,
58+
lastName: lastName,
59+
billing: billing,
60+
shipping: shipping
61+
)
62+
}
63+
}
64+
65+
/// Defines all of the Customer CodingKeys
66+
///
67+
extension Customer {
68+
enum CodingKeys: String, CodingKey {
69+
case customerID = "id"
70+
case email
71+
case firstName = "first_name"
72+
case lastName = "last_name"
73+
case billing
74+
case shipping
75+
}
76+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import Foundation
2+
3+
public class CustomerRemote: Remote {
4+
/// Retrieves a `Customer`
5+
///
6+
/// - Parameters:
7+
/// - customerID: ID of the customer that will be retrieved
8+
/// - siteID: Site for which we'll fetch the customer.
9+
/// - completion: Closure to be executed upon completion.
10+
///
11+
func retrieveCustomer(for siteID: Int64, with customerID: Int64, completion: @escaping (Result<Customer, Error>) -> Void) {
12+
let path = "/customers/\(customerID)"
13+
let request = JetpackRequest(wooApiVersion: .mark3,
14+
method: .get,
15+
siteID: siteID,
16+
path: path,
17+
parameters: nil
18+
)
19+
20+
let mapper = CustomerMapper(siteID: siteID)
21+
enqueue(request, mapper: mapper, completion: completion)
22+
}
23+
}

0 commit comments

Comments
 (0)