Skip to content

Commit

Permalink
added the taxonomy API calls
Browse files Browse the repository at this point in the history
evermeer committed Sep 21, 2015
1 parent 50e79fa commit ef98745
Showing 5 changed files with 103 additions and 8 deletions.
6 changes: 6 additions & 0 deletions EVWordPressAPI.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
@@ -11,6 +11,8 @@
34F8D345B1B84C9143635E64 /* Pods.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E8794B1C8EEE9BA04FEF83DD /* Pods.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
7F05E8B01BAFEE010046AB5C /* EVWordpressAPI_Comments.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F05E8AF1BAFEE010046AB5C /* EVWordpressAPI_Comments.swift */; settings = {ASSET_TAGS = (); }; };
7F05E8B11BAFF13E0046AB5C /* EVWordpressAPI_Comments.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F05E8AF1BAFEE010046AB5C /* EVWordpressAPI_Comments.swift */; settings = {ASSET_TAGS = (); }; };
7F05E8B31BAFFE8C0046AB5C /* EVWordPressAPI_Taxonomy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F05E8B21BAFFE8C0046AB5C /* EVWordPressAPI_Taxonomy.swift */; settings = {ASSET_TAGS = (); }; };
7F05E8B41BB000090046AB5C /* EVWordPressAPI_Taxonomy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F05E8B21BAFFE8C0046AB5C /* EVWordPressAPI_Taxonomy.swift */; settings = {ASSET_TAGS = (); }; };
7F0E6DC31BA75BCB0071AC65 /* EVWordPressAPI_Users.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F139E9D1B6A18FC00D32731 /* EVWordPressAPI_Users.swift */; settings = {ASSET_TAGS = (); }; };
7F139E9E1B6A18FC00D32731 /* EVWordPressAPI_Users.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F139E9D1B6A18FC00D32731 /* EVWordPressAPI_Users.swift */; };
7F139EA01B6A1EFD00D32731 /* EVWordPressAPI_Posts.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F139E9F1B6A1EFD00D32731 /* EVWordPressAPI_Posts.swift */; };
@@ -36,6 +38,7 @@
/* Begin PBXFileReference section */
450FD17338218F5D03655DE2 /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = "<group>"; };
7F05E8AF1BAFEE010046AB5C /* EVWordpressAPI_Comments.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EVWordpressAPI_Comments.swift; sourceTree = "<group>"; };
7F05E8B21BAFFE8C0046AB5C /* EVWordPressAPI_Taxonomy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EVWordPressAPI_Taxonomy.swift; sourceTree = "<group>"; };
7F139E9D1B6A18FC00D32731 /* EVWordPressAPI_Users.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EVWordPressAPI_Users.swift; sourceTree = "<group>"; };
7F139E9F1B6A1EFD00D32731 /* EVWordPressAPI_Posts.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EVWordPressAPI_Posts.swift; sourceTree = "<group>"; };
7F139EA11B6A20EE00D32731 /* EVWordPressAPI_Sites.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EVWordPressAPI_Sites.swift; sourceTree = "<group>"; };
@@ -180,6 +183,7 @@
7F139EA11B6A20EE00D32731 /* EVWordPressAPI_Sites.swift */,
7F139E9F1B6A1EFD00D32731 /* EVWordPressAPI_Posts.swift */,
7F05E8AF1BAFEE010046AB5C /* EVWordpressAPI_Comments.swift */,
7F05E8B21BAFFE8C0046AB5C /* EVWordPressAPI_Taxonomy.swift */,
);
path = EVWordPressAPI;
sourceTree = "<group>";
@@ -388,6 +392,7 @@
7F139EA21B6A20EE00D32731 /* EVWordPressAPI_Sites.swift in Sources */,
7F05E8B01BAFEE010046AB5C /* EVWordpressAPI_Comments.swift in Sources */,
7F7CFCFA1B5F839100A42318 /* ViewController.swift in Sources */,
7F05E8B31BAFFE8C0046AB5C /* EVWordPressAPI_Taxonomy.swift in Sources */,
7F159E031BA6E16C00247CB1 /* EVWordpressParameters.swift in Sources */,
7F7CFCF81B5F839100A42318 /* AppDelegate.swift in Sources */,
7F139E9E1B6A18FC00D32731 /* EVWordPressAPI_Users.swift in Sources */,
@@ -400,6 +405,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
7F05E8B41BB000090046AB5C /* EVWordPressAPI_Taxonomy.swift in Sources */,
7F7CFD0E1B5F839100A42318 /* EVWordPressAPITests.swift in Sources */,
7F05E8B11BAFF13E0046AB5C /* EVWordpressAPI_Comments.swift in Sources */,
7F655AFB1B68A231003FF992 /* WordPressRequestConvertible.swift in Sources */,
71 changes: 71 additions & 0 deletions EVWordPressAPI/EVWordPressAPI_Taxonomy.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
//
// EVWordPressAPI_Taxonomy.swift
// EVWordPressAPI
//
// Created by Edwin Vermeer on 9/21/15.
// Copyright © 2015 evict. All rights reserved.
//

import Alamofire
import AlamofireOauth2
import AlamofireJsonToObjects
import EVReflection


public extension EVWordPressAPI {
// MARK: - Comments


/**
Get information about a single category.
See: https://developer.wordpress.com/docs/api/1.1/get/sites/%24site/categories/slug:%24category/

:param: category The category where you want to get the information of
:param: parameters an array of basicContextParameters. For complete list plus documentation see the api documentation
:param: completionHandler A code block that will be called with the Posts object
:return: No return value
*/
public func category(category:String?, parameters:[basicContextParameters]? = nil, completionHandler: (Taxonomy?) -> Void) {
genericCall("/sites/\(self.site)/categories/slug:\(category)", parameters:parameters, completionHandler: completionHandler)
}


/**
Get a list of a site's categories.
See: https://developer.wordpress.com/docs/api/1.1/get/sites/%24site/categories/

:param: category The category where you want to get the information of
:param: parameters an array of basicContextParameters. For complete list plus documentation see the api documentation
:param: completionHandler A code block that will be called with the Posts object
:return: No return value
*/
public func categories(parameters:[basicContextParameters]? = nil, completionHandler: (Categories?) -> Void) {
genericCall("/sites/\(self.site)/categories/", parameters:parameters, completionHandler: completionHandler)
}


/**
Get a list of a site's tags.
See: https://developer.wordpress.com/docs/api/1.1/get/sites/%24site/tags/

:param: parameters an array of tagsParameters. For complete list plus documentation see the api documentation
:param: completionHandler A code block that will be called with the Posts object
:return: No return value
*/
public func tags(parameters:[tagsParameters]? = nil, completionHandler: (Tags?) -> Void) {
genericCall("/sites/\(self.site)/tags/", parameters:parameters, completionHandler: completionHandler)
}


/**
Get information about a single tag.
See: https://developer.wordpress.com/docs/api/1.1/get/sites/%24site/tags/slug:%24tag/

:param: parameters an array of basicContextParameters. For complete list plus documentation see the api documentation
:param: completionHandler A code block that will be called with the Posts object
:return: No return value
*/
public func tag(tag:String, parameters:[basicContextParameters]? = nil, completionHandler: (Taxonomy?) -> Void) {
genericCall("/sites/\(self.site)/tags/slug:\(tag)", parameters:parameters, completionHandler: completionHandler)
}
}
16 changes: 9 additions & 7 deletions EVWordPressAPI/EVWordpressData.swift
Original file line number Diff line number Diff line change
@@ -117,33 +117,35 @@ public class Capabilities: EVObject {
}


public class Categories: EVObject {
var categories = [Categorie]()
public class Categories: WPObject {
var found: Int = 0
var categories = [Taxonomy]()

// This way we can solve that the JSON uses values for keys
public override func setValue(value: AnyObject!, forUndefinedKey key: String) {
if let dic = value as? NSDictionary {
categories.append(Categorie(dictionary: dic))
categories.append(Taxonomy(dictionary: dic))
return
}
NSLog("---> setValue for key '\(key)' should be handled.")
}
}

public class Tags: EVObject {
var tags = [Categorie]()
public class Tags: WPObject {
var found: Int = 0
var tags = [Taxonomy]()

// This way we can solve that the JSON uses values for keys
public override func setValue(value: AnyObject!, forUndefinedKey key: String) {
if let dic = value as? NSDictionary {
tags.append(Categorie(dictionary: dic))
tags.append(Taxonomy(dictionary: dic))
return
}
NSLog("---> setValue for key '\(key)' should be handled.")
}
}

public class Categorie: EVObject {
public class Taxonomy: WPObject {
var ID: Int = 0
var name: String?
var slug: String?
16 changes: 16 additions & 0 deletions EVWordPressAPI/EVWordpressParameters.swift
Original file line number Diff line number Diff line change
@@ -172,3 +172,19 @@ public enum commentsParameters: EVAssociated {
case type(String)
case status(String)
}


public enum tagsParameters: EVAssociated {
case context(String)
case http_envelope(Bool)
case pretty(Bool)
case meta(String)
case fields(String)
case callback(String)
case number(Int)
case offset(Int)
case page(Int)
case search(String)
case order(String)
case order_by(String)
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ API sections - status (for now only the get calls)
- Sites - all 11 get calls implemented
- Posts - all 6 get calls implemented
- Comments - all 5 get calls implemented
- Taxonomy - to do
- Taxonomy - al 4 get calls implemented
- Follow - to do
- Freshly Pressed - to do
- Notifications - to do

0 comments on commit ef98745

Please sign in to comment.