-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
354 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// Copyright (c) SRG SSR. All rights reserved. | ||
// | ||
// License information is available from the LICENSE file. | ||
// | ||
|
||
#import "SRGModel.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
/** | ||
* Broadcast information. | ||
*/ | ||
@interface SRGBroadcastInformation : SRGModel | ||
|
||
/** | ||
* An information message. | ||
*/ | ||
@property (nonatomic, readonly, copy) NSString *message; | ||
|
||
/** | ||
* The date at which the information has been made available. | ||
*/ | ||
@property (nonatomic, readonly) NSDate *startDate; | ||
|
||
/** | ||
* The date at which the information will be removed. | ||
*/ | ||
@property (nonatomic, readonly) NSDate *endDate; | ||
|
||
/** | ||
* A URL to an associated web page. | ||
*/ | ||
@property (nonatomic, readonly, nullable) NSURL *URL; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// | ||
// Copyright (c) SRG SSR. All rights reserved. | ||
// | ||
// License information is available from the LICENSE file. | ||
// | ||
|
||
#import "SRGBroadcastInformation.h" | ||
|
||
#import "SRGJSONTransformers.h" | ||
|
||
#import <libextobjc/libextobjc.h> | ||
|
||
@interface SRGBroadcastInformation () | ||
|
||
@property (nonatomic, copy) NSString *message; | ||
@property (nonatomic) NSDate *startDate; | ||
@property (nonatomic) NSDate *endDate; | ||
@property (nonatomic, nullable) NSURL *URL; | ||
|
||
@end | ||
|
||
@implementation SRGBroadcastInformation | ||
|
||
#pragma mark MTLJSONSerializing protocol | ||
|
||
+ (NSDictionary *)JSONKeyPathsByPropertyKey | ||
{ | ||
static NSDictionary *s_mapping; | ||
static dispatch_once_t s_onceToken; | ||
dispatch_once(&s_onceToken, ^{ | ||
s_mapping = @{ @keypath(SRGBroadcastInformation.new, message) : @"hintText", | ||
@keypath(SRGBroadcastInformation.new, startDate) : @"startDate", | ||
@keypath(SRGBroadcastInformation.new, endDate) : @"endDate", | ||
@keypath(SRGBroadcastInformation.new, URL) : @"url" }; | ||
}); | ||
return s_mapping; | ||
} | ||
|
||
#pragma mark Transformers | ||
|
||
+ (NSValueTransformer *)startDateJSONTransformer | ||
{ | ||
return SRGISO8601DateJSONTransformer(); | ||
} | ||
|
||
+ (NSValueTransformer *)endDateJSONTransformer | ||
{ | ||
return SRGISO8601DateJSONTransformer(); | ||
} | ||
|
||
+ (NSValueTransformer *)URLJSONTransformer | ||
{ | ||
return [NSValueTransformer valueTransformerForName:MTLURLValueTransformerName]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// Copyright (c) SRG SSR. All rights reserved. | ||
// | ||
// License information is available from the LICENSE file. | ||
// | ||
|
||
#import "SRGModel.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
/** | ||
* A service status message. | ||
*/ | ||
@interface SRGServiceMessage : SRGModel | ||
|
||
/** | ||
* The message unique identifier. | ||
*/ | ||
@property (nonatomic, readonly, copy) NSString *uid; | ||
|
||
/** | ||
* The message text. | ||
*/ | ||
@property (nonatomic, readonly, copy) NSString *text; | ||
|
||
/** | ||
* The message date. | ||
*/ | ||
@property (nonatomic, readonly) NSDate *date; | ||
|
||
/** | ||
* A URL where additional information can be accessed. | ||
*/ | ||
@property (nonatomic, readonly, nullable) NSURL *URL; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// | ||
// Copyright (c) SRG SSR. All rights reserved. | ||
// | ||
// License information is available from the LICENSE file. | ||
// | ||
|
||
#import "SRGServiceMessage.h" | ||
|
||
#import "SRGJSONTransformers.h" | ||
|
||
#import <libextobjc/libextobjc.h> | ||
|
||
@interface SRGServiceMessage () | ||
|
||
@property (nonatomic, copy) NSString *uid; | ||
@property (nonatomic, copy) NSString *text; | ||
@property (nonatomic) NSDate *date; | ||
@property (nonatomic) NSURL *URL; | ||
|
||
@end | ||
|
||
@implementation SRGServiceMessage | ||
|
||
#pragma mark MTLJSONSerializing protocol | ||
|
||
+ (NSDictionary *)JSONKeyPathsByPropertyKey | ||
{ | ||
static NSDictionary *s_mapping; | ||
static dispatch_once_t s_onceToken; | ||
dispatch_once(&s_onceToken, ^{ | ||
s_mapping = @{ @keypath(SRGServiceMessage.new, uid) : @"id", | ||
@keypath(SRGServiceMessage.new, text) : @"text", | ||
@keypath(SRGServiceMessage.new, date) : @"modifyDate", | ||
@keypath(SRGServiceMessage.new, URL) : @"url" }; | ||
}); | ||
return s_mapping; | ||
} | ||
|
||
#pragma mark Transformers | ||
|
||
+ (NSValueTransformer *)dateJSONTransformer | ||
{ | ||
return SRGISO8601DateJSONTransformer(); | ||
} | ||
|
||
+ (NSValueTransformer *)URLJSONTransformer | ||
{ | ||
return [NSValueTransformer valueTransformerForName:MTLURLValueTransformerName]; | ||
} | ||
|
||
#pragma mark Equality | ||
|
||
- (BOOL)isEqual:(id)object | ||
{ | ||
if (! [object isKindOfClass:self.class]) { | ||
return NO; | ||
} | ||
|
||
SRGServiceMessage *otherServiceMessage = object; | ||
return [self.uid isEqualToString:otherServiceMessage.uid]; | ||
} | ||
|
||
- (NSUInteger)hash | ||
{ | ||
return self.uid.hash; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.