MNFFeed

Objective-C

@interface MNFFeed : MNFObject

Swift

class MNFFeed : MNFObject

The MNFFeed class encapsulates the user feed json data in an object.

A feed 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 MNFFeed object.

Immutable properties

  • @abstract A list of feed items.

    @discussion Each feed item represents a list of transactions on the same date.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly) NSArray<MNFFeedItem *> *_Nullable feedItems;

    Swift

    var feedItems: [MNFFeedItem]? { get }
  • @abstract Whether the server feed has more data to be fetched.

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL hasMoreData;

    Swift

    var hasMoreData: Bool { get }
  • @abstract The starting date of the feed.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly) NSDate *_Nonnull from;

    Swift

    var from: Date { get }
  • to

    @abstract The final date of the feed.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly) NSDate *_Nonnull to;

    Swift

    var to: Date { get }
  • @abstract If not all items were returned within the specified time range, this field will indicate the date of the last returned item. Else it will be nil. This could happen either if a take value has been passed or the backend hard limit have been reached.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly) NSDate *_Nonnull actualEndDate;

    Swift

    var actualEndDate: Date { get }
  • @abstract Indicates whether there exists more pages when paginating.

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL hasMorePages;

    Swift

    var hasMorePages: Bool { get }
  • @abstract Use this value to explicitly state which feed items you would like to show in you. Make the value nil in order to display all topic ids. Defaults to nil.

    Declaration

    Objective-C

    @property (nonatomic, strong, nullable) NSArray<NSString *> *topicNamesToDisplay;

    Swift

    var topicNamesToDisplay: [String]? { get set }

Pagination

  • @description Adds the next page of feedItems to the feedItems of the feed object.

    Warning

    Should only be used if take has been used when fetching the feed object

    Declaration

    Objective-C

    - (nonnull MNFJob *)appendPageWithCompletion:
        (nonnull MNFFeedItemsCompletionHandler)completion;

    Swift

    func appendPage(completion: @escaping MNFFeedItemsCompletionHandler) -> MNFJob

    Return Value

    An MNFJob containing an error or nil.

  • @description Replaces the existing feedItems in the feed object with the next page of feed items.

    Declaration

    Objective-C

    - (nonnull MNFJob *)nextPageWithCompletion:
        (nonnull void (^)(NSError *_Nullable))completion;

    Swift

    func nextPage(completion: @escaping (Error?) -> Void) -> MNFJob

    Return Value

    An MNFJob containing an error or nil.

  • @description Replaces the existing feedItems in the feed object with the previous page of feed items.

    Declaration

    Objective-C

    - (nonnull MNFJob *)prevPageWithCompletion:
        (nonnull void (^)(NSError *_Nullable))completion;

    Swift

    func prevPage(completion: @escaping (Error?) -> Void) -> MNFJob

    Return Value

    An MNFJob containing an error or nil.

Fetching

  • @description Fetches the user feed from the server between two dates.

    Declaration

    Objective-C

    + (nonnull MNFJob *)fetchFromDate:(nonnull NSDate *)from
                               toDate:(nonnull NSDate *)to
                                 skip:(nullable NSNumber *)skip
                                 take:(nullable NSNumber *)take
                       withCompletion:(nullable MNFFeedCompletionHandler)completion;

    Swift

    class func fetch(from: Date, to: Date, skip: NSNumber?, take: NSNumber?, withCompletion completion: MNFFeedCompletionHandler? = nil) -> MNFJob

    Parameters

    from

    The date from which the feed is to be fetched.

    to

    The date to which the feed is to be fetched.

    skip

    The number of feed items to skip. If nil then no feed items are skipped.

    take

    The number of feed items to take. If nil then all items are returned.

    completion

    A completion block returning a feed and an error.

    Return Value

    An MNFJob containing an MNFFeed or an error.

  • @description Fetches the user feed from the server between two dates.

    Declaration

    Objective-C

    + (nonnull MNFJob *)fetchFromDate:(nonnull NSDate *)from
                               toDate:(nonnull NSDate *)to
                                 skip:(nullable NSNumber *)skip
                                 take:(nullable NSNumber *)take
                                 type:(nullable NSString *)type
                 eventTypeIdentifiers:(nullable NSString *)eventTypeIdentifiers
                       withCompletion:(nonnull MNFFeedCompletionHandler)completion;

    Swift

    class func fetch(from: Date, to: Date, skip: NSNumber?, take: NSNumber?, type: String?, eventTypeIdentifiers: String?, withCompletion completion: @escaping MNFFeedCompletionHandler) -> MNFJob

    Parameters

    from

    The date from which the feed is to be fetched.

    to

    The date to which the feed is to be fetched.

    skip

    The number of feed items to skip. If nil then no feed items are skipped.

    take

    The number of feed items to take. If nil then all items are returned.

    type

    A comma separated string of feed item types to return. Values can be found by fetching feed types.

    eventTypeIdentifiers

    A comma separated string of identifiers for which userevents to return. Values can be found by fetching event types in MNFUserEvent class.

    completion

    A completion block returning a feed and an error.

    Return Value

    An MNFJob containing an MNFFeed or an error.

Appending

  • @abstract Appends days to the back of the feed.

    Declaration

    Objective-C

    - (nonnull MNFJob *)appendDays:(nonnull NSNumber *)days
                    withCompletion:
                        (nullable MNFFeedItemsCompletionHandler)completion;

    Swift

    func appendDays(_ days: NSNumber, withCompletion completion: MNFFeedItemsCompletionHandler? = nil) -> MNFJob

    Parameters

    days

    The number of days to append to the feed.

    completion

    A completion block returning an error.

    Return Value

    An MNFJob containing the server result or an error.

Refresh

  • @abstract Replaces the feed data with feed data from the server.

    Declaration

    Objective-C

    - (nonnull MNFJob *)
        refreshFromServerFromDate:(nonnull NSDate *)from
                           toDate:(nonnull NSDate *)to
                   withCompletion:
                       (nullable void (^)(NSArray<MNFFeedItem *> *_Nonnull,
                                          NSArray<MNFFeedItem *> *_Nonnull,
                                          NSError *_Nonnull))completion;

    Swift

    func refreshFromServer(from: Date, to: Date, withCompletion completion: (([MNFFeedItem], [MNFFeedItem], Error) -> Void)? = nil) -> MNFJob

    Parameters

    from

    The date from which feed data is to be fetched.

    to

    The date to which feed data is to be fetched.

    completion

    A completion block returning an error.

    Return Value

    An MNFJob containing the server results or an error.

Fetch feed types

  • @abstract Fetches all the available feed types as an array of strings.

    Declaration

    Objective-C

    + (nonnull MNFJob *)fetchFeedTypesWithCompletion:
        (nullable MNFFeedTypesCompletionHandler)completion;

    Swift

    class func fetchTypes(completion: MNFFeedTypesCompletionHandler? = nil) -> MNFJob

    Parameters

    completion

    A completion block returning an array of strings and an error.

    Return Value

    An MNFJob containing an array of strings and an error.

Fetch feed types by id

  • @abstract Fetches a specific feeditem with type and identifier.

    Declaration

    Objective-C

    + (nonnull MNFJob *)fetchFeedItemWithFeedType:(nonnull NSString *)type
                                       identifier:(nonnull NSNumber *)identifier
                                   withCompletion:
                                       (nullable MNFSingleFeedItemCompletionHandler)
                                           completion;

    Swift

    class func fetchFeedItem(withFeedType type: String, identifier: NSNumber, withCompletion completion: MNFSingleFeedItemCompletionHandler? = nil) -> MNFJob

    Parameters

    type

    The feed type of the feeditem

    identifier

    The identifier of the feeditem

    completion

    A completion block returning an array of strings and an error.

    Return Value

    An MNFJob containing an array of strings and an error.

Fetch scheduled events

  • Fetches all scheduled user events in a given period.

    Declaration

    Objective-C

    + (nonnull MNFJob *)
        fetchScheduledEventsOfType:(nonnull NSString *)type
                          fromDate:(nonnull NSDate *)from
                            toDate:(nonnull NSDate *)to
                    withCompletion:
                        (nullable MNFMultipleScheduledEventsCompletionHandler)
                            completion;

    Swift

    class func fetchScheduledEvents(ofType type: String, from: Date, to: Date, withCompletion completion: MNFMultipleScheduledEventsCompletionHandler? = nil) -> MNFJob

    Parameters

    type

    The type of events to fetch. Can be ‘Weekly’ or ‘Monthly’.

    from

    The date from which scheduled events are fetched.

    to

    The date to which scheduled events are fetched.

    completion

    A completion block returning a list of scheduled events and an error.

    Return Value

    An MNFJob containing a list of scheduled events and an error.

Grouping

  • @abstract Groups all feed items by date into feed item groups.

    Declaration

    Objective-C

    - (void)groupByDate;

    Swift

    func groupByDate()
  • @abstract Ungroups feed item groups back into a list of feed items.

    Declaration

    Objective-C

    - (void)ungroup;

    Swift

    func ungroup()