OlapicMediaHandler Class Reference
| Inherits from | OlapicHandler : NSObject |
| Declared in | OlapicMediaHandler.h |
Tasks
Utils
Get a list of media
UI
Report
Streams
Source Types
Link/Unlink Media to Streams
Statuses
Class Methods
getKeyForImageSize:
Get string key for an image size
+ (NSString *)getKeyForImageSize:(OlapicMediaImageSize)sizeParameters
- size
Return Value
The string value
Availability
v1.0
Discussion
The returned key will be used to call the get
method of a OlapicMediaEntity, so if you send
OlapicMediaImageSizeMobile, you’ll get “images/mobile”
Declared In
OlapicMediaHandler.hInstance Methods
getCurationSourceTypes:onFailure:
Get a list of availables source types
- (void)getCurationSourceTypes:(void ( ^ ) ( NSArray *response ))success onFailure:(void ( ^ ) ( NSError *error ))failureParameters
- success
A callback block for when the source types are successfully retrieved
- failure
A callback block for when the SDK can’t get the source types
Discussion
Example:
[[[OlapicSDK sharedOlapicSDK] getSourceTypes:^(NSArray *response) {
NSLog(@"%@", response);
} onFailure:^(NSError *error) {
NSLog(@"%@", error);
}];
Declared In
OlapicMediaHandler.hgetMediaFromURL:onSuccess:onFailure:
Get a media from an API URL
- (void)getMediaFromURL:(NSString *)URL onSuccess:(void ( ^ ) ( NSDictionary *response ))success onFailure:(void ( ^ ) ( NSError *error ))failureParameters
- URL
The API URL
- success
A callback block for when the media is successfully retrieved. The response is a dictionary with the following keys:
- links: An
NSDictionarywith the API URLs to paginate the media objects - media: An
NSArraywith the media objects
- links: An
- failure
A callback block for when the SDK can’t get the media
Availability
v1.0
Discussion
Example:
[[[OlapicSDK sharedOlapicSDK] media] getMediaFromURL:@"//photorankapi-a.akamaihd.net/customers/{ID}/media/recent/"
onSuccess:^(NSDictionary *response){
NSArray *media = [response valueForKey:@"media"]
for(int i = 0; i < [media count]; i++){
OlapicMediaEntity *mediaObject = [media objectAtIndex:i];
NSLog(@"Media %@",mediaObject);
}
}
onFailure:^(NSError *error){
NSLog(@"Error: %@",error.description);
}];
Declared In
OlapicMediaHandler.hgetMediaFromURL:onSuccess:onFailure:parameters:
Get a media from an API URL, with extra parameters
- (void)getMediaFromURL:(NSString *)URL onSuccess:(void ( ^ ) ( NSDictionary *response ))success onFailure:(void ( ^ ) ( NSError *error ))failure parameters:(NSDictionary *)parametersParameters
- URL
The API URL
- success
A callback block for when the media is successfully retrieved
- failure
A callback block for when the SDK can’t get the media
- parameters
A list of parameters for the request, like ‘count’ or ‘limit’
Availability
v1.0
Discussion
Example:
NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
[parameters setValue:@"10" forKey:@"count"];
[[[OlapicSDK sharedOlapicSDK] media] getMediaFromURL:@"//photorankapi-a.akamaihd.net/customers/{ID}/media/recent/"
onSuccess:^(NSDictionary *response){
NSArray *media = [response valueForKey:@"media"]
for(int i = 0; i < [media count]; i++){
OlapicMediaEntity *mediaObject = [media objectAtIndex:i];
NSLog(@"Media %@",mediaObject);
}
}
onFailure:^(NSError *error){
NSLog(@"Error: %@",error.description);
} parameters:parameters];
Declared In
OlapicMediaHandler.hgetRelatedStreamsFromMedia:onSuccess:onFailure:
Get a list of streams related to a media
- (void)getRelatedStreamsFromMedia:(OlapicMediaEntity *)media onSuccess:(void ( ^ ) ( NSDictionary *streams ))success onFailure:(void ( ^ ) ( NSError *error ))failureParameters
- media
The media object
- success
A callback block for when the streams are successfully retrieved
- failure
A callback block for when the SDK can’t get the streams
Availability
v1.0
Discussion
Example:
[[[OlapicSDK sharedOlapicSDK] media] getRelatedStreamsFromMedia:mediaEntityObject
onSuccess:^(NSArray *streams){
for(int i = 0; i < [streams count]; i++){
OlapicStreamEntity *streamObject = [streams objectAtIndex:i];
NSLog(@"Stream %@",streamObject);
}
}
onFailure:^(NSError *error){
NSLog(@"Error: %@",error.description);
}];
Declared In
OlapicMediaHandler.hlinkMedia:toStreams:onSuccess:onFailure:
Link a media object to a list of streams
- (void)linkMedia:(OlapicCurationMediaEntity *)media toStreams:(NSArray *)streams onSuccess:(void ( ^ ) ( NSArray *result ))success onFailure:(void ( ^ ) ( NSError *error ))failureParameters
- media
The media object
- streams
The streams to link
- success
A callback block for when the connection is successfully done. The result is a list with the requested links, its information and if the operations were completed
- failure
A callback block in case the operation fails
Availability
v1.0
Declared In
OlapicMediaHandler.hloadImageWithSize:fromMedia:onSuccess:onFailure:
Load an image with a specific size
- (void)loadImageWithSize:(OlapicMediaImageSize)size fromMedia:(OlapicMediaEntity *)media onSuccess:(void ( ^ ) ( NSData *mediaData , UIImage *mediaImage ))success onFailure:(void ( ^ ) ( NSError *error ))failureParameters
- size
The image size
- media
The media object from where the image will be loaded
- success
A callback block for when the image is successfully retrieved
- failure
A callback block for when the SDK can’t get the image
Availability
v1.0
Discussion
Example:
[[[OlapicSDK sharedOlapicSDK] media] loadImageWithSize:OlapicMediaImageSizeOriginal
fromMedia:mediaEntityObject
onSuccess:^(NSData *mediaData,UIImage *mediaImage){
UIImageView *imageView = [[UIImageView alloc] initWithImage:mediaImage];
[self.view addSubview:imageView];
}
onFailure:^(NSError *error){
NSLog(@"Error: %@",error.description);
}];
Declared In
OlapicMediaHandler.hreportMedia:metadata:onSuccess:onFailure:
Report a media
- (void)reportMedia:(OlapicMediaEntity *)media metadata:(NSDictionary *)metadata onSuccess:(void ( ^ ) ( void ))success onFailure:(void ( ^ ) ( NSError *error ))failureParameters
- media
The media object to report
- metadata
A list with the report information
- email: The email of the user who wants to report the media
- reason: The reason why the media will be reported
- success
A callback block for when the media is successfully reported
- failure
A callback block for when the SDK can’t report the media
Availability
v1.0
Discussion
Example:
NSMutableDictionary *metadata = [[NSMutableDictionary alloc] init];
[metadata setValue:@"example@olapic.com" forKey:@"email"];
[metadata setValue:@"I find this photo offensive!" forKey:@"reason"];
[[[OlapicSDK sharedOlapicSDK] media] reportMedia:mediaEntityObject
metadata:metadata
onSuccess:^(void){
NSLog(@"Successfully reported");
}
onFailure:^(NSError *error){
NSLog(@"Error: %@",error.description);
}];
Declared In
OlapicMediaHandler.hsetStatus:forMedia:onSuccess:onFailure:
Add or change the status of a list of media objects
- (void)setStatus:(OlapicMediaStatus *)status forMedia:(NSArray *)media onSuccess:(void ( ^ ) ( NSArray *result ))success onFailure:(void ( ^ ) ( NSError *error ))failureParameters
- status
The new status
- media
The list of media
- success
A callback block for when the status is successfully changed
- failure
A callback block in case the operation fails
Availability
v1.0
Declared In
OlapicMediaHandler.hunlinkMedia:toStreams:onSuccess:onFailure:
Unlink a media object from a list of streams
- (void)unlinkMedia:(OlapicCurationMediaEntity *)media toStreams:(NSArray *)streams onSuccess:(void ( ^ ) ( NSArray *result ))success onFailure:(void ( ^ ) ( NSError *error ))failureParameters
- media
The media object
- streams
The streams to unlink
- success
A callback block for when the connection is successfully done. The result is a list with the requested unlinks, its information and if the operations were completed
- failure
A callback block in case the operation fails
Availability
v1.0
Declared In
OlapicMediaHandler.h