-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
80 changed files
with
712 additions
and
367 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
{ | ||
"pins" : [ | ||
{ | ||
"identity" : "alamofire", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/Alamofire/Alamofire", | ||
"state" : { | ||
"revision" : "f455c2975872ccd2d9c81594c658af65716e9b9a", | ||
"version" : "5.9.1" | ||
} | ||
}, | ||
{ | ||
"identity" : "collectionconcurrencykit", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/JohnSundell/CollectionConcurrencyKit.git", | ||
"state" : { | ||
"revision" : "b4f23e24b5a1bff301efc5e70871083ca029ff95", | ||
"version" : "0.2.0" | ||
} | ||
}, | ||
{ | ||
"identity" : "cryptoswift", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/krzyzanowskim/CryptoSwift.git", | ||
"state" : { | ||
"revision" : "7892a123f7e8d0fe62f9f03728b17bbd4f94df5c", | ||
"version" : "1.8.1" | ||
} | ||
}, | ||
{ | ||
"identity" : "ohhttpstubs", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/AliSoftware/OHHTTPStubs", | ||
"state" : { | ||
"revision" : "12f19662426d0434d6c330c6974d53e2eb10ecd9", | ||
"version" : "9.1.0" | ||
} | ||
}, | ||
{ | ||
"identity" : "sourcekitten", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/jpsim/SourceKitten.git", | ||
"state" : { | ||
"revision" : "b6dc09ee51dfb0c66e042d2328c017483a1a5d56", | ||
"version" : "0.34.1" | ||
} | ||
}, | ||
{ | ||
"identity" : "swift-argument-parser", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/apple/swift-argument-parser.git", | ||
"state" : { | ||
"revision" : "8f4d2753f0e4778c76d5f05ad16c74f707390531", | ||
"version" : "1.2.3" | ||
} | ||
}, | ||
{ | ||
"identity" : "swift-syntax", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/apple/swift-syntax.git", | ||
"state" : { | ||
"revision" : "6ad4ea24b01559dde0773e3d091f1b9e36175036", | ||
"version" : "509.0.2" | ||
} | ||
}, | ||
{ | ||
"identity" : "swiftlint", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/realm/SwiftLint", | ||
"state" : { | ||
"revision" : "f17a4f9dfb6a6afb0408426354e4180daaf49cee", | ||
"version" : "0.54.0" | ||
} | ||
}, | ||
{ | ||
"identity" : "swiftytexttable", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/scottrhoyt/SwiftyTextTable.git", | ||
"state" : { | ||
"revision" : "c6df6cf533d120716bff38f8ff9885e1ce2a4ac3", | ||
"version" : "0.9.0" | ||
} | ||
}, | ||
{ | ||
"identity" : "swxmlhash", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/drmohundro/SWXMLHash.git", | ||
"state" : { | ||
"revision" : "a853604c9e9a83ad9954c7e3d2a565273982471f", | ||
"version" : "7.0.2" | ||
} | ||
}, | ||
{ | ||
"identity" : "wordpress-ios-shared", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/wordpress-mobile/WordPress-iOS-Shared.git", | ||
"state" : { | ||
"branch" : "mokagio/swiftlint-read-as-dependency", | ||
"revision" : "422950b28f01d7cc11218e7d70a6cd65004d23ae" | ||
} | ||
}, | ||
{ | ||
"identity" : "wpxmlrpc", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/wordpress-mobile/wpxmlrpc", | ||
"state" : { | ||
"revision" : "bfc413d336bdeaab89e62dc483380baa99b2257e", | ||
"version" : "0.10.0" | ||
} | ||
}, | ||
{ | ||
"identity" : "yams", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/jpsim/Yams.git", | ||
"state" : { | ||
"revision" : "8a835d918245ca22f36663dd3862138805d7f707", | ||
"version" : "5.1.0" | ||
} | ||
} | ||
], | ||
"version" : 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
Sources/APIInterface/WordPressComRESTAPIVersionedPathBuilder.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#import <Foundation/Foundation.h> | ||
#if SWIFT_PACKAGE | ||
#import "WordPressComRESTAPIVersionedPathBuilder.h" | ||
#import "WordPressComRESTAPIVersion.h" | ||
#else | ||
#import "WordPressKit/WordPressComRESTAPIVersionedPathBuilder.h" | ||
#endif | ||
|
||
static NSString* const WordPressComRESTApiVersionStringInvalid = @"invalid_api_version"; | ||
static NSString* const WordPressComRESTApiVersionString_1_0 = @"rest/v1"; | ||
static NSString* const WordPressComRESTApiVersionString_1_1 = @"rest/v1.1"; | ||
static NSString* const WordPressComRESTApiVersionString_1_2 = @"rest/v1.2"; | ||
static NSString* const WordPressComRESTApiVersionString_1_3 = @"rest/v1.3"; | ||
static NSString* const WordPressComRESTApiVersionString_2_0 = @"wpcom/v2"; | ||
|
||
@implementation WordPressComRESTAPIVersionedPathBuilder | ||
|
||
+ (NSString *)pathForEndpoint:(NSString *)endpoint | ||
withVersion:(WordPressComRESTAPIVersion)apiVersion | ||
{ | ||
NSString *apiVersionString = [self apiVersionStringWithEnumValue:apiVersion]; | ||
|
||
return [NSString stringWithFormat:@"%@/%@", apiVersionString, endpoint]; | ||
} | ||
|
||
+ (NSString *)apiVersionStringWithEnumValue:(WordPressComRESTAPIVersion)apiVersion | ||
{ | ||
NSString *result = nil; | ||
|
||
switch (apiVersion) { | ||
case WordPressComRESTAPIVersion_1_0: | ||
result = WordPressComRESTApiVersionString_1_0; | ||
break; | ||
|
||
case WordPressComRESTAPIVersion_1_1: | ||
result = WordPressComRESTApiVersionString_1_1; | ||
break; | ||
|
||
case WordPressComRESTAPIVersion_1_2: | ||
result = WordPressComRESTApiVersionString_1_2; | ||
break; | ||
|
||
case WordPressComRESTAPIVersion_1_3: | ||
result = WordPressComRESTApiVersionString_1_3; | ||
break; | ||
|
||
case WordPressComRESTAPIVersion_2_0: | ||
result = WordPressComRESTApiVersionString_2_0; | ||
break; | ||
|
||
default: | ||
NSAssert(NO, @"This should never by executed"); | ||
result = WordPressComRESTApiVersionStringInvalid; | ||
break; | ||
} | ||
|
||
return result; | ||
} | ||
|
||
@end |
14 changes: 14 additions & 0 deletions
14
Sources/APIInterface/include/WordPressComRESTAPIVersionedPathBuilder.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#import <Foundation/Foundation.h> | ||
#if SWIFT_PACKAGE | ||
#import "WordPressComRESTAPIVersion.h" | ||
#else | ||
#import <WordPressKit/WordPressComRESTAPIVersion.h> | ||
#endif | ||
|
||
@interface WordPressComRESTAPIVersionedPathBuilder: NSObject | ||
|
||
+ (NSString *)pathForEndpoint:(NSString *)endpoint | ||
withVersion:(WordPressComRESTAPIVersion)apiVersion | ||
NS_SWIFT_NAME(path(forEndpoint:withVersion:)); | ||
|
||
@end |
9 changes: 9 additions & 0 deletions
9
Sources/APIInterface/include/WordPressComRestApiErrorDomain.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#import <Foundation/Foundation.h> | ||
|
||
/// Error domain of `NSError` instances that are converted from `WordPressComRestApiEndpointError` | ||
/// and `WordPressAPIError<WordPressComRestApiEndpointError>` instances. | ||
/// | ||
/// This matches the compiler generated value and is used to ensure consistent error domain across error types and SPM or Framework build modes. | ||
/// | ||
/// See `extension WordPressComRestApiEndpointError: CustomNSError` in CoreAPI package for context. | ||
static NSString *const _Nonnull WordPressComRestApiErrorDomain = @"WordPressKit.WordPressComRestApiError"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#import "ServiceRemoteWordPressComREST.h" | ||
#import "WPKit-Swift.h" | ||
|
||
@implementation ServiceRemoteWordPressComREST | ||
|
||
- (instancetype)initWithWordPressComRestApi:(WordPressComRestApi *)wordPressComRestApi { | ||
|
||
NSParameterAssert([wordPressComRestApi isKindOfClass:[WordPressComRestApi class]]); | ||
|
||
self = [super init]; | ||
if (self) { | ||
_wordPressComRestApi = wordPressComRestApi; | ||
_wordPressComRESTAPI = wordPressComRestApi; | ||
} | ||
return self; | ||
} | ||
|
||
#pragma mark - Request URL construction | ||
|
||
- (NSString *)pathForEndpoint:(NSString *)resourceUrl | ||
withVersion:(WordPressComRESTAPIVersion)apiVersion | ||
{ | ||
NSParameterAssert([resourceUrl isKindOfClass:[NSString class]]); | ||
|
||
return [WordPressComRESTAPIVersionedPathBuilder pathForEndpoint:resourceUrl | ||
withVersion:apiVersion]; | ||
} | ||
|
||
@end |
File renamed without changes.
2 changes: 2 additions & 0 deletions
2
...sKit/WordPressAPI/Date+WordPressCom.swift → Sources/CoreAPI/Date+WordPressCom.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import Foundation | ||
|
||
extension Date { | ||
|
||
/// Parses a date string | ||
|
2 changes: 2 additions & 0 deletions
2
...PressAPI/DateFormatter+WordPressCom.swift → .../CoreAPI/DateFormatter+WordPressCom.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
1 change: 1 addition & 0 deletions
1
...I/HTTPAuthenticationAlertController.swift → ...I/HTTPAuthenticationAlertController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...ordPressKit/Utility/Result+Callback.swift → Sources/CoreAPI/Result+Callback.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import Foundation | ||
|
||
extension String.Encoding { | ||
/// See: https://www.iana.org/assignments/character-sets/character-sets.xhtml | ||
init?(ianaCharsetName: String) { | ||
let encoding: CFStringEncoding = CFStringConvertIANACharSetNameToEncoding(ianaCharsetName as CFString) | ||
guard encoding != kCFStringEncodingInvalidId, | ||
let builtInEncoding = CFStringBuiltInEncodings(rawValue: encoding) | ||
else { | ||
return nil | ||
} | ||
|
||
switch builtInEncoding { | ||
case .macRoman: | ||
self = .macOSRoman | ||
case .windowsLatin1: | ||
self = .windowsCP1252 | ||
case .isoLatin1: | ||
self = .isoLatin1 | ||
case .nextStepLatin: | ||
self = .nextstep | ||
case .ASCII: | ||
self = .ascii | ||
case .unicode: | ||
self = .unicode | ||
case .UTF8: | ||
self = .utf8 | ||
case .nonLossyASCII: | ||
self = .nonLossyASCII | ||
case .UTF16BE: | ||
self = .utf16BigEndian | ||
case .UTF16LE: | ||
self = .utf16LittleEndian | ||
case .UTF32: | ||
self = .utf32 | ||
case .UTF32BE: | ||
self = .utf32BigEndian | ||
case .UTF32LE: | ||
self = .utf32LittleEndian | ||
@unknown default: | ||
return nil | ||
} | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.