From aac240ad8cb0f948a3569f8b30559ef4ea70044c Mon Sep 17 00:00:00 2001 From: Carlos Garcia Date: Wed, 10 Feb 2021 13:05:11 +0100 Subject: [PATCH 1/5] Add POST request to WP.org rest Api --- WordPressKit/WordPressOrgRestApi.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/WordPressKit/WordPressOrgRestApi.swift b/WordPressKit/WordPressOrgRestApi.swift index e62e1845..c9971bb2 100644 --- a/WordPressKit/WordPressOrgRestApi.swift +++ b/WordPressKit/WordPressOrgRestApi.swift @@ -31,6 +31,13 @@ open class WordPressOrgRestApi: NSObject, WordPressRestApi { return request(method: .get, path: path, parameters: parameters, completion: completion) } + @discardableResult + open func POST(_ path: String, + parameters: [String: AnyObject]?, + completion: @escaping Completion) -> Progress? { + return request(method: .post, path: path, parameters: parameters, completion: completion) + } + @discardableResult open func request(method: HTTPMethod, path: String, From ff8c5759143deb978180e2407d5f9a48c686ae31 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Date: Wed, 10 Feb 2021 14:02:12 +0100 Subject: [PATCH 2/5] Add unit test for WP.org POST request Apply swiftlint corrections Update `testSuccessfulPostCall` test case --- .../Mock Data/wp-reusable-blocks.json | 50 +++++++++++++++++++ .../WordPressOrgRestApiTests.swift | 32 +++++++++++- 2 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 WordPressKitTests/Mock Data/wp-reusable-blocks.json diff --git a/WordPressKitTests/Mock Data/wp-reusable-blocks.json b/WordPressKitTests/Mock Data/wp-reusable-blocks.json new file mode 100644 index 00000000..5e818f84 --- /dev/null +++ b/WordPressKitTests/Mock Data/wp-reusable-blocks.json @@ -0,0 +1,50 @@ +{ + "id": 6, + "date": "2021-02-10T11:51:53", + "date_gmt": "2021-02-10T11:51:53", + "guid": { + "rendered": "https:\/\/test-site.org\/2021\/02\/10\/untitled-reusable-block\/", + "raw": "https:\/\/test-site.org\/2021\/02\/10\/untitled-reusable-block\/" + }, + "modified": "2021-02-10T12:31:39", + "modified_gmt": "2021-02-10T12:31:39", + "password": "", + "slug": "untitled-reusable-block", + "status": "publish", + "type": "wp_block", + "link": "https:\/\/test-site.org\/2021\/02\/10\/untitled-reusable-block\/", + "title": { + "raw": "A resuable block" + }, + "content": { + "raw": "\n

Some text<\/p>\n\n\n\n