Inherits from OlapicHandler : NSObject
Declared in OlapicMediaHandler.h

Overview

The object in charge of the media’s common functionalities

Class Methods

getKeyForImageSize:

Get string key for an image size

+ (NSString *)getKeyForImageSize:(OlapicMediaImageSize)size

Parameters

size

OlapicMediaImageSize

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.h

Instance Methods

getCurationSourceTypes:onFailure:

Get a list of availables source types

- (void)getCurationSourceTypes:(void ( ^ ) ( NSArray *response ))success onFailure:(void ( ^ ) ( NSError *error ))failure

Parameters

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.h

getMediaFromURL:onSuccess:onFailure:

Get a media from an API URL

- (void)getMediaFromURL:(NSString *)URL onSuccess:(void ( ^ ) ( NSDictionary *response ))success onFailure:(void ( ^ ) ( NSError *error ))failure

Parameters

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 NSDictionary with the API URLs to paginate the media objects
  • media: An NSArray with the media objects
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.h

getMediaFromURL: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 *)parameters

Parameters

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.h

getRelatedStreamsFromMedia:onSuccess:onFailure:

Get a list of streams related to a media

- (void)getRelatedStreamsFromMedia:(OlapicMediaEntity *)media onSuccess:(void ( ^ ) ( NSDictionary *streams ))success onFailure:(void ( ^ ) ( NSError *error ))failure

Parameters

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.h

linkMedia: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 ))failure

Parameters

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.h

loadImageWithSize: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 ))failure

Parameters

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.h

reportMedia:metadata:onSuccess:onFailure:

Report a media

- (void)reportMedia:(OlapicMediaEntity *)media metadata:(NSDictionary *)metadata onSuccess:(void ( ^ ) ( void ))success onFailure:(void ( ^ ) ( NSError *error ))failure

Parameters

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.h

setStatus: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 ))failure

Parameters

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.h

unlinkMedia: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 ))failure

Parameters

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