Skip to content

Commit

Permalink
Merge branch 'trunk' into fix/22859-stats-traffic-card-information-fa…
Browse files Browse the repository at this point in the history
…ils-to-load-when-date-cannot-be-parsed
  • Loading branch information
staskus committed Mar 27, 2024
2 parents ae05b59 + 631b1df commit 4425e5f
Show file tree
Hide file tree
Showing 710 changed files with 1,132 additions and 1,065 deletions.
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ Naming/FileName:
Metrics/BlockLength:
Exclude:
- 'fastlane/Fastfile'
- 'WordPressKit.podspec'
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ _None._

- Improve yyyy-MM-dd date formatter to support dates happening at DST transitions. [#771]

## 15.0.0

### Breaking Changes

- Reworked the `NSDate` RFC3339 / WordPress.com JSON conversions API [#759]
- Changed `FilePart` `filename` property to `fileName` [#765]

### Bug Fixes

- Fix crash when querying a WordPress plugin whose slug is not url-safe. [#767]

## 14.1.0

### New Features
Expand Down
26 changes: 14 additions & 12 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (3.0.6)
CFPropertyList (3.0.7)
base64
nkf
rexml
activesupport (7.1.2)
activesupport (7.1.3.2)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
Expand Down Expand Up @@ -39,16 +41,16 @@ GEM
aws-eventstream (~> 1, >= 1.0.2)
babosa (1.0.4)
base64 (0.2.0)
bigdecimal (3.1.5)
bigdecimal (3.1.7)
claide (1.1.0)
claide-plugins (0.9.2)
cork
nap
open4 (~> 1.3)
cocoapods (1.14.3)
cocoapods (1.15.2)
addressable (~> 2.8)
claide (>= 1.0.2, < 2.0)
cocoapods-core (= 1.14.3)
cocoapods-core (= 1.15.2)
cocoapods-deintegrate (>= 1.0.3, < 2.0)
cocoapods-downloader (>= 2.1, < 3.0)
cocoapods-plugins (>= 1.0.0, < 2.0)
Expand All @@ -65,7 +67,7 @@ GEM
xcodeproj (>= 1.23.0, < 2.0)
cocoapods-check (1.1.0)
cocoapods (~> 1.0)
cocoapods-core (1.14.3)
cocoapods-core (1.15.2)
activesupport (>= 5.0, < 8)
addressable (~> 2.8)
algoliasearch (~> 1.0)
Expand All @@ -88,7 +90,7 @@ GEM
colored2 (3.1.2)
commander (4.6.0)
highline (~> 2.0.0)
concurrent-ruby (1.2.2)
concurrent-ruby (1.2.3)
connection_pool (2.4.1)
cork (0.3.0)
colored2 (~> 3.1)
Expand Down Expand Up @@ -133,8 +135,7 @@ GEM
rake (>= 12.0.0, < 14.0.0)
domain_name (0.6.20231109)
dotenv (2.8.1)
drb (2.2.0)
ruby2_keywords
drb (2.2.1)
emoji_regex (3.2.3)
escape (0.0.4)
ethon (0.16.0)
Expand Down Expand Up @@ -260,7 +261,7 @@ GEM
http-cookie (1.0.5)
domain_name (~> 0.5)
httpclient (2.8.3)
i18n (1.14.1)
i18n (1.14.4)
concurrent-ruby (~> 1.0)
jmespath (1.6.2)
json (2.7.1)
Expand All @@ -272,7 +273,7 @@ GEM
language_server-protocol (3.17.0.3)
mini_magick (4.12.0)
mini_mime (1.1.5)
minitest (5.20.0)
minitest (5.22.3)
molinillo (0.8.0)
multi_json (1.15.0)
multipart-post (2.3.0)
Expand All @@ -281,6 +282,7 @@ GEM
nap (1.1.0)
naturally (2.2.1)
netrc (0.11.0)
nkf (0.2.0)
no_proxy_fix (0.1.2)
octokit (8.1.0)
base64
Expand Down Expand Up @@ -354,7 +356,7 @@ GEM
unicode-display_width (2.5.0)
webrick (1.8.1)
word_wrap (1.0.0)
xcodeproj (1.23.0)
xcodeproj (1.24.0)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
Expand Down
2 changes: 1 addition & 1 deletion Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 64af6d71574c7a92d01a9446aa874e066917ebe5

COCOAPODS: 1.14.3
COCOAPODS: 1.15.2
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ extension RemoteCommentV2: Decodable {

// since `date_gmt` is already in GMT timezone, manually add the timezone string to make the rfc3339 formatter happy (or it will throw otherwise).
guard let dateString = try? container.decode(String.self, forKey: .date),
let date = NSDate(wordPressComJSONString: dateString + "+00:00") as Date? else {
let date = NSDate.with(wordPressComJSONString: dateString + "+00:00") else {
throw DecodingError.dataCorruptedError(forKey: .date, in: container, debugDescription: "Date parsing failed")
}
self.date = date
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import Foundation

/// The parameters required to create a post or a page.
public struct RemotePostCreateParameters {
public struct RemotePostCreateParameters: Equatable {
public var type: String

public var status: String
public var date: Date?
public var authorID: Int?
Expand All @@ -21,13 +23,14 @@ public struct RemotePostCreateParameters {
public var tags: [String] = []
public var categoryIDs: [Int] = []

public init(status: String) {
public init(type: String, status: String) {
self.type = type
self.status = status
}
}

/// Represents a partial update to be applied to a post or a page.
public struct RemotePostUpdateParameters {
public struct RemotePostUpdateParameters: Equatable {
public var ifNotModifiedSince: Date?

public var status: String?
Expand Down Expand Up @@ -155,6 +158,7 @@ extension RemotePostCreateParameters {

private enum RemotePostWordPressComCodingKeys: String, CodingKey {
case ifNotModifiedSince = "if_not_modified_since"
case type
case status
case date
case authorID = "author"
Expand All @@ -178,6 +182,7 @@ struct RemotePostCreateParametersWordPressComEncoder: Encodable {

func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: RemotePostWordPressComCodingKeys.self)
try container.encodeIfPresent(parameters.type, forKey: .type)
try container.encodeIfPresent(parameters.status, forKey: .status)
try container.encodeIfPresent(parameters.date, forKey: .date)
try container.encodeIfPresent(parameters.authorID, forKey: .authorID)
Expand Down Expand Up @@ -243,8 +248,8 @@ struct RemotePostUpdateParametersWordPressComEncoder: Encodable {

private enum RemotePostXMLRPCCodingKeys: String, CodingKey {
case ifNotModifiedSince = "if_not_modified_since"
case type = "post_type"
case postStatus = "post_status"
case pageStatus = "page_status"
case date = "date_created_gmt"
case authorID = "wp_author_id"
case title
Expand All @@ -262,22 +267,13 @@ private enum RemotePostXMLRPCCodingKeys: String, CodingKey {
static let postTags = "post_tag"
}

enum RemotePostEncodingPostType {
case post, page
}

struct RemotePostCreateParametersXMLRPCEncoder: Encodable {
let parameters: RemotePostCreateParameters
let type: RemotePostEncodingPostType

func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: RemotePostXMLRPCCodingKeys.self)
switch type {
case .post:
try container.encodeIfPresent(parameters.status, forKey: .postStatus)
case .page:
try container.encodeIfPresent(parameters.status, forKey: .pageStatus)
}
try container.encode(parameters.type, forKey: .type)
try container.encodeIfPresent(parameters.status, forKey: .postStatus)
try container.encodeIfPresent(parameters.date, forKey: .date)
try container.encodeIfPresent(parameters.authorID, forKey: .authorID)
try container.encodeIfPresent(parameters.title, forKey: .title)
Expand Down Expand Up @@ -308,17 +304,11 @@ struct RemotePostCreateParametersXMLRPCEncoder: Encodable {

struct RemotePostUpdateParametersXMLRPCEncoder: Encodable {
let parameters: RemotePostUpdateParameters
let type: RemotePostEncodingPostType

func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: RemotePostXMLRPCCodingKeys.self)
try container.encodeIfPresent(parameters.ifNotModifiedSince, forKey: .ifNotModifiedSince)
switch type {
case .post:
try container.encodeIfPresent(parameters.status, forKey: .postStatus)
case .page:
try container.encodeIfPresent(parameters.status, forKey: .pageStatus)
}
try container.encodeIfPresent(parameters.status, forKey: .postStatus)
try container.encodeIfPresent(parameters.date, forKey: .date)
try container.encodeIfPresent(parameters.authorID, forKey: .authorID)
try container.encodeIfPresent(parameters.title, forKey: .title)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ - (void)getAccountDetailsWithSuccess:(void (^)(RemoteUser *remoteUser))success
NSString *requestUrl = [self pathForEndpoint:@"me"
withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1];

[self.wordPressComRestApi GET:requestUrl
[self.wordPressComRESTAPI get:requestUrl
parameters:nil
success:^(id responseObject, NSHTTPURLResponse *httpResponse) {
if (!success) {
Expand Down Expand Up @@ -108,7 +108,7 @@ - (void)updateBlogsVisibility:(NSDictionary *)blogs
};
NSString *path = [self pathForEndpoint:@"me/sites"
withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1];
[self.wordPressComRestApi POST:path
[self.wordPressComRESTAPI post:path
parameters:parameters
success:^(id responseObject, NSHTTPURLResponse *httpResponse) {
if (success) {
Expand All @@ -127,7 +127,7 @@ - (void)isPasswordlessAccount:(NSString *)identifier success:(void (^)(BOOL pass

NSString *path = [self pathForEndpoint:[NSString stringWithFormat:@"users/%@/auth-options", encodedIdentifier]
withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1];
[self.wordPressComRestApi GET:path
[self.wordPressComRESTAPI get:path
parameters:nil
success:^(id responseObject, NSHTTPURLResponse *httpResponse) {
if (!success) {
Expand All @@ -149,7 +149,7 @@ - (void)isEmailAvailable:(NSString *)email success:(void (^)(BOOL available))suc
static NSString * const errorEmailAddressInvalid = @"invalid";
static NSString * const errorEmailAddressTaken = @"taken";

[self.wordPressComRestApi GET:@"is-available/email"
[self.wordPressComRESTAPI get:@"is-available/email"
parameters:@{ @"q": email, @"format": @"json"}
success:^(id responseObject, NSHTTPURLResponse *httpResponse) {
if ([responseObject isKindOfClass:[NSDictionary class]]) {
Expand Down Expand Up @@ -211,7 +211,7 @@ - (void)isUsernameAvailable:(NSString *)username
success:(void (^)(BOOL available))success
failure:(void (^)(NSError *error))failure
{
[self.wordPressComRestApi GET:@"is-available/username"
[self.wordPressComRESTAPI get:@"is-available/username"
parameters:@{ @"q": username, @"format": @"json"}
success:^(id responseObject, NSHTTPURLResponse *httpResponse) {
if (!success) {
Expand Down Expand Up @@ -317,7 +317,7 @@ - (void)requestWPComMagicLinkForEmail:(NSString *)email
[params addEntriesFromDictionary:extraParams];
}

[self.wordPressComRestApi POST:path
[self.wordPressComRESTAPI post:path
parameters:[NSDictionary dictionaryWithDictionary:params]
success:^(id responseObject, NSHTTPURLResponse *httpResponse) {
if (success) {
Expand All @@ -336,7 +336,7 @@ - (void)requestVerificationEmailWithSucccess:(void (^)(void))success
NSString *path = [self pathForEndpoint:@"me/send-verification-email"
withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1];

[self.wordPressComRestApi POST:path parameters:nil success:^(id _Nonnull responseObject, NSHTTPURLResponse * _Nullable httpResponse) {
[self.wordPressComRESTAPI post:path parameters:nil success:^(id _Nonnull responseObject, NSHTTPURLResponse * _Nullable httpResponse) {
if (success) {
success();
}
Expand All @@ -355,7 +355,7 @@ - (void)getBlogsWithParameters:(NSDictionary *)parameters
{
NSString *requestUrl = [self pathForEndpoint:@"me/sites"
withVersion:ServiceRemoteWordPressComRESTApiVersion_1_2];
[self.wordPressComRestApi GET:requestUrl
[self.wordPressComRESTAPI get:requestUrl
parameters:parameters
success:^(id responseObject, NSHTTPURLResponse *httpResponse) {
if (success) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ - (void)getAllAuthorsWithRemoteUsers:(NSMutableArray <RemoteUser *>*)remoteUsers
NSString *requestUrl = [self pathForEndpoint:path
withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1];

[self.wordPressComRestApi GET:requestUrl
[self.wordPressComRESTAPI get:requestUrl
parameters:parameters
success:^(id responseObject, NSHTTPURLResponse *httpResponse) {
if (success) {
Expand Down Expand Up @@ -138,7 +138,7 @@ - (void)syncPostTypesWithSuccess:(PostTypesHandler)success
NSString *requestUrl = [self pathForEndpoint:path
withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1];
NSDictionary *parameters = @{@"context": @"edit"};
[self.wordPressComRestApi GET:requestUrl
[self.wordPressComRESTAPI get:requestUrl
parameters:parameters
success:^(NSDictionary *responseObject, NSHTTPURLResponse *httpResponse) {

Expand Down Expand Up @@ -168,7 +168,7 @@ - (void)syncPostFormatsWithSuccess:(PostFormatsHandler)success
NSString *requestUrl = [self pathForEndpoint:path
withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1];

[self.wordPressComRestApi GET:requestUrl
[self.wordPressComRESTAPI get:requestUrl
parameters:nil
success:^(id responseObject, NSHTTPURLResponse *httpResponse) {
NSDictionary *formats = [self mapPostFormatsFromResponse:responseObject[@"formats"]];
Expand All @@ -189,7 +189,7 @@ - (void)syncBlogWithSuccess:(BlogDetailsHandler)success
NSString *requestUrl = [self pathForEndpoint:path
withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1];

[self.wordPressComRestApi GET:requestUrl
[self.wordPressComRESTAPI get:requestUrl
parameters:nil
success:^(id responseObject, NSHTTPURLResponse *httpResponse) {
NSDictionary *responseDict = (NSDictionary *)responseObject;
Expand All @@ -210,7 +210,7 @@ - (void)syncBlogSettingsWithSuccess:(SettingsHandler)success
NSString *path = [self pathForSettings];
NSString *requestUrl = [self pathForEndpoint:path withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1];

[self.wordPressComRestApi GET:requestUrl
[self.wordPressComRESTAPI get:requestUrl
parameters:nil
success:^(id responseObject, NSHTTPURLResponse *httpResponse) {
if (![responseObject isKindOfClass:[NSDictionary class]]){
Expand Down Expand Up @@ -240,7 +240,7 @@ - (void)updateBlogSettings:(RemoteBlogSettings *)settings
NSString *path = [NSString stringWithFormat:@"sites/%@/settings?context=edit", self.siteID];
NSString *requestUrl = [self pathForEndpoint:path withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1];

[self.wordPressComRestApi POST:requestUrl
[self.wordPressComRESTAPI post:requestUrl
parameters:parameters
success:^(NSDictionary *responseDict, NSHTTPURLResponse *httpResponse) {
if (![responseDict isKindOfClass:[NSDictionary class]]) {
Expand Down Expand Up @@ -272,7 +272,7 @@ - (void)fetchSiteInfoForAddress:(NSString *)siteAddress
NSString *requestUrl = [self pathForEndpoint:path
withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1];

[self.wordPressComRestApi GET:requestUrl
[self.wordPressComRESTAPI get:requestUrl
parameters:nil
success:^(id responseObject, NSHTTPURLResponse *httpResponse) {
if (success) {
Expand All @@ -293,7 +293,7 @@ - (void)fetchUnauthenticatedSiteInfoForAddress:(NSString *)siteAddress
NSString *path = [self pathForEndpoint:@"connect/site-info" withVersion:ServiceRemoteWordPressComRESTApiVersion_1_1];
NSURL *siteURL = [NSURL URLWithString:siteAddress];

[self.wordPressComRestApi GET:path
[self.wordPressComRESTAPI get:path
parameters:@{ @"url": siteURL.absoluteString }
success:^(id responseObject, NSHTTPURLResponse *httpResponse) {
if (success) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 4425e5f

Please sign in to comment.