/
SPRequest.h
221 lines (199 loc) · 9.8 KB
/
SPRequest.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
//
// SPRequest.h
// Spectttator
//
// Created by David Keegan on 6/25/11.
// Copyright 2011 David Keegan.
//
#import <Foundation/Foundation.h>
#import "SPShot.h"
#import "SPPlayer.h"
#import "SPPagination.h"
extern NSString *const SPListDebuts;
extern NSString *const SPListEveryone;
extern NSString *const SPListPopular;
/** The `SPRequest` class provides a programmatic interface for interacting
with the majority of [Dribbble api](http://dribbble.com/api) calls, there are some shot centric
methods implemented on the `SPShot` object.
The following snippet demonstrates how to get the last 10 shots a player liked.
#import <Spectttator/Spectttator.h>
NSString *username = @"kgn";
[SPRequest shotsForPlayerLikes:username
withPagination:[SPPagination perPage:10]
runOnMainThread:NO
withBlock:^(NSArray *shots, SPPagination *pagination){
NSLog(@"Shot %@ likes: %@", username, shots);
}];
This is non-blocking, `NSLog` will run whenever the comment data has finished loading,
but the block still has access to everything in the scope from where it was defined.
If the block is updating UI elements make sure to set `runOnMainThread:YES`, the Dribbble
requests will still be asynchronous but the passed in block will be executed on the main thread.
*/
@interface SPRequest : NSObject
///----------------------------
/// @name Players
///----------------------------
/**
Retrieves profile details for a player specified by _username_.
@param username The username of the player.
@param runOnMainThread Specifies if the passed in block should be run on the main thread.
If UI elements are being updated in the block this should be `YES`.
@param block The block to be executed once the data has been retrieved.
A `SPPlayer` object is passed to the block.
@see SPPlayer
*/
+ (void)playerInformationForUsername:(NSString *)username
runOnMainThread:(BOOL)runOnMainThread
withBlock:(void (^)(SPPlayer *player))block;
/**
Retrieves the list of followers for a player specified by _username_.
@param username The username of the player.
@param pagination A NSDictionary with pagination data, the best way to
create this dictionary is with the helper functions on `SPPagination`.
If `nil` the default pagination will be used as defined by the
[dribbble api](http://dribbble.com/api#pagination).
@param runOnMainThread Specifies if the passed in block should be run on the main thread.
If UI elements are being updated in the block this should be `YES`.
@param block The block to be executed once the data has been retrieved.
An `NSArray` of `SPPlayer` objects and a `SPPagination` objects are passed to the block.
@see playerFollowers:withBlock:
@see SPPagination
@see SPPlayer
*/
+ (void)playerFollowers:(NSString *)username
withPagination:(NSDictionary *)pagination
runOnMainThread:(BOOL)runOnMainThread
withBlock:(void (^)(NSArray *players, SPPagination *pagination))block;
/**
Retrieves the list of followers for a player specified by _username_.
@param username The username of the player.
@param pagination A NSDictionary with pagination data, the best way to
create this dictionary is with the helper functions on `SPPagination`.
If `nil` the default pagination will be used as defined by the
[dribbble api](http://dribbble.com/api#pagination).
@param runOnMainThread Specifies if the passed in block should be run on the main thread.
If UI elements are being updated in the block this should be `YES`.
@param block The block to be executed once the data has been retrieved.
An `NSArray` of `SPPlayer` objects and a `SPPagination` objects are passed to the block.
@see playerFollowing:withBlock:
@see SPPagination
@see SPPlayer
*/
+ (void)playerFollowing:(NSString *)username
withPagination:(NSDictionary *)pagination
runOnMainThread:(BOOL)runOnMainThread
withBlock:(void (^)(NSArray *players, SPPagination *pagination))block;
/**
Retrieves the list of players drafted by the player specified by _username_.
@param username The username of the player.
@param pagination A NSDictionary with pagination data, the best way to
create this dictionary is with the helper functions on `SPPagination`.
If `nil` the default pagination will be used as defined by the
[dribbble api](http://dribbble.com/api#pagination).
@param runOnMainThread Specifies if the passed in block should be run on the main thread.
If UI elements are being updated in the block this should be `YES`.
@param block The block to be executed once the data has been retrieved.
An `NSArray` of `SPPlayer` objects and a `SPPagination` objects are passed to the block.
@see playerDraftees:withBlock:
@see SPPagination
@see SPPlayer
*/
+ (void)playerDraftees:(NSString *)username
withPagination:(NSDictionary *)pagination
runOnMainThread:(BOOL)runOnMainThread
withBlock:(void (^)(NSArray *players, SPPagination *pagination))block;
///----------------------------
/// @name Shots
///----------------------------
/**
Retrieves details for a shot specified by _id_.
@param identifier The shot identifier number.
@param runOnMainThread Specifies if the passed in block should be run on the main thread.
If UI elements are being updated in the block this should be `YES`.
@param block The block to be executed once the data has been retrieved.
A `SPShot` object is passed to the block.
@see SPShot
*/
+ (void)shotInformationForIdentifier:(NSUInteger)identifier
runOnMainThread:(BOOL)runOnMainThread
withBlock:(void (^)(SPShot *shot))block;
/**
Retrieves the specified list of shots.
@param list The list to retrieve shots from, must be one of the following values:
- `SPDebutsList`
- `SPEveryoneList`
- `SPPopularList`
@param pagination A NSDictionary with pagination data, the best way to
create this dictionary is with the helper functions on `SPPagination`.
If `nil` the default pagination will be used as defined by the
[dribbble api](http://dribbble.com/api#pagination).
@param runOnMainThread Specifies if the passed in block should be run on the main thread.
If UI elements are being updated in the block this should be `YES`.
@param block The block to be executed once the data has been retrieved.
An `NSArray` of `SPShot` objects and a `SPPagination` objects are passed to the block.
@see shotsForList:withBlock:
@see SPPagination
@see SPShot
*/
+ (void)shotsForList:(NSString *)list
withPagination:(NSDictionary *)pagination
runOnMainThread:(BOOL)runOnMainThread
withBlock:(void (^)(NSArray *shots, SPPagination *pagination))block;
/**
Retrieves the most recent shots for the player specified by _username_.
@param username The username of the player.
@param pagination A NSDictionary with pagination data, the best way to
create this dictionary is with the helper functions on `SPPagination`.
If `nil` the default pagination will be used as defined by the
[dribbble api](http://dribbble.com/api#pagination).
@param runOnMainThread Specifies if the passed in block should be run on the main thread.
If UI elements are being updated in the block this should be `YES`.
@param block The block to be executed once the data has been retrieved.
An `NSArray` of `SPShot` objects and a `SPPagination` objects are passed to the block.
@see shotsForPlayer:withBlock:
@see SPPagination
@see SPShot
*/
+ (void)shotsForPlayer:(NSString *)username
withPagination:(NSDictionary *)pagination
runOnMainThread:(BOOL)runOnMainThread
withBlock:(void (^)(NSArray *shots, SPPagination *pagination))block;
/**
Retrieves the most recent shots published by those the player specified by _username_ is following.
@param username The username of the player.
@param pagination A NSDictionary with pagination data, the best way to
create this dictionary is with the helper functions on `SPPagination`.
If `nil` the default pagination will be used as defined by the
[dribbble api](http://dribbble.com/api#pagination).
@param runOnMainThread Specifies if the passed in block should be run on the main thread.
If UI elements are being updated in the block this should be `YES`.
@param block The block to be executed once the data has been retrieved.
An `NSArray` of `SPShot` objects and a `SPPagination` objects are passed to the block.
@see shotsForPlayerFollowing:withBlock:
@see SPPagination
@see SPShot
*/
+ (void)shotsForPlayerFollowing:(NSString *)username
withPagination:(NSDictionary *)pagination
runOnMainThread:(BOOL)runOnMainThread
withBlock:(void (^)(NSArray *shots, SPPagination *pagination))block;
/**
Retrieves shots liked by the player specified by _username_.
@param username The username of the player.
@param pagination A NSDictionary with pagination data, the best way to
create this dictionary is with the helper functions on `SPPagination`.
If `nil` the default pagination will be used as defined by the
[dribbble api](http://dribbble.com/api#pagination).
@param runOnMainThread Specifies if the passed in block should be run on the main thread.
If UI elements are being updated in the block this should be `YES`.
@param block The block to be executed once the data has been retrieved.
An `NSArray` of `SPShot` objects and a `SPPagination` objects are passed to the block.
@see shotsForPlayerLikes:withBlock:
@see SPPagination
@see SPShot
*/
+ (void)shotsForPlayerLikes:(NSString *)username
withPagination:(NSDictionary *)pagination
runOnMainThread:(BOOL)runOnMainThread
withBlock:(void (^)(NSArray *shots, SPPagination *pagination))block;
@end