VOVoucherMedia
@interface VOVoucherMedia : NSObject <NSCoding>
VOVoucherMedia
is the model for all Media items inside of a VOVoucher
.
It represents all of the different Media types:
Image - Any kind of photo (eg. png, jpg).
Animation - Any kind of animated photo (eg. gif).
Sound - Any kind of sound (eg. mp3).
Youtube - A youtube video.
Video - Any kind of video (eg. m4a).
Note - Any kind of text.
-
The type of
VOVoucherMedia
.Declaration
Objective-C
@property (readonly, nonatomic) VOVoucherMediaType mediaType;
Swift
var mediaType: VOVoucherMediaType { get }
-
The id of the
VOVoucherMedia
. This id is unique for allVOVoucherMedia
s and will be set by the Vouchr Server.Declaration
Objective-C
@property (assign, readwrite, nonatomic) long mediaId;
Swift
var mediaId: Int { get set }
-
The title of the
VOVoucherMedia
.Declaration
Objective-C
@property (readonly, strong, nonatomic, nullable) NSString *title;
Swift
var title: String? { get }
-
The url to get the media item.
Declaration
Objective-C
@property (readwrite, strong, nonatomic, nullable) NSString *mediaUrlString;
Swift
var mediaUrlString: String? { get set }
-
The url to show a thumbnail image.
Declaration
Objective-C
@property (readwrite, strong, nonatomic, nullable) NSString *thumbnailUrlString;
Swift
var thumbnailUrlString: String? { get set }
-
The url for a web view or external browser to open.
Declaration
Objective-C
@property (readwrite, strong, nonatomic, nullable) NSString *externalUrlString;
Swift
var externalUrlString: String? { get set }
-
The local file url for the media.
Declaration
Objective-C
@property (assign, readwrite, nonatomic, nullable) NSURL *mediaLocalUrl;
Swift
var mediaLocalUrl: URL? { get set }
-
Returns the mediaLocalUrl if it exists otherwise the mediaUrlString as a URL.
Declaration
Objective-C
@property (readonly, nonatomic, nullable) NSURL *mediaLocalOrRemoteUrl;
Swift
var mediaLocalOrRemoteUrl: URL? { get }
-
Initializer to create a
VOVoucherMedia
from an NSDictionary. The Initializer will try to be smart about returning the proper subclass ofVOVoucherMedia
(eg.VOImageMedia
when it is a photo).Declaration
Objective-C
- (nonnull instancetype)initWithDictionary:(nonnull NSDictionary *)dictionary;
Swift
init(dictionary: [AnyHashable : Any])
Parameters
dictionary
- the dictionary representation of a
VOVoucherMedia
.Return Value
Instance of
VOVoucherMedia
. -
Initializer to create a
VOVoucherMedia
from properties. The Initializer will try to be smart about returning the proper subclass ofVOVoucherMedia
(eg.VOImageMedia
when it is a photo).Declaration
Objective-C
- (nonnull instancetype)initWithType:(VOVoucherMediaType)mediaType title:(nullable NSString *)title mediaUrlString:(nullable NSString *)mediaUrlString thumbnailUrlString:(nullable NSString *)thumbnailUrlString;
Swift
init(type mediaType: VOVoucherMediaType, title: String?, mediaUrlString: String?, thumbnailUrlString: String?)
Parameters
mediaType
- the type of
VOVoucherMedia
.title
- the title of the
VOVoucherMedia
.mediaUrlString
- the url to the
VOVoucherMedia
item.thumbnailUrlString
- the thumbnail of the
VOVoucherMedia
item.Return Value
Instance of
VOVoucherMedia
. -
Creates an array of
VOVoucherMedia
s from an Array of NSDictionary versions ofVOVoucherMedia
s. Internally callsinitWithDictionary:
for eachVOVoucherMedia
.Declaration
Objective-C
+ (nonnull NSArray<VOVoucherMedia *> *)voucherMediasFromArray: (nonnull NSArray *)mediasJson;
Swift
class func voucherMedias(from mediasJson: [Any]) -> [VOVoucherMedia]
Parameters
mediasJson
- Array of NSDictionary
VOVoucherMedia
s.Return Value
Array of
VOVoucherMedia
objects. -
Static Initializer to create a
VOVoucherMedia
from an NSDictionary. The Initializer will try to be smart about returning the proper subclass ofVOVoucherMedia
(eg.VOImageMedia
when it is a photo).Declaration
Objective-C
+ (nonnull instancetype)voucherMediaWithDictionary: (nonnull NSDictionary *)dictionary;
Parameters
dictionary
- the dictionary representation of a
VOVoucherMedia
.Return Value
Instance of
VOVoucherMedia
. -
Static Initializer to create a
VOVoucherMedia
from properties. The Initializer will try to be smart about returning the proper subclass ofVOVoucherMedia
(eg.VOImageMedia
when it is a photo).Declaration
Objective-C
+ (nonnull instancetype)voucherMediaWithType:(VOVoucherMediaType)mediaType title:(nullable NSString *)title mediaUrlString:(nullable NSString *)mediaUrlString thumbnailUrlString: (nullable NSString *)thumbnailUrlString;
Parameters
mediaType
- the type of
VOVoucherMedia
.title
- the title of the
VOVoucherMedia
.mediaUrlString
- the url to the
VOVoucherMedia
item.thumbnailUrlString
- the thumbnail of the
VOVoucherMedia
item.Return Value
Instance of
VOVoucherMedia
. -
Converts a
VOVoucherMedia
to an NSDictionary that can be used for sending to the server.Declaration
Objective-C
- (nonnull NSDictionary *)dictionaryRepresentationWithoutMediaData;
Swift
func dictionaryRepresentationWithoutMediaData() -> [AnyHashable : Any]
Return Value
dictionary - Dictionary form of a
VOVoucherMedia
without the media data. -
Converts a
VOVoucherMedia
to an NSDictionary that can be used for caching.Declaration
Objective-C
- (nonnull NSDictionary *)dictionaryRepresentation;
Swift
func dictionaryRepresentation() -> [AnyHashable : Any]
Return Value
dictionary - Dictionary form of a
VOVoucherMedia
. -
Helper to convert a
VOVoucherMediaType
to a string valueDeclaration
Objective-C
+ (nonnull NSString *)mediaStringFromMediaType:(VOVoucherMediaType)mediaType;
Swift
class func mediaString(from mediaType: VOVoucherMediaType) -> String
Parameters
mediaType
- the mediaType that is being converted
Return Value
string form of a mediaType.
-
Updates all properties of this instance of
VOVoucherMedia
with the properties of media.Declaration
Objective-C
- (void)updateWithMedia:(nonnull VOVoucherMedia *)media;
Swift
func update(with media: VOVoucherMedia)
Parameters
media
- the properties that should be set on this
VOVoucherMedia
. -
Updates the type of this instance of
VOVoucherMedia
with specifiedVOVoucherMediaType
.Declaration
Objective-C
- (void)updateMediaType:(VOVoucherMediaType)type;
Swift
func updateMediaType(_ type: VOVoucherMediaType)
Parameters
type
- the type that should be set on this
VOVoucherMedia
. -
Indicates whether the
VOVoucherMedia
has been uploaded to theVOVoucher
server.Declaration
Objective-C
- (BOOL)hasBeenUploadedToServer;
Swift
func hasBeenUploadedToServer() -> Bool