-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSTCollection.h
73 lines (62 loc) · 1.97 KB
/
STCollection.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//
// STCollection.h
// Stretchr
//
// Created by Tyler Bunnell on 4/17/14.
// Copyright (c) 2014 Stretchr, Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
@class STCollection;
@class STResponse;
@class STRequest;
/**
* STCollectionBlock defines the block signature for the block
* that will be called when a collection response is received
* from Stretchr
*
* @param request The original STRequest object used to make the request.
* @param resource The STCollection object from the response returned by
* Stretchr.
*/
typedef void (^STCollectionBlock)(STRequest* request, STCollection* collection);
@interface STCollection : NSObject
/**
* An array of STResource objects in this collection object.
*/
@property(readonly, nonatomic, copy) NSArray* resources;
/**
* The number of objects in this collection.
*/
@property(readonly, nonatomic) NSUInteger count;
/**
* The total number of objects in this collection.
*
* This value will only be set if the "total" parameter was included in the
* request that generated this colletion.
*/
@property(readonly, nonatomic) NSUInteger total;
/**
* All the objects in the response in raw NSDictionary format. Useful if you
* simply want to directly access the objects themselves without having to
* unwrap an STResource object.
*/
@property(readonly, nonatomic, copy) NSArray* rawObjects;
/**
* Creates a new STCollection object out of the given data object.
*
* @param response The data object from which to build the STCollection object.
* This data object is extracted from an STResponse object.
*
* @return The built STCollection object.
*/
+ (id)collectionWithData:(NSDictionary*)data;
/**
* Creates a new STCollection object out of the given data object.
*
* @param response The data object from which to build the STCollection object.
* This data object is extracted from an STResponse object.
*
* @return The built STCollection object.
*/
- (id)initWithData:(NSDictionary*)data;
@end