@@ -8,9 +8,9 @@ struct RESTRequest: Request {
88 ///
99 let siteURL : String
1010
11- /// WooCommerce API Version
11+ /// WooCommerce / WordPress API Version Path
1212 ///
13- let wooApiVersion : WooAPIVersion
13+ let apiVersionPath : String ?
1414
1515 /// HTTP Request Method
1616 ///
@@ -24,30 +24,66 @@ struct RESTRequest: Request {
2424 ///
2525 let parameters : [ String : Any ] ?
2626
27- /// Designated Initializer.
27+ private init ( siteURL: String ,
28+ apiVersionPath: String ? ,
29+ method: HTTPMethod ,
30+ path: String ,
31+ parameters: [ String : Any ] ) {
32+ self . siteURL = siteURL
33+ self . apiVersionPath = apiVersionPath
34+ self . method = method
35+ self . path = path
36+ self . parameters = parameters
37+ }
38+
39+ /// - Parameters:
40+ /// - siteURL: URL of the site to send the REST request to.
41+ /// - method: HTTP Method we should use.
42+ /// - path: path to the target endpoint.
43+ /// - parameters: Collection of String parameters to be passed over to our target endpoint.
2844 ///
45+ init ( siteURL: String ,
46+ method: HTTPMethod ,
47+ path: String ,
48+ parameters: [ String : Any ] = [ : ] ) {
49+ self . init ( siteURL: siteURL, apiVersionPath: nil , method: method, path: path, parameters: parameters)
50+ }
51+
2952 /// - Parameters:
3053 /// - siteURL: URL of the site to send the REST request to.
54+ /// - wooApiVersion: WooCommerce API version.
3155 /// - method: HTTP Method we should use.
3256 /// - path: path to the target endpoint.
3357 /// - parameters: Collection of String parameters to be passed over to our target endpoint.
3458 ///
3559 init ( siteURL: String ,
36- wooApiVersion: WooAPIVersion = . none ,
60+ wooApiVersion: WooAPIVersion ,
3761 method: HTTPMethod ,
3862 path: String ,
3963 parameters: [ String : Any ] = [ : ] ) {
40- self . siteURL = siteURL
41- self . wooApiVersion = wooApiVersion
42- self . method = method
43- self . path = path
44- self . parameters = parameters
64+ self . init ( siteURL: siteURL, apiVersionPath: wooApiVersion. path, method: method, path: path, parameters: parameters)
65+ }
66+
67+ /// - Parameters:
68+ /// - siteURL: URL of the site to send the REST request to.
69+ /// - wordpressApiVersion: WordPress API version.
70+ /// - method: HTTP Method we should use.
71+ /// - path: path to the target endpoint.
72+ /// - parameters: Collection of String parameters to be passed over to our target endpoint.
73+ ///
74+ init ( siteURL: String ,
75+ wordpressApiVersion: WordPressAPIVersion ,
76+ method: HTTPMethod ,
77+ path: String ,
78+ parameters: [ String : Any ] = [ : ] ) {
79+ self . init ( siteURL: siteURL, apiVersionPath: wordpressApiVersion. path, method: method, path: path, parameters: parameters)
4580 }
4681
4782 /// Returns a URLRequest instance representing the current REST API Request.
4883 ///
4984 func asURLRequest( ) throws -> URLRequest {
50- let components = [ siteURL, Settings . basePath, wooApiVersion. path, path]
85+ let components = [ siteURL, Settings . basePath, apiVersionPath, path]
86+ . compactMap { $0 }
5187 . map { $0. trimSlashes ( ) }
5288 . filter { $0. isEmpty == false }
5389 let url = try components. joined ( separator: " / " ) . asURL ( )
0 commit comments