This repository has been archived by the owner on Aug 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
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
25 changed files
with
1,011 additions
and
32 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// | ||
// GYAPIPaywallResponse.h | ||
// Glassfy | ||
// | ||
// Created by Luca Garbolino on 13/10/21. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "GYAPIBaseResponse.h" | ||
@class GYSku; | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface GYAPIPaywallResponse: GYAPIBaseResponse | ||
@property(nonatomic, strong) NSString *content; | ||
@property(nullable, nonatomic, strong) NSString *locale; | ||
@property(nullable, nonatomic, strong) NSString *pwid; | ||
@property(nonatomic, strong) NSArray<GYSku*> *skus; | ||
@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,65 @@ | ||
// | ||
// GYAPIPaywallResponse.m | ||
// Glassfy | ||
// | ||
// Created by Luca Garbolino on 13/10/21. | ||
// | ||
|
||
#import "GYAPIPaywallResponse.h" | ||
#import "GYAPIBaseResponse.h" | ||
#import "GYError.h" | ||
#import "GYSku+Private.h" | ||
|
||
@implementation GYAPIPaywallResponse | ||
- (instancetype _Nullable)initWithObject:(NSDictionary *)obj error:(NSError **)error | ||
{ | ||
self = [super initWithObject:obj error:error]; | ||
if (error && *error) { | ||
return self; | ||
} | ||
|
||
if (self) { | ||
NSDictionary *paywall = obj[@"paywall"]; | ||
if ([paywall isKindOfClass:NSDictionary.class]) { | ||
NSString *content = paywall[@"content"]; | ||
if ([content isKindOfClass:NSString.class]) { | ||
self.content = content; | ||
} | ||
|
||
NSString *locale = paywall[@"locale"]; | ||
if ([locale isKindOfClass:NSString.class]) { | ||
self.locale = locale; | ||
} | ||
|
||
NSString *pwid = paywall[@"pwid"]; | ||
if ([pwid isKindOfClass:NSString.class]) { | ||
self.pwid = pwid; | ||
} | ||
} | ||
|
||
NSMutableArray *skus = [NSMutableArray array]; | ||
NSArray *skusJSON = obj[@"skus"]; | ||
if ([skusJSON isKindOfClass:NSArray.class]) { | ||
for (NSDictionary *skuJSON in skusJSON) { | ||
if (![skuJSON isKindOfClass:NSDictionary.class] || skuJSON.allKeys.count == 0) { | ||
continue; | ||
} | ||
|
||
//ToDo manage error | ||
GYSku *s = [[GYSku alloc] initWithObject:skuJSON error:error]; | ||
if (s) { | ||
[skus addObject:s]; | ||
} | ||
} | ||
} | ||
self.skus = skus; | ||
|
||
|
||
// verify | ||
if (!self.content) { | ||
*error = [GYError serverError:GYErrorCodeUnknow description:@"Unexpected data format"]; | ||
} | ||
} | ||
return self; | ||
} | ||
@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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// GYFormatter.h | ||
// Glassfy | ||
// | ||
// Created by Luca Garbolino on 27/10/21. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
API_AVAILABLE(ios(11.2), macos(10.13.2), watchos(6.2)) | ||
typedef NS_OPTIONS(NSUInteger, SKProductPeriodUnit); | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface GYFormatter : NSObject | ||
+ (NSString *)formatPrice:(NSNumber *)price locale:(NSLocale *)locale; | ||
+ (NSString *)formatPercentage:(NSNumber *)price locale:(NSLocale *)locale; | ||
|
||
+ (NSString *)formatPeriod:(NSInteger)perdiod unit:(SKProductPeriodUnit)unit locale:(NSLocale *)locale API_AVAILABLE(ios(11.2), macos(10.13.2), watchos(6.2)); | ||
+ (NSString *)formatUnit:(SKProductPeriodUnit)unit locale:(NSLocale *)locale API_AVAILABLE(ios(11.2), macos(10.13.2), watchos(6.2)); | ||
|
||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
Oops, something went wrong.