@@ -21,6 +21,7 @@ public struct RemotePostCreateParameters: Equatable {
2121 public var format : String ?
2222 public var isSticky = false
2323 public var tags : [ String ] = [ ]
24+ public var otherTerms : [ String : [ String ] ] = [ : ]
2425 public var categoryIDs : [ Int ] = [ ]
2526 public var metadata : Set < RemotePostMetadataItem > = [ ]
2627 public var discussion : RemotePostDiscussionSettings = . default
@@ -52,6 +53,7 @@ public struct RemotePostUpdateParameters: Equatable {
5253 public var format : String ? ?
5354 public var isSticky : Bool ?
5455 public var tags : [ String ] ?
56+ public var otherTerms : [ String : [ String ] ] ?
5557 public var categoryIDs : [ Int ] ?
5658 public var metadata : Set < RemotePostMetadataItem > ?
5759 public var discussion : RemotePostDiscussionSettings ?
@@ -138,6 +140,9 @@ extension RemotePostCreateParameters {
138140 if previous. tags != tags {
139141 changes. tags = tags
140142 }
143+ if !RemotePost. compareOtherTerms ( previous. otherTerms, withAnother: otherTerms) {
144+ changes. otherTerms = otherTerms
145+ }
141146 if Set ( previous. categoryIDs) != Set ( categoryIDs) {
142147 changes. categoryIDs = categoryIDs
143148 }
@@ -191,6 +196,9 @@ extension RemotePostCreateParameters {
191196 if let tags = changes. tags {
192197 self . tags = tags
193198 }
199+ if let otherTerms = changes. otherTerms {
200+ self . otherTerms = otherTerms
201+ }
194202 if let categoryIDs = changes. categoryIDs {
195203 self . categoryIDs = categoryIDs
196204 }
@@ -253,9 +261,19 @@ struct RemotePostCreateParametersWordPressComEncoder: Encodable {
253261
254262 // Posts
255263 try container. encodeIfPresent ( parameters. format, forKey: . format)
264+
265+ // Terms (including tags)
266+ var terms = [ String: [ String] ] ( )
256267 if !parameters. tags. isEmpty {
257- try container . encode ( [ RemotePostWordPressComCodingKeys . postTags: parameters . tags ] , forKey : . terms )
268+ terms [ RemotePostWordPressComCodingKeys . postTags] = parameters . tags
258269 }
270+ if !parameters. otherTerms. isEmpty {
271+ terms. merge ( parameters. otherTerms) { old, _ in old }
272+ }
273+ if !terms. isEmpty {
274+ try container. encode ( terms, forKey: . terms)
275+ }
276+
259277 if !parameters. categoryIDs. isEmpty {
260278 try container. encodeIfPresent ( parameters. categoryIDs, forKey: . categoryIDs)
261279 }
@@ -330,16 +348,25 @@ struct RemotePostUpdateParametersWordPressComEncoder: Encodable {
330348 try container. encode ( metadata, forKey: . metadata)
331349 }
332350
351+ // Terms (including tags)
352+ var terms = [ String: [ String] ] ( )
353+ if let tags = parameters. tags, !tags. isEmpty {
354+ terms [ RemotePostWordPressComCodingKeys . postTags] = tags
355+ }
356+ if let otherTerms = parameters. otherTerms, !otherTerms. isEmpty {
357+ terms. merge ( otherTerms) { old, _ in old }
358+ }
359+ if !terms. isEmpty {
360+ try container. encode ( terms, forKey: . terms)
361+ }
362+
333363 // Pages
334364 if let parentPageID = parameters. parentPageID {
335365 try container. encodeNullableID ( parentPageID, forKey: . parentPageID)
336366 }
337367
338368 // Posts
339369 try container. encodeIfPresent ( parameters. format, forKey: . format)
340- if let tags = parameters. tags {
341- try container. encode ( [ RemotePostWordPressComCodingKeys . postTags: tags] , forKey: . terms)
342- }
343370 try container. encodeIfPresent ( parameters. categoryIDs, forKey: . categoryIDs)
344371 try container. encodeIfPresent ( parameters. isSticky, forKey: . isSticky)
345372 if let discussion = parameters. discussion {
@@ -395,14 +422,23 @@ struct RemotePostCreateParametersXMLRPCEncoder: Encodable {
395422 try container. encode ( metadata, forKey: . metadata)
396423 }
397424
425+ // Terms (including tags)
426+ var terms = [ String: [ String] ] ( )
427+ if !parameters. tags. isEmpty {
428+ terms [ RemotePostXMLRPCCodingKeys . taxonomyTag] = parameters. tags
429+ }
430+ if !parameters. otherTerms. isEmpty {
431+ terms. merge ( parameters. otherTerms) { old, _ in old }
432+ }
433+ if !terms. isEmpty {
434+ try container. encode ( terms, forKey: . termNames)
435+ }
436+
398437 // Pages
399438 try container. encodeIfPresent ( parameters. parentPageID, forKey: . parentPageID)
400439
401440 // Posts
402441 try container. encodeIfPresent ( parameters. format, forKey: . format)
403- if !parameters. tags. isEmpty {
404- try container. encode ( [ RemotePostXMLRPCCodingKeys . taxonomyTag: parameters. tags] , forKey: . termNames)
405- }
406442 if !parameters. categoryIDs. isEmpty {
407443 try container. encode ( [ RemotePostXMLRPCCodingKeys . taxonomyCategory: parameters. categoryIDs] , forKey: . terms)
408444 }
@@ -438,16 +474,25 @@ struct RemotePostUpdateParametersXMLRPCEncoder: Encodable {
438474 try container. encode ( metadata, forKey: . metadata)
439475 }
440476
477+ // Terms (including tags)
478+ var terms = [ String: [ String] ] ( )
479+ if let tags = parameters. tags, !tags. isEmpty {
480+ terms [ RemotePostXMLRPCCodingKeys . taxonomyTag] = tags
481+ }
482+ if let otherTerms = parameters. otherTerms, !otherTerms. isEmpty {
483+ terms. merge ( otherTerms) { old, _ in old }
484+ }
485+ if !terms. isEmpty {
486+ try container. encode ( terms, forKey: . termNames)
487+ }
488+
441489 // Pages
442490 if let parentPageID = parameters. parentPageID {
443491 try container. encodeNullableID ( parentPageID, forKey: . parentPageID)
444492 }
445493
446494 // Posts
447495 try container. encodeStringIfPresent ( parameters. format, forKey: . format)
448- if let tags = parameters. tags {
449- try container. encode ( [ RemotePostXMLRPCCodingKeys . taxonomyTag: tags] , forKey: . termNames)
450- }
451496 if let categoryIDs = parameters. categoryIDs {
452497 try container. encode ( [ RemotePostXMLRPCCodingKeys . taxonomyCategory: categoryIDs] , forKey: . terms)
453498 }
0 commit comments