Skip to content

Commit

Permalink
Merge branch 'trunk' into fix/12945-stats-an-error-occurred-shows-on-…
Browse files Browse the repository at this point in the history
…insights-tab-2
  • Loading branch information
guarani committed Mar 29, 2024
2 parents 9ddb467 + c2a51c2 commit b1cc66d
Show file tree
Hide file tree
Showing 718 changed files with 863 additions and 902 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'
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ _None._

- Improved parsing using Codable for Stats Insight entities. [#763]

## 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 All @@ -62,6 +73,7 @@ _None._
### Internal Changes

- Add WP.com theme type information. [#750]
- Add `page` and `number` parameters to fetchFollowedSites in `ReaderTopicServiceRemote` [#753]

## 14.0.1

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.
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.
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.
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 @@ -139,11 +139,11 @@ - (void)uploadMedia:(NSArray *)mediaItems
if (remoteMedia.postID != nil && [remoteMedia.postID compare:@(0)] == NSOrderedDescending) {
parameters[@"attrs[0][parent_id]"] = remoteMedia.postID;
}
FilePart *filePart = [[FilePart alloc] initWithParameterName:@"media[]" url:remoteMedia.localURL filename:filename mimeType:type];
FilePart *filePart = [[FilePart alloc] initWithParameterName:@"media[]" url:remoteMedia.localURL fileName:filename mimeType:type];
[fileParts addObject:filePart];
}

[self.wordPressComRestApi multipartPOST:requestUrl
[self.wordPressComRESTAPI multipartPOST:requestUrl
parameters:parameters
fileParts:fileParts
requestEnqueued:^(NSNumber *taskID) {
Expand Down Expand Up @@ -203,8 +203,8 @@ - (void)uploadMedia:(RemoteMedia *)media
}
return;
}
FilePart *filePart = [[FilePart alloc] initWithParameterName:@"media[]" url:media.localURL filename:filename mimeType:type];
__block NSProgress *localProgress = [self.wordPressComRestApi multipartPOST:requestUrl
FilePart *filePart = [[FilePart alloc] initWithParameterName:@"media[]" url:media.localURL fileName:filename mimeType:type];
__block NSProgress *localProgress = [self.wordPressComRESTAPI multipartPOST:requestUrl
parameters:parameters
fileParts:@[filePart]
requestEnqueued:nil
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 @@ -58,7 +58,7 @@ public struct PluginDirectoryGetInformationEndpoint {

func buildRequest() throws -> URLRequest {
try HTTPRequestBuilder(url: PluginDirectoryRemoteConstants.getInformationEndpoint)
.append(percentEncodedPath: "\(slug).json")
.appendURLString("\(slug).json")
.query(name: "fields", value: "icons,banners")
.build()
}
Expand Down
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 @@ -164,8 +164,8 @@ - (void)createPost:(RemotePost *)post
parameters[@"content"] = post.content;
parameters[@"title"] = post.title;
parameters[@"status"] = post.status;
FilePart *filePart = [[FilePart alloc] initWithParameterName:@"media[]" url:media.localURL filename:filename mimeType:type];
[self.wordPressComRestApi multipartPOST:requestUrl
FilePart *filePart = [[FilePart alloc] initWithParameterName:@"media[]" url:media.localURL fileName:filename mimeType:type];
[self.wordPressComRESTAPI multipartPOST:requestUrl
parameters:parameters
fileParts:@[filePart]
requestEnqueued:^(NSNumber *taskID) {
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.
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,26 @@ extern NSString * const WordPressComReaderEndpointURL;
failure:(void (^)(NSError *error))failure;

/**
Get a list of the sites the user follows.
Get a list of the sites the user follows with the default API parameters.
@param success block called on a successful fetch.
@param failure block called if there is any error. `error` can be any underlying network error.
*/
- (void)fetchFollowedSitesWithSuccess:(void(^)(NSArray *sites))success
failure:(void(^)(NSError *error))failure;
failure:(void(^)(NSError *error))failure DEPRECATED_MSG_ATTRIBUTE("Use fetchFollowedSitesForPage:number:success:failure: instead.");

/**
Get a list of the sites the user follows with the specified API parameters.
@param page The page number to fetch.
@param number The number of sites to fetch per page.
@param success block called on a successful fetch.
@param failure block called if there is any error. `error` can be any underlying network error.
*/
- (void)fetchFollowedSitesForPage:(NSUInteger)page
number:(NSUInteger)number
success:(void(^)(NSNumber *totalSites, NSArray<RemoteReaderSiteInfo *> *sites))success
failure:(void(^)(NSError *error))failure;

/**
Unfollows the topic with the specified slug.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,21 @@ - (void)fetchReaderMenuWithSuccess:(void (^)(NSArray *topics))success failure:(v

- (void)fetchFollowedSitesWithSuccess:(void(^)(NSArray *sites))success failure:(void(^)(NSError *error))failure
{
NSString *path = @"read/following/mine?meta=site,feed";
void (^wrappedSuccess)(NSNumber *, NSArray<RemoteReaderSiteInfo *> *) = ^(NSNumber *totalSites, NSArray<RemoteReaderSiteInfo *> *sites) {
if (success) {
success(sites);
}
};

[self fetchFollowedSitesForPage:0 number:0 success:wrappedSuccess failure:failure];
}

- (void)fetchFollowedSitesForPage:(NSUInteger)page
number:(NSUInteger)number
success:(void(^)(NSNumber *totalSites, NSArray<RemoteReaderSiteInfo *> *sites))success
failure:(void(^)(NSError *error))failure
{
NSString *path = [self pathForFollowedSitesWithPage:page number:number];
NSString *requestUrl = [self pathForEndpoint:path
withVersion:ServiceRemoteWordPressComRESTApiVersion_1_2];

Expand All @@ -70,14 +84,14 @@ - (void)fetchFollowedSitesWithSuccess:(void(^)(NSArray *sites))success failure:(
return;
}
NSDictionary *response = (NSDictionary *)responseObject;
NSNumber *totalSites = [response numberForKey:@"total_subscriptions"];
NSArray *subscriptions = [response arrayForKey:@"subscriptions"];
NSMutableArray *sites = [NSMutableArray array];
for (NSDictionary *dict in subscriptions) {
RemoteReaderSiteInfo *siteInfo = [self siteInfoFromFollowedSiteDictionary:dict];
[sites addObject:siteInfo];
}
success(sites);

success(totalSites, sites);
} failure:^(NSError *error, NSHTTPURLResponse *httpResponse) {
if (failure) {
failure(error);
Expand Down Expand Up @@ -300,4 +314,17 @@ - (RemoteReaderTopic *)normalizeMenuTopicDictionary:(NSDictionary *)topicDict su
return topic;
}

- (NSString *)pathForFollowedSitesWithPage:(NSUInteger)page number:(NSUInteger)number
{
NSString *path = @"read/following/mine?meta=site,feed";
if (page > 0) {
path = [path stringByAppendingFormat:@"&page=%lu", (unsigned long)page];
}
if (number > 0) {
path = [path stringByAppendingFormat:@"&number=%lu", (unsigned long)number];
}

return path;
}

@end
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.
16 changes: 16 additions & 0 deletions Sources/WordPressKit/WordPressAPI/FilePart.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#import <Foundation/Foundation.h>

/// Represents the infomartion needed to encode a file on a multipart form request.
@interface FilePart: NSObject

@property (strong, nonatomic) NSString * _Nonnull parameterName;
@property (strong, nonatomic) NSURL * _Nonnull url;
@property (strong, nonatomic) NSString * _Nonnull fileName;
@property (strong, nonatomic) NSString * _Nonnull mimeType;

- (instancetype _Nonnull)initWithParameterName:(NSString * _Nonnull)parameterName
url:(NSURL * _Nonnull)url
fileName:(NSString * _Nonnull)fileName
mimeType:(NSString * _Nonnull)mimeType;

@end
18 changes: 18 additions & 0 deletions Sources/WordPressKit/WordPressAPI/FilePart.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#import "FilePart.h"

@implementation FilePart

- (instancetype)initWithParameterName:(NSString *)parameterName
url:(NSURL *)url
fileName:(NSString *)fileName
mimeType:(NSString *)mimeType
{
self = [super init];
self.parameterName = parameterName;
self.url = url;
self.fileName = fileName;
self.mimeType = mimeType;
return self;
}

@end
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,5 +1,7 @@
@import Foundation;

@class FilePart;

@protocol WordPressComRESTAPIInterfacing

@property (strong, nonatomic, readonly) NSURL * _Nonnull baseURL;
Expand All @@ -14,4 +16,11 @@
success:(void (^ _Nonnull)(id _Nonnull, NSHTTPURLResponse * _Nullable))success
failure:(void (^ _Nonnull)(NSError * _Nonnull, NSHTTPURLResponse * _Nullable))failure;

- (NSProgress * _Nullable)multipartPOST:(NSString * _Nonnull)URLString
parameters:(NSDictionary<NSString *, NSObject *> * _Nullable)parameters
fileParts:(NSArray<FilePart *> * _Nonnull)fileParts
requestEnqueued:(void (^ _Nullable)(NSNumber * _Nonnull))requestEnqueue
success:(void (^ _Nonnull)(id _Nonnull, NSHTTPURLResponse * _Nullable))success
failure:(void (^ _Nonnull)(NSError * _Nonnull, NSHTTPURLResponse * _Nullable))failure;

@end
Loading

0 comments on commit b1cc66d

Please sign in to comment.