Skip to content

Commit

Permalink
Update access control to components called by removed types
Browse files Browse the repository at this point in the history
  • Loading branch information
mokagio committed Apr 9, 2024
1 parent d17587a commit 58a6386
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 13 deletions.
32 changes: 24 additions & 8 deletions Sources/WordPressKit/Models/RemotePostParameters.swift
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,14 @@ private enum RemotePostWordPressComCodingKeys: String, CodingKey {
static let postTags = "post_tag"
}

struct RemotePostCreateParametersWordPressComEncoder: Encodable {
public struct RemotePostCreateParametersWordPressComEncoder: Encodable {
let parameters: RemotePostCreateParameters

func encode(to encoder: Encoder) throws {
public init(parameters: RemotePostCreateParameters) {
self.parameters = parameters
}

public 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)
Expand Down Expand Up @@ -212,10 +216,14 @@ struct RemotePostCreateParametersWordPressComEncoder: Encodable {
}
}

struct RemotePostUpdateParametersWordPressComEncoder: Encodable {
public struct RemotePostUpdateParametersWordPressComEncoder: Encodable {
let parameters: RemotePostUpdateParameters

func encode(to encoder: Encoder) throws {
public init(parameters: RemotePostUpdateParameters) {
self.parameters = parameters
}

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: RemotePostWordPressComCodingKeys.self)
try container.encodeIfPresent(parameters.ifNotModifiedSince, forKey: .ifNotModifiedSince)

Expand Down Expand Up @@ -274,10 +282,14 @@ private enum RemotePostXMLRPCCodingKeys: String, CodingKey {
static let postTags = "post_tag"
}

struct RemotePostCreateParametersXMLRPCEncoder: Encodable {
public struct RemotePostCreateParametersXMLRPCEncoder: Encodable {
let parameters: RemotePostCreateParameters

func encode(to encoder: Encoder) throws {
public init(parameters: RemotePostCreateParameters) {
self.parameters = parameters
}

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: RemotePostXMLRPCCodingKeys.self)
try container.encode(parameters.type, forKey: .type)
try container.encodeIfPresent(parameters.status, forKey: .postStatus)
Expand Down Expand Up @@ -309,10 +321,14 @@ struct RemotePostCreateParametersXMLRPCEncoder: Encodable {
}
}

struct RemotePostUpdateParametersXMLRPCEncoder: Encodable {
public struct RemotePostUpdateParametersXMLRPCEncoder: Encodable {
let parameters: RemotePostUpdateParameters

func encode(to encoder: Encoder) throws {
public init(parameters: RemotePostUpdateParameters) {
self.parameters = parameters
}

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: RemotePostXMLRPCCodingKeys.self)
try container.encodeIfPresent(parameters.ifNotModifiedSince, forKey: .ifNotModifiedSince)
try container.encodeIfPresent(parameters.status, forKey: .postStatus)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ extension DateFormatter {
/// A `DateFormatter` configured to manage dates compatible with the WordPress.com API.
///
/// - SeeAlso: [https://developer.wordpress.com/docs/api/](https://developer.wordpress.com/docs/api/)
static let wordPressCom: DateFormatter = {
public static let wordPressCom: DateFormatter = {
let formatter = DateFormatter()
formatter.dateFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ssZ"
formatter.timeZone = NSTimeZone(forSecondsFromGMT: 0) as TimeZone
Expand Down
4 changes: 2 additions & 2 deletions Sources/WordPressKit/WordPressAPI/HTTPRequestBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import wpxmlrpc
///
/// Calling this class's url related functions (the ones that changes path, query, etc) does not modify the
/// original URL string. The URL will be perserved in the final result that's returned by the `build` function.
final class HTTPRequestBuilder {
enum Method: String, CaseIterable {
public final class HTTPRequestBuilder {
public enum Method: String, CaseIterable {
case get = "GET"
case post = "POST"
case put = "PUT"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ open class WordPressComRestApi: NSObject {
return configuration
}

func perform(
public func perform(
_ method: HTTPRequestBuilder.Method,
URLString: String,
parameters: [String: AnyObject]? = nil,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ open class WordPressOrgXMLRPCApi: NSObject {
/// - Parameters:
/// - streaming: set to `true` if there are large data (i.e. uploading files) in given `parameters`. `false` by default.
/// - Returns: A `Result` type that contains the XMLRPC success or failure result.
func call(method: String, parameters: [AnyObject]?, fulfilling progress: Progress? = nil, streaming: Bool = false) async -> WordPressAPIResult<HTTPAPIResponse<AnyObject>, WordPressOrgXMLRPCApiFault> {
public func call(method: String, parameters: [AnyObject]?, fulfilling progress: Progress? = nil, streaming: Bool = false) async -> WordPressAPIResult<HTTPAPIResponse<AnyObject>, WordPressOrgXMLRPCApiFault> {
let session = streaming ? uploadURLSession : urlSession
let builder = HTTPRequestBuilder(url: endpoint)
.method(.post)
Expand Down

0 comments on commit 58a6386

Please sign in to comment.