MNFCategory
Objective-C
@interface MNFCategory : MNFObject {
NSArray *_children;
}
Swift
class MNFCategory : MNFObject
An MNFCategory encapsulates category json data from the server in an object.
A category should not be directly initialized but instead should be constructed with data from the server. The response from the server will be automatically converted to an MNFCategory object.
-
@abstract The default name of a parent category when presented as ‘other’ category
Declaration
Objective-C
@property (nonatomic, strong, readonly) NSString *_Nonnull otherCategoryName;
Swift
var otherCategoryName: String { get }
-
@abstract Whether the category is a public category or a user created category.
Declaration
Objective-C
@property (nonatomic, strong, readonly) NSNumber *_Nonnull isSystemCategory;
Swift
var isSystemCategory: NSNumber { get }
-
@abstract The category rank.
Declaration
Objective-C
@property (nonatomic, strong, readonly) NSString *_Nonnull categoryRank;
Swift
var categoryRank: String { get }
-
@abstract The budget generation type.
Declaration
Objective-C
@property (nonatomic, strong, readonly) NSNumber *_Nonnull budgetGenerationType;
Swift
var budgetGenerationType: NSNumber { get }
-
@abstract A list of the category’s children.
Declaration
Objective-C
@property (nonatomic, strong, readonly) NSArray *_Nonnull children;
Swift
var children: [Any] { get }
-
@abstract The category context identifier.
@discussion Indicates what context the category belongs to; normal or small business user.
Declaration
Objective-C
@property (nonatomic, strong, readonly) NSNumber *_Nonnull categoryContextId;
Swift
var categoryContextId: NSNumber { get }
-
@abstract The ascending order of the category.
Declaration
Objective-C
@property (nonatomic, strong, readonly) NSNumber *_Nonnull orderId;
Swift
var orderId: NSNumber { get }
-
@abstract Additional data for displaying the category.
Declaration
Objective-C
@property (nonatomic, strong, readonly) NSString *_Nonnull displayData;
Swift
var displayData: String { get }
-
@abstract The name of the category.
Declaration
Objective-C
@property (nonatomic, strong) NSString *_Nonnull name;
Swift
var name: String { get set }
-
@abstract The server identifier of a parent category.
@discussion If the category is not a child category this value is nil.
Declaration
Objective-C
@property (nonatomic, strong) NSNumber *_Nonnull parentCategoryId;
Swift
var parentCategoryId: NSNumber { get set }
-
@abstract Whether the category is a fixed expenses category.
Declaration
Objective-C
@property (nonatomic, strong) NSNumber *_Nonnull isFixedExpenses;
Swift
var isFixedExpenses: NSNumber { get set }
-
@abstract The category type.
Declaration
Objective-C
@property (nonatomic) MNFCategoryTypeId categoryTypeId;
Swift
var categoryTypeId: MNFCategoryTypeId { get set }
-
@description Fetches a category with a given identifier from the server.
Warning
does not fetch the children of the category.
Declaration
Objective-C
+ (nonnull MNFJob *)fetchWithId:(nonnull NSNumber *)identifier culture:(nullable NSString *)theCulture completion: (nullable MNFCategoryCompletionHandler)completion;
Swift
class func fetch(withId identifier: NSNumber, culture theCulture: String?, completion: MNFCategoryCompletionHandler? = nil) -> MNFJob
Parameters
theCulture
you can explicitly state the culture you want for the categories you are fetching. If nil is passed it uses the default culture of the user which can be set in MNFUser.
completion
A completion block returning either an MNFCategory or an error.
Return Value
MNFJob containing the result as an NSArray of MNFCategories or an error if applicable.
-
@description Fetches all user created categories
Declaration
Objective-C
+ (nonnull MNFJob *) fetchUserCreatedCategoriesWithCulture:(nullable NSString *)theCulture completion: (nullable MNFMultipleCategoriesCompletionHandler) completion;
Swift
class func fetchUserCreatedCategories(withCulture theCulture: String?, completion: MNFMultipleCategoriesCompletionHandler? = nil) -> MNFJob
Parameters
theCulture
you can explicitly state the culture you want for the categories you are fetching. If nil is passed it uses the default culture of the user which can be set in MNFUser.
completion
A completion block returning an NSArrary of MNFCategories or an error if applicable.
Return Value
MNFJob containing the results as an NSArrary of MNFCategories or an error if applicable.
-
@description Fetches all system categories.
Declaration
Objective-C
+ (nonnull MNFJob *) fetchSystemCategoriesWithCulture:(nullable NSString *)theCulture completion: (nullable MNFMultipleCategoriesCompletionHandler) completion;
Swift
class func fetchSystemCategories(withCulture theCulture: String?, completion: MNFMultipleCategoriesCompletionHandler? = nil) -> MNFJob
Parameters
theCulture
you can explicitly state the culture you want for the categories you are fetching. If nil is passed it uses the default culture of the user which can be set in MNFUser.
completion
A completion block returning an NSArray of MNFCategories or an error.
Return Value
MNFJob containing the results as an NSArray of MNFCategories or an error if applicable.
-
@description Fetches all categories both system and user categories.
Declaration
Objective-C
+ (nonnull MNFJob *) fetchCategoriesWithCulture:(nullable NSString *)theCulture completion:(nullable MNFMultipleCategoriesCompletionHandler) completion;
Swift
class func fetchCategories(withCulture theCulture: String?, completion: MNFMultipleCategoriesCompletionHandler? = nil) -> MNFJob
Parameters
theCulture
you can explicitly state the culture you want for the categories you are fetching. If nil is passed it uses the default culture of the user which can be set in MNFUser.
completion
a completion block returning an NSArray of MNFCategories or an error.
Return Value
MNFJob containing the results as an NSArray of MNFCategories or an error if applicable.
-
@description Fetches all categories and creates the tree structure for the categories
Declaration
Objective-C
+ (nonnull MNFJob *) fetchCategoryTreeWithCulture:(nullable NSString *)theCulture completion: (nullable MNFMultipleCategoriesCompletionHandler) completion;
Swift
class func fetchTree(withCulture theCulture: String?, completion: MNFMultipleCategoriesCompletionHandler? = nil) -> MNFJob
Parameters
theCulture
you can explicitly state the culture you want for the categories you are fetching. If nil is passed it uses the default culture of the user which can be set in MNFUser.
completion
a block returning an NSArray of MNFCategories in a tree structure or an error.
Return Value
MNFJob containing the results as an NSArray of MNFCategories or an error if applicable
-
@description Fetches the category types.
Declaration
Objective-C
+ (nonnull MNFJob *)fetchCategoryTypesWithCompletion: (nullable MNFMultipleCategoryTypesCompletionHandler)completion;
Swift
class func fetchTypes(completion: MNFMultipleCategoryTypesCompletionHandler? = nil) -> MNFJob
Parameters
completion
A completion block with an NSArray of MNFCategoryType instances or an error if one occurred.
Return Value
A job returning an NSArray of MNFCategoryType instances.
-
@description Creates a user category and returns it with a completion block. User categories can be distinguished by system categories using the isSystemCategory parameter.
Declaration
Objective-C
+ (nonnull MNFJob *) createUserParentCategoryWithName:(nonnull NSString *)theName isFixedExpense:(nullable NSNumber *)isFixedExpense categoryType:(MNFCategoryTypeId)theCategoryType completion: (nullable MNFCategoryCompletionHandler)completion;
Swift
class func createUserParentCategory(withName theName: String, isFixedExpense: NSNumber?, categoryType theCategoryType: MNFCategoryTypeId, completion: MNFCategoryCompletionHandler? = nil) -> MNFJob
Parameters
theName
The name of the category to be created.
isFixedExpense
A boolean variable wrapped in an NSNumber to indicate whether the category is a fixed expense or not. If nil is passed then by default it is not a fixed expense.
theCategoryType
An integer variable wrapped in an NSNumber to indicate the type of cateogry.
completion
An MNFCategory sent in the completion block or an error if one occurred.
Return Value
An MNFCategory sent in the completion block or an error if one occurred.
-
@description Creates a user category and returns it with a completion block. User categories can be distinguished by system categories using the isSystemCategory parameter.
Declaration
Objective-C
+ (nonnull MNFJob *) createUserChildCategoryWithName:(nonnull NSString *)theName isFixedExpense:(nullable NSNumber *)isFixedExpense parentCategoryType:(MNFCategoryTypeId)theParentCategoryType parentCategoryId:(nonnull NSNumber *)theParentCategoryId completion: (nullable MNFCategoryCompletionHandler)completion;
Swift
class func createUserChildCategory(withName theName: String, isFixedExpense: NSNumber?, parentCategoryType theParentCategoryType: MNFCategoryTypeId, parentCategoryId theParentCategoryId: NSNumber, completion: MNFCategoryCompletionHandler? = nil) -> MNFJob
Parameters
theName
The name of the category to be created.
isFixedExpense
A boolean variable wrapped in an NSNumber to indicate whether the category is a fixed expense or not. If nil is passed then by default it is not a fixed expense.
theParentCategoryType
An integer variable wrapped in an NSNumber to indicate the type of cateogry.
theParentCategoryId
The id of the parent of the userCategory. Pass nil if you want the category to be a parent category.
completion
An MNFCategory sent in the completion block or an error if one occurred.
Return Value
An MNFCategory sent in the completion block or an error if one occurred.
-
@description Saves changes to the user category to the server. Or if it is a new category, it creates it on the server and updates it.
Declaration
Objective-C
- (nonnull MNFJob *)saveWithCompletion: (nullable MNFErrorOnlyCompletionHandler)completion;
Swift
func save(completion: MNFErrorOnlyCompletionHandler? = nil) -> MNFJob
Parameters
completion
A completion block returning the server result and an error.
Return Value
MNFJob A job containing the server result and an error.
-
@description Refreshes the given category by fetching it from the server.
Warning
does not update the children of the category.
Declaration
Objective-C
- (nonnull MNFJob *)refreshWithCompletion: (nullable MNFErrorOnlyCompletionHandler)completion;
Swift
func refresh(completion: MNFErrorOnlyCompletionHandler? = nil) -> MNFJob
Parameters
completion
A completion returning an NSError if the refresh failed.
Return Value
MNFJob containing an NSError if the refresh failed.
-
@description Deletes the user category from the server.
Warning
Remember to deallocate objects that have been deleted from the server.
Declaration
Objective-C
- (nonnull MNFJob *) deleteCategoryWithConnectedRules:(nullable NSNumber *)deleteConnectedRules moveTransactionsToNewCategoryId:(nullable NSNumber *)theNewCategoryId completion:(nullable MNFErrorOnlyCompletionHandler) completion;
Swift
func delete(withConnectedRules deleteConnectedRules: NSNumber?, moveTransactionsToNewCategoryId theNewCategoryId: NSNumber?, completion: MNFErrorOnlyCompletionHandler? = nil) -> MNFJob
Parameters
completion
A completion block returning an error.
Return Value
MNFJob A job containing an error.
-
@description Creates a category tree from a list of categories.
Declaration
Objective-C
+ (nonnull NSArray<MNFCategory *> *)categoryTreeFromCategories: (nonnull NSArray<MNFCategory *> *)categories;
Swift
class func categoryTree(fromCategories categories: [MNFCategory]) -> [MNFCategory]
Parameters
categories
The categories to use to create the tree.
Return Value
A category tree made from the categories provided.
-
@description Creates a flat list of categories from a category tree.
Declaration
Objective-C
+ (nonnull NSArray<MNFCategory *> *)categoriesFromCategoryTree: (nonnull NSArray<MNFCategory *> *)categoryTree;
Swift
class func categories(fromCategoryTree categoryTree: [MNFCategory]) -> [MNFCategory]
Parameters
categoryTree
The category tree to create the list from.
Return Value
A flat list of categories made from the category tree provided.