Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Commit

Permalink
Release v1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lgarbo committed Jun 6, 2023
1 parent 5395dff commit fff9209
Show file tree
Hide file tree
Showing 25 changed files with 1,209 additions and 439 deletions.
2 changes: 1 addition & 1 deletion Glassfy.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Glassfy"
s.version = "1.3.8"
s.version = "1.4.0"
s.summary = "Subscription and in-app-purchase service."
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.source = { :git => "https://github.com/glassfy/ios-sdk.git", :tag => s.version.to_s }
Expand Down
90 changes: 63 additions & 27 deletions Glassfy.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@
objects = {

/* Begin PBXBuildFile section */
6478E62C2A0B6D8E006FE38E /* GYPaywall+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 6478E62A2A0B6D8E006FE38E /* GYPaywall+Private.h */; settings = {ATTRIBUTES = (Private, ); }; };
6478E62D2A0B6D8E006FE38E /* GYPaywall.m in Sources */ = {isa = PBXBuildFile; fileRef = 6478E62B2A0B6D8E006FE38E /* GYPaywall.m */; };
6478E62F2A0B6DDD006FE38E /* GYPaywall.h in Headers */ = {isa = PBXBuildFile; fileRef = 6478E62E2A0B6DDD006FE38E /* GYPaywall.h */; settings = {ATTRIBUTES = (Public, ); }; };
6478E63A2A0B80AB006FE38E /* GYPaywallHtmlJsonProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 6478E6342A0B80AB006FE38E /* GYPaywallHtmlJsonProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
6478E63B2A0B80AB006FE38E /* GYPaywallJsonProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = 6478E6352A0B80AB006FE38E /* GYPaywallJsonProvider.m */; };
6478E63C2A0B80AB006FE38E /* GYPaywallNoCodeJsonProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = 6478E6362A0B80AB006FE38E /* GYPaywallNoCodeJsonProvider.m */; };
6478E63D2A0B80AB006FE38E /* GYPaywallNoCodeJsonProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 6478E6372A0B80AB006FE38E /* GYPaywallNoCodeJsonProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
6478E63E2A0B80AB006FE38E /* GYPaywallHtmlJsonProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = 6478E6382A0B80AB006FE38E /* GYPaywallHtmlJsonProvider.m */; };
6478E63F2A0B80AB006FE38E /* GYPaywallJsonProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 6478E6392A0B80AB006FE38E /* GYPaywallJsonProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
81010F292590C1AB00B07DE4 /* GYAPIOfferingsResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 81010F252590C1AB00B07DE4 /* GYAPIOfferingsResponse.h */; settings = {ATTRIBUTES = (Private, ); }; };
81010F2A2590C1AB00B07DE4 /* GYAPIOfferingsResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = 81010F262590C1AB00B07DE4 /* GYAPIOfferingsResponse.m */; };
8104537725909F320015A728 /* GYAPIInitResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 8104537525909F320015A728 /* GYAPIInitResponse.h */; settings = {ATTRIBUTES = (Private, ); }; };
Expand All @@ -32,7 +41,7 @@
812C842229B5F51F00A3F736 /* GYPurchasesHistory.m in Sources */ = {isa = PBXBuildFile; fileRef = 812C842029B5F51F00A3F736 /* GYPurchasesHistory.m */; };
812C842429B5F55200A3F736 /* GYPurchasesHistory.h in Headers */ = {isa = PBXBuildFile; fileRef = 812C842329B5F55200A3F736 /* GYPurchasesHistory.h */; settings = {ATTRIBUTES = (Public, ); }; };
812C842629B5F58800A3F736 /* GYPurchasesHistory+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 812C842529B5F58800A3F736 /* GYPurchasesHistory+Private.h */; settings = {ATTRIBUTES = (Private, ); }; };
812C842929B5FAD400A3F736 /* GYAPIPurchaseHistoryResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 812C842729B5FAD400A3F736 /* GYAPIPurchaseHistoryResponse.h */; };
812C842929B5FAD400A3F736 /* GYAPIPurchaseHistoryResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 812C842729B5FAD400A3F736 /* GYAPIPurchaseHistoryResponse.h */; settings = {ATTRIBUTES = (Private, ); }; };
812C842A29B5FAD400A3F736 /* GYAPIPurchaseHistoryResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = 812C842829B5FAD400A3F736 /* GYAPIPurchaseHistoryResponse.m */; };
812C842D29B5FD9200A3F736 /* GYPurchaseHistory+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 812C842B29B5FD9200A3F736 /* GYPurchaseHistory+Private.h */; settings = {ATTRIBUTES = (Private, ); }; };
812C842E29B5FD9200A3F736 /* GYPurchaseHistory.m in Sources */ = {isa = PBXBuildFile; fileRef = 812C842C29B5FD9200A3F736 /* GYPurchaseHistory.m */; };
Expand Down Expand Up @@ -130,6 +139,15 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
6478E62A2A0B6D8E006FE38E /* GYPaywall+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "GYPaywall+Private.h"; sourceTree = "<group>"; };
6478E62B2A0B6D8E006FE38E /* GYPaywall.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GYPaywall.m; sourceTree = "<group>"; };
6478E62E2A0B6DDD006FE38E /* GYPaywall.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GYPaywall.h; path = Public/GYPaywall.h; sourceTree = "<group>"; };
6478E6342A0B80AB006FE38E /* GYPaywallHtmlJsonProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GYPaywallHtmlJsonProvider.h; sourceTree = "<group>"; };
6478E6352A0B80AB006FE38E /* GYPaywallJsonProvider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GYPaywallJsonProvider.m; sourceTree = "<group>"; };
6478E6362A0B80AB006FE38E /* GYPaywallNoCodeJsonProvider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GYPaywallNoCodeJsonProvider.m; sourceTree = "<group>"; };
6478E6372A0B80AB006FE38E /* GYPaywallNoCodeJsonProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GYPaywallNoCodeJsonProvider.h; sourceTree = "<group>"; };
6478E6382A0B80AB006FE38E /* GYPaywallHtmlJsonProvider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GYPaywallHtmlJsonProvider.m; sourceTree = "<group>"; };
6478E6392A0B80AB006FE38E /* GYPaywallJsonProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GYPaywallJsonProvider.h; sourceTree = "<group>"; };
81010F252590C1AB00B07DE4 /* GYAPIOfferingsResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GYAPIOfferingsResponse.h; sourceTree = "<group>"; };
81010F262590C1AB00B07DE4 /* GYAPIOfferingsResponse.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GYAPIOfferingsResponse.m; sourceTree = "<group>"; };
8104537525909F320015A728 /* GYAPIInitResponse.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GYAPIInitResponse.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -334,50 +352,52 @@
816830A1258B6D9C00565968 /* Source */ = {
isa = PBXGroup;
children = (
816830B3258B6EA100565968 /* Core */,
8104537B25909F380015A728 /* Data */,
81951CD026443F65003901F1 /* Glassfy.h */,
817A1C75258CE0A200D1BA10 /* Glassfy.m */,
8166504128DB6B2700E5B985 /* GYAccountableSku.h */,
8166503C28DB671200E5B985 /* GYAccountableSku.m */,
81E5B8952912C88400D134E9 /* GYAttributionItem.h */,
81E5B8932912C87600D134E9 /* GYAttributionItem.m */,
81951CD526443F94003901F1 /* GYOfferings.h */,
810F6FB225E50CFF00D3009E /* GYOfferings.m */,
812767FD29CCA7F800498889 /* GYInitializeOptions.h */,
812767FA29CC990200498889 /* GYInitializeOptions.m */,
81951CD426443F94003901F1 /* GYOffering.h */,
817A1C3C258CC9EA00D1BA10 /* GYOffering.m */,
811DB39E280975C900021880 /* GYSkuBase.h */,
811DB39B280972C900021880 /* GYSkuBase.m */,
81951CD926443FAA003901F1 /* GYSku.h */,
817A1C48258CCA7000D1BA10 /* GYSku.m */,
8166504128DB6B2700E5B985 /* GYAccountableSku.h */,
8166503C28DB671200E5B985 /* GYAccountableSku.m */,
81D18D7A2812AF6200C68558 /* GYSkuPaddle.h */,
81D18D782812AF5700C68558 /* GYSkuPaddle.m */,
81951CD826443FAA003901F1 /* GYTransaction.h */,
8161C4972594DD2F009CA563 /* GYTransaction.m */,
81951CD526443F94003901F1 /* GYOfferings.h */,
810F6FB225E50CFF00D3009E /* GYOfferings.m */,
6478E62E2A0B6DDD006FE38E /* GYPaywall.h */,
6478E62B2A0B6D8E006FE38E /* GYPaywall.m */,
818880BB27171DA900128A10 /* GYPaywallViewController.h */,
818880B827171D7A00128A10 /* GYPaywallViewController.m */,
81951CDD26443FB8003901F1 /* GYPermission.h */,
81EFB54925A772F200706FCB /* GYPermission.m */,
81951CDC26443FB8003901F1 /* GYPermissions.h */,
81C2816125E3F58C0048189D /* GYPermissions.m */,
8191E86A26690C850077BDD7 /* GYUserProperties.h */,
816EF2882661161200513FB1 /* GYUserProperties.m */,
818880BB27171DA900128A10 /* GYPaywallViewController.h */,
818880B827171D7A00128A10 /* GYPaywallViewController.m */,
81FCCE8527C3CE0A00DF3D1A /* GYPurchaseDelegate.h */,
812C842F29B5FDA600A3F736 /* GYPurchaseHistory.h */,
812C842C29B5FD9200A3F736 /* GYPurchaseHistory.m */,
812C842329B5F55200A3F736 /* GYPurchasesHistory.h */,
812C842029B5F51F00A3F736 /* GYPurchasesHistory.m */,
812767FD29CCA7F800498889 /* GYInitializeOptions.h */,
812767FA29CC990200498889 /* GYInitializeOptions.m */,
81C9AF5D2805BB82004A36A1 /* GYStoresInfo.h */,
81C9AF5A2805BB5B004A36A1 /* GYStoresInfo.m */,
81951CD926443FAA003901F1 /* GYSku.h */,
817A1C48258CCA7000D1BA10 /* GYSku.m */,
811DB39E280975C900021880 /* GYSkuBase.h */,
811DB39B280972C900021880 /* GYSkuBase.m */,
81D18D7A2812AF6200C68558 /* GYSkuPaddle.h */,
81D18D782812AF5700C68558 /* GYSkuPaddle.m */,
81C9AF5E2805BB82004A36A1 /* GYStoreInfo.h */,
81C9AF562805BAB1004A36A1 /* GYStoreInfo.m */,
81C9AF652805C386004A36A1 /* GYStoreInfoPaddle.h */,
81C9AF622805C36B004A36A1 /* GYStoreInfoPaddle.m */,
81C9AF5D2805BB82004A36A1 /* GYStoresInfo.h */,
81C9AF5A2805BB5B004A36A1 /* GYStoresInfo.m */,
81951CD826443FAA003901F1 /* GYTransaction.h */,
8161C4972594DD2F009CA563 /* GYTransaction.m */,
81951CD226443F82003901F1 /* GYTypes.h */,
81FCCE8527C3CE0A00DF3D1A /* GYPurchaseDelegate.h */,
816830B3258B6EA100565968 /* Core */,
8104537B25909F380015A728 /* Data */,
817A1CC7258CE9C700D1BA10 /* Utils */,
8191E86A26690C850077BDD7 /* GYUserProperties.h */,
816EF2882661161200513FB1 /* GYUserProperties.m */,
816830C0258B6F2800565968 /* Supporting Files */,
817A1CC7258CE9C700D1BA10 /* Utils */,
);
path = Source;
sourceTree = "<group>";
Expand All @@ -391,13 +411,20 @@
817A1CF4258CF63600D1BA10 /* GYAPIManager.m */,
817A1CE5258CF46600D1BA10 /* GYCacheManager.h */,
817A1CE6258CF46600D1BA10 /* GYCacheManager.m */,
6478E6392A0B80AB006FE38E /* GYPaywallJsonProvider.h */,
6478E6352A0B80AB006FE38E /* GYPaywallJsonProvider.m */,
6478E6342A0B80AB006FE38E /* GYPaywallHtmlJsonProvider.h */,
6478E6382A0B80AB006FE38E /* GYPaywallHtmlJsonProvider.m */,
6478E6372A0B80AB006FE38E /* GYPaywallNoCodeJsonProvider.h */,
6478E6362A0B80AB006FE38E /* GYPaywallNoCodeJsonProvider.m */,
817A1CFD258CF7EE00D1BA10 /* GYStoreRequest.h */,
817A1CFE258CF7EE00D1BA10 /* GYStoreRequest.m */,
811F322D2631CC6C00777020 /* Glassfy+Private.h */,
8166503F28DB689200E5B985 /* GYAccountableSku+Private.h */,
81E5B8972912CE9700D134E9 /* GYAttributionItem+Private.h */,
81359D7025B1DBFC009B1A4B /* GYOffering+Private.h */,
810F6FB725E50D2000D3009E /* GYOfferings+Private.h */,
6478E62A2A0B6D8E006FE38E /* GYPaywall+Private.h */,
818880BD27171E1F00128A10 /* GYPaywallViewController+Private.h */,
81EFB55025A7736B00706FCB /* GYPermission+Private.h */,
81C2816825E3F6AC0048189D /* GYPermissions+Private.h */,
Expand Down Expand Up @@ -475,6 +502,7 @@
817A1CE7258CF46600D1BA10 /* GYCacheManager.h in Headers */,
81E1DC3225933FC7003B5EBD /* SKPayment+GYEncode.h in Headers */,
818880BC27171DA900128A10 /* GYPaywallViewController.h in Headers */,
6478E63D2A0B80AB006FE38E /* GYPaywallNoCodeJsonProvider.h in Headers */,
8138BA9B25924C8F005CB44E /* SKProductDiscount+GYEncode.h in Headers */,
81C684652602633500223D3E /* GYAPISignatureResponse.h in Headers */,
812C842629B5F58800A3F736 /* GYPurchasesHistory+Private.h in Headers */,
Expand All @@ -488,6 +516,7 @@
816EF29026611CF700513FB1 /* GYUserProperties+Private.h in Headers */,
81C9AF602805BB82004A36A1 /* GYStoreInfo.h in Headers */,
811F31B226317EC800777020 /* GYOffering+Private.h in Headers */,
6478E63F2A0B80AB006FE38E /* GYPaywallJsonProvider.h in Headers */,
81951CD326443F82003901F1 /* GYTypes.h in Headers */,
81951CD126443F65003901F1 /* Glassfy.h in Headers */,
816EF28D26611C5900513FB1 /* GYAPIPropertiesResponse.h in Headers */,
Expand All @@ -514,8 +543,11 @@
812C843029B5FDA600A3F736 /* GYPurchaseHistory.h in Headers */,
81951CDA26443FAA003901F1 /* GYTransaction.h in Headers */,
81951CDE26443FB8003901F1 /* GYPermissions.h in Headers */,
6478E63A2A0B80AB006FE38E /* GYPaywallHtmlJsonProvider.h in Headers */,
6478E62C2A0B6D8E006FE38E /* GYPaywall+Private.h in Headers */,
812C842D29B5FD9200A3F736 /* GYPurchaseHistory+Private.h in Headers */,
8138BAA225924CB4005CB44E /* SKPaymentTransaction+GYEncode.h in Headers */,
6478E62F2A0B6DDD006FE38E /* GYPaywall.h in Headers */,
8138BA5F25923E78005CB44E /* GYCodableProtocol.h in Headers */,
818880BE27171E1F00128A10 /* GYPaywallViewController+Private.h in Headers */,
81C9AF662805C386004A36A1 /* GYStoreInfoPaddle.h in Headers */,
Expand Down Expand Up @@ -621,6 +653,7 @@
buildActionMask = 2147483647;
files = (
8104538D2590A15E0015A728 /* GYAPIBaseResponse.m in Sources */,
6478E62D2A0B6D8E006FE38E /* GYPaywall.m in Sources */,
8104537825909F320015A728 /* GYAPIInitResponse.m in Sources */,
81C2816325E3F58C0048189D /* GYPermissions.m in Sources */,
812C842229B5F51F00A3F736 /* GYPurchasesHistory.m in Sources */,
Expand All @@ -635,6 +668,7 @@
81D18D792812AF5700C68558 /* GYSkuPaddle.m in Sources */,
8161C4992594DD2F009CA563 /* GYTransaction.m in Sources */,
8138BA8A25924B42005CB44E /* SKProduct+GYEncode.m in Sources */,
6478E63C2A0B80AB006FE38E /* GYPaywallNoCodeJsonProvider.m in Sources */,
817A1C4A258CCA7000D1BA10 /* GYSku.m in Sources */,
812C842E29B5FD9200A3F736 /* GYPurchaseHistory.m in Sources */,
811DB39D280972C900021880 /* GYSkuBase.m in Sources */,
Expand All @@ -649,6 +683,7 @@
817A1CE8258CF46600D1BA10 /* GYCacheManager.m in Sources */,
810F6FB425E50CFF00D3009E /* GYOfferings.m in Sources */,
817A1D00258CF7EE00D1BA10 /* GYStoreRequest.m in Sources */,
6478E63B2A0B80AB006FE38E /* GYPaywallJsonProvider.m in Sources */,
8166503E28DB671200E5B985 /* GYAccountableSku.m in Sources */,
818880BA27171D7A00128A10 /* GYPaywallViewController.m in Sources */,
818880B62717153A00128A10 /* GYAPIPaywallResponse.m in Sources */,
Expand All @@ -664,6 +699,7 @@
816EF28E26611C5900513FB1 /* GYAPIPropertiesResponse.m in Sources */,
81EFB54B25A772F200706FCB /* GYPermission.m in Sources */,
81010F2A2590C1AB00B07DE4 /* GYAPIOfferingsResponse.m in Sources */,
6478E63E2A0B80AB006FE38E /* GYPaywallHtmlJsonProvider.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -829,7 +865,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.3.8;
MARKETING_VERSION = 1.4.0;
PRODUCT_BUNDLE_IDENTIFIER = net.glassfy.sdk;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -857,7 +893,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.3.8;
MARKETING_VERSION = 1.4.0;
PRODUCT_BUNDLE_IDENTIFIER = net.glassfy.sdk;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Our SDK can be easly integrated through Cocoapods or Swift Package Manager
#### Integrate using Cocoapods
Add the pod to your Podfile:

```pod 'Glassfy', '~> 1.3.8'```
```pod 'Glassfy', '~> 1.4.0'```

Then, run the following command:

Expand Down
2 changes: 1 addition & 1 deletion Source/GYAPIManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ - (void)getPropertiesWithCompletion:(GYGetPropertiesCompletion _Nullable)block

- (void)getPaywall:(NSString *)paywallId locale:(NSString *)locale completion:(GYGetPaywallCompletion _Nullable)block
{
NSURLComponents *url = [self baseURLV0];
NSURLComponents *url = [self baseURLV1];
url.path = [url.path stringByAppendingPathComponent:@"paywall"];

NSMutableArray<NSURLQueryItem*> *queryItems = [(url.queryItems ?: @[]) mutableCopy];
Expand Down
12 changes: 10 additions & 2 deletions Source/GYAPIPaywallResponse.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,28 @@
// GYAPIPaywallResponse.h
// Glassfy
//
// Created by Luca Garbolino on 13/10/21.
// Created by Luca Garbolino on 27/06/22.
//

#import <Foundation/Foundation.h>
#import "GYAPIBaseResponse.h"
#import "GYTypes.h"
#import "GYInternalType.h"
@class GYSku;

NS_ASSUME_NONNULL_BEGIN

@interface GYAPIPaywallResponse: GYAPIBaseResponse
@property(nonatomic, strong) NSString *content;

@property(nullable, nonatomic, strong) NSURL *contentUrl;
@property(nullable, nonatomic, strong) NSString *version;
@property(nonatomic, assign) GYPaywallType type;
@property(nullable, nonatomic, strong) NSString *locale;
@property(nullable, nonatomic, strong) NSString *pwid;
@property(nonatomic, strong) NSArray<GYSku*> *skus;

+ (GYPaywallType)paywallTypeFromString:(NSString*)typeStr;

@end

NS_ASSUME_NONNULL_END
41 changes: 33 additions & 8 deletions Source/GYAPIPaywallResponse.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,29 @@
// GYAPIPaywallResponse.m
// Glassfy
//
// Created by Luca Garbolino on 13/10/21.
// Created by Luca Garbolino on 27/06/22.
//

#import "GYAPIPaywallResponse.h"
#import "GYAPIBaseResponse.h"
#import "GYError.h"
#import "GYSku+Private.h"
#import "GYError.h"

#define PAYWALL_TYPE_HTML @"html"
#define PAYWALL_TYPE_NOCODE @"nocode"

@implementation GYAPIPaywallResponse

+ (GYPaywallType)paywallTypeFromString:(NSString*)typeStr
{
GYPaywallType type = GYPaywallTypeNoCode;
if ([typeStr isKindOfClass:NSString.class]) {
if ([PAYWALL_TYPE_HTML isEqualToString:typeStr]) {
type = GYPaywallTypeHTML;
}
}
return type;
}

- (instancetype _Nullable)initWithObject:(NSDictionary *)obj error:(NSError **)error
{
self = [super initWithObject:obj error:error];
Expand All @@ -21,9 +35,17 @@ - (instancetype _Nullable)initWithObject:(NSDictionary *)obj error:(NSError **)e
if (self) {
NSDictionary *paywall = obj[@"paywall"];
if ([paywall isKindOfClass:NSDictionary.class]) {
NSString *content = paywall[@"content"];
if ([content isKindOfClass:NSString.class]) {
self.content = content;

NSString *version = paywall[@"version"];
if ([version isKindOfClass:NSString.class]) {
self.version = version;
}

self.type = [GYAPIPaywallResponse paywallTypeFromString:paywall[@"type"]];

NSString *contentUrl = paywall[@"url"];
if ([contentUrl isKindOfClass:NSString.class]) {
self.contentUrl = [NSURL URLWithString:contentUrl];
}

NSString *locale = paywall[@"locale"];
Expand Down Expand Up @@ -56,10 +78,13 @@ - (instancetype _Nullable)initWithObject:(NSDictionary *)obj error:(NSError **)e


// verify
if (!self.content) {
*error = [GYError serverError:GYErrorCodeUnknow description:@"Unexpected data format"];
if (!self.contentUrl) {
if (error) {
*error = [GYError serverError:GYErrorCodeUnknow description:@"Unexpected data format"];
}
}
}
return self;
}

@end
22 changes: 22 additions & 0 deletions Source/GYInternalType.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// GYInternalType.h
// Glassfy
//
// Created by Luca Garbolino on 25/10/22.
//

#ifndef GYInternalType_h
#define GYInternalType_h

typedef NS_ENUM(NSUInteger, GYSubplatform) {
GYSubplatformUnknown = 0,
GYSubplatformiOS = 1,
GYSubplatformCatalyst = 2,
GYSubplatformTV = 3,
GYSubplatformWatch = 4,
GYSubplatformOSx = 5,
GYSubplatformDrive = 6,
GYSubplatformSimulator = 7
};

#endif /* GYInternalType_h */
Loading

0 comments on commit fff9209

Please sign in to comment.