MNFBudget

Objective-C

@interface MNFBudget : MNFObject

Swift

class MNFBudget : MNFObject

The MNFBudget class represents a budget object with serialized json data from the server and methods to interact with the budget api.

Immutable properties

  • The type of the budget. ‘Planning’ or ‘Budget’.

    Declaration

    Objective-C

    @property (nonatomic, copy, readonly) NSString *_Nullable type;

    Swift

    var type: String? { get }
  • The period for the budget if the budget is a planning budget. ‘Month.

    Declaration

    Objective-C

    @property (nonatomic, copy, readonly) NSString *_Nullable period;

    Swift

    var period: String? { get }
  • The offset of the budget if the budget is a planning budget.

    Declaration

    Objective-C

    @property (nonatomic, copy, readonly) NSNumber *_Nullable offset;

    Swift

    @NSCopying var offset: NSNumber? { get }
  • The creation date of the budget.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly) NSDate *_Nullable created;

    Swift

    var created: Date? { get }
  • The budget entries.

    Declaration

    Objective-C

    @property (nonatomic, copy, readonly) NSArray<MNFBudgetEntry *> *_Nullable entries;

    Swift

    var entries: [MNFBudgetEntry]? { get }

Mutable properties

  • The name of the budget.

    Declaration

    Objective-C

    @property (nonatomic, copy) NSString *_Nullable name;

    Swift

    var name: String? { get set }
  • The text description of the budget.

    Declaration

    Objective-C

    @property (nonatomic, copy) NSString *_Nullable budgetDescription;

    Swift

    var budgetDescription: String? { get set }
  • The account ids of the accounts for the budget.

    Declaration

    Objective-C

    @property (nonatomic, copy) NSArray *_Nullable accountIds;

    Swift

    var accountIds: [Any]? { get set }

Fetching

  • Fetches a list of budget with a filter.

    Declaration

    Objective-C

    + (nonnull MNFJob *)
        fetchBudgetsWithIds:(nullable NSString *)ids
                 accountIds:(nullable NSString *)accountIds
                       type:(nullable NSString *)type
                 completion:(nullable MNFMultipleBudgetCompletionHandler)completion;

    Swift

    class func fetchBudgets(withIds ids: String?, accountIds: String?, type: String?, completion: MNFMultipleBudgetCompletionHandler? = nil) -> MNFJob

    Parameters

    ids

    The ids of the budgets to return in a comma separated string.

    accountIds

    The account ids to filter budgets by in a comma separated string.

    type

    The type of budget to return in the list.

    completion

    A completion block returning a list of budgets and an error.

    Return Value

    MNFJob A job containing a list of budgets and an error.

  • Fetches a single budget with a given identifier.

    Declaration

    Objective-C

    + (nonnull MNFJob *)fetchBudgetWithId:(nonnull NSNumber *)identifier
                                   filter:(nullable MNFBudgetFilter *)filter
                               completion:
                                   (nullable MNFBudgetCompletionHandler)completion;

    Swift

    class func fetch(withId identifier: NSNumber, filter: MNFBudgetFilter?, completion: MNFBudgetCompletionHandler? = nil) -> MNFJob

    Parameters

    identifier

    The identifiter of the budget to fetch.

    filter

    A filter object to filter by the budget entries.

    completion

    A completion block returning a budget and an error.

    Return Value

    MNFJob A job containing a budget and an error.

Creating

  • Creates a budget with the given parameters.

    Declaration

    Objective-C

    + (nonnull MNFJob *)budgetWithName:(nullable NSString *)name
                                  type:(nullable NSString *)type
                           description:(nullable NSString *)budgetDescription
                            accountIds:(nullable NSArray *)accountIds
                                period:(nullable NSString *)period
                                offset:(nullable NSNumber *)offset
                            completion:
                                (nullable MNFBudgetCompletionHandler)completion;

    Swift

    class func budget(withName name: String?, type: String?, description budgetDescription: String?, accountIds: [Any]?, period: String?, offset: NSNumber?, completion: MNFBudgetCompletionHandler? = nil) -> MNFJob

    Parameters

    name

    The name of the budget.

    type

    The budget type. ‘Budget’ or ‘Planning’.

    budgetDescription

    The text description of the budget.

    accountIds

    The ids of the accounts for the budget.

    completion

    A completion block returning a budget and an error.

    Return Value

    MNFJob A job containing a budget and an error.

Saving

  • Saves changes to a budget.

    Declaration

    Objective-C

    - (nonnull MNFJob *)saveWithCompletion:
        (nullable MNFErrorOnlyCompletionHandler)completion;

    Swift

    func save(completion: MNFErrorOnlyCompletionHandler? = nil) -> MNFJob

    Parameters

    completion

    A completion block returning an error.

    Return Value

    MNFJob A job containing an error.

Deleting

  • Deletes a budget.

    Declaration

    Objective-C

    - (nonnull MNFJob *)deleteWithCompletion:
        (nullable MNFErrorOnlyCompletionHandler)completion;

    Swift

    func delete(completion: MNFErrorOnlyCompletionHandler? = nil) -> MNFJob

    Parameters

    completion

    A completion block returning an error.

    Return Value

    MNFJob A job containing an error.

Refreshing

  • Refreshes a budget.

    Declaration

    Objective-C

    - (nonnull MNFJob *)refreshWithCompletion:
        (nullable MNFErrorOnlyCompletionHandler)completion;

    Swift

    func refresh(completion: MNFErrorOnlyCompletionHandler? = nil) -> MNFJob

    Parameters

    completion

    A completion block returning an error.

    Return Value

    MNFJob A job containing an error.

Fetching entries

  • Fetches budget entries in the budget.

    Declaration

    Objective-C

    - (nonnull MNFJob *)
        fetchBudgetEntriesWithFilter:(nullable MNFBudgetFilter *)filter
                          completion:
                              (nullable MNFMultipleBudgetEntriesCompletionHandler)
                                  completion;

    Swift

    func fetchEntries(with filter: MNFBudgetFilter?, completion: MNFMultipleBudgetEntriesCompletionHandler? = nil) -> MNFJob

    Parameters

    filter

    A filter object to filter the budget entries.

    completion

    A completion block returning a list of budget entries and an error.

    Return Value

    MNFJob A job containing a list of entries and an error.

  • Fetches a budget entry with a given identifier.

    Declaration

    Objective-C

    - (nonnull MNFJob *)
        fetchBudgetEntryWithId:(nonnull NSNumber *)identifier
                    completion:(nullable MNFBudgetEntryCompletionHandler)completion;

    Swift

    func fetchEntry(withId identifier: NSNumber, completion: MNFBudgetEntryCompletionHandler? = nil) -> MNFJob

    Parameters

    identifier

    The identifier of the budget entry.

    completion

    A completion block returning a budget entry and an error.

    Return Value

    MNFJob A job containing a budget entry and an error.

Creating entries

  • Creates budget entries in the budget.

    Warning

    The instances passed to the method as the entries to create are not the same instances returned in the completion block or job.

    Declaration

    Objective-C

    - (nonnull MNFJob *)
        createBudgetEntries:(nonnull NSArray<MNFBudgetEntry *> *)entries
                 completion:
                     (nullable MNFMultipleBudgetEntriesCompletionHandler)completion;

    Swift

    func createBudgetEntries(_ entries: [MNFBudgetEntry], completion: MNFMultipleBudgetEntriesCompletionHandler? = nil) -> MNFJob

    Parameters

    entries

    A list of budget entries to create.

    completion

    A completion block returning a budget entries and an error.

    Return Value

    MNFJob A job containing a list of entries and an error.

Resetting

  • Resets the entire budget.

    Declaration

    Objective-C

    - (nonnull MNFJob *)resetWithCompletion:
        (nullable MNFErrorOnlyCompletionHandler)completion;

    Swift

    func reset(completion: MNFErrorOnlyCompletionHandler? = nil) -> MNFJob

    Parameters

    completion

    A completion block returning an error.

    Return Value

    MNFJob A job containing an error.