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

Commit

Permalink
Release v1.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
lgarbo committed Jun 23, 2021
1 parent 0a2dcd8 commit 0d22b68
Show file tree
Hide file tree
Showing 17 changed files with 260 additions and 166 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.1.3"
s.version = "1.1.4"
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
12 changes: 10 additions & 2 deletions Glassfy.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
817A1CF6258CF63600D1BA10 /* GYAPIManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 817A1CF4258CF63600D1BA10 /* GYAPIManager.m */; };
817A1CFF258CF7EE00D1BA10 /* GYStoreRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 817A1CFD258CF7EE00D1BA10 /* GYStoreRequest.h */; settings = {ATTRIBUTES = (Private, ); }; };
817A1D00258CF7EE00D1BA10 /* GYStoreRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 817A1CFE258CF7EE00D1BA10 /* GYStoreRequest.m */; };
817C95692678F79200DB4945 /* GYAPISkuResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 817C95682678F78400DB4945 /* GYAPISkuResponse.h */; settings = {ATTRIBUTES = (Private, ); }; };
817C956B2678F7D300DB4945 /* GYAPISkuResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = 817C956A2678F7D300DB4945 /* GYAPISkuResponse.m */; };
8191E86B26690C850077BDD7 /* GYUserProperties.h in Headers */ = {isa = PBXBuildFile; fileRef = 8191E86A26690C850077BDD7 /* GYUserProperties.h */; settings = {ATTRIBUTES = (Public, ); }; };
81951CD126443F65003901F1 /* Glassfy.h in Headers */ = {isa = PBXBuildFile; fileRef = 81951CD026443F65003901F1 /* Glassfy.h */; settings = {ATTRIBUTES = (Public, ); }; };
81951CD326443F82003901F1 /* GYTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 81951CD226443F82003901F1 /* GYTypes.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -136,6 +138,8 @@
817A1CF4258CF63600D1BA10 /* GYAPIManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GYAPIManager.m; sourceTree = "<group>"; };
817A1CFD258CF7EE00D1BA10 /* GYStoreRequest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GYStoreRequest.h; sourceTree = "<group>"; };
817A1CFE258CF7EE00D1BA10 /* GYStoreRequest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GYStoreRequest.m; sourceTree = "<group>"; };
817C95682678F78400DB4945 /* GYAPISkuResponse.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GYAPISkuResponse.h; sourceTree = "<group>"; };
817C956A2678F7D300DB4945 /* GYAPISkuResponse.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GYAPISkuResponse.m; sourceTree = "<group>"; };
8191E86A26690C850077BDD7 /* GYUserProperties.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GYUserProperties.h; path = Public/GYUserProperties.h; sourceTree = "<group>"; };
81951CD026443F65003901F1 /* Glassfy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Glassfy.h; path = Public/Glassfy.h; sourceTree = "<group>"; };
81951CD226443F82003901F1 /* GYTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GYTypes.h; path = Public/GYTypes.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -196,6 +200,8 @@
81C684642602633500223D3E /* GYAPISignatureResponse.m */,
816EF28B26611C5900513FB1 /* GYAPIPropertiesResponse.h */,
816EF28C26611C5900513FB1 /* GYAPIPropertiesResponse.m */,
817C95682678F78400DB4945 /* GYAPISkuResponse.h */,
817C956A2678F7D300DB4945 /* GYAPISkuResponse.m */,
8138BAE225925705005CB44E /* Categories */,
);
name = Data;
Expand Down Expand Up @@ -358,6 +364,7 @@
81EFB54425A772D900706FCB /* GYAPIPermissionsResponse.h in Headers */,
811F31AD26317EC200777020 /* GYPermissions+Private.h in Headers */,
816830B8258B6EE400565968 /* GYManager.h in Headers */,
817C95692678F79200DB4945 /* GYAPISkuResponse.h in Headers */,
8104537725909F320015A728 /* GYAPIInitResponse.h in Headers */,
8138BAA825924CDF005CB44E /* SKPaymentDiscount+GYEncode.h in Headers */,
8191E86B26690C850077BDD7 /* GYUserProperties.h in Headers */,
Expand Down Expand Up @@ -484,6 +491,7 @@
81C684662602633500223D3E /* GYAPISignatureResponse.m in Sources */,
817A1C3E258CC9EA00D1BA10 /* GYOffering.m in Sources */,
8161C42825948D82009CA563 /* GYError.m in Sources */,
817C956B2678F7D300DB4945 /* GYAPISkuResponse.m in Sources */,
817A1CE8258CF46600D1BA10 /* GYCacheManager.m in Sources */,
810F6FB425E50CFF00D3009E /* GYOfferings.m in Sources */,
817A1D00258CF7EE00D1BA10 /* GYStoreRequest.m in Sources */,
Expand Down Expand Up @@ -660,7 +668,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.1.3;
MARKETING_VERSION = 1.1.4;
PRODUCT_BUNDLE_IDENTIFIER = net.glassfy.sdk;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -687,7 +695,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.1.3;
MARKETING_VERSION = 1.1.4;
PRODUCT_BUNDLE_IDENTIFIER = net.glassfy.sdk;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
5 changes: 4 additions & 1 deletion Source/GYAPIManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#import "GYAPIOfferingsResponse.h"
#import "GYAPISignatureResponse.h"
#import "GYAPIPropertiesResponse.h"
#import "GYAPISkuResponse.h"
@class SKProduct;
@class SKPaymentTransaction;
@class GYCacheManager;
Expand All @@ -21,6 +22,7 @@ typedef void(^GYGetPermissionsCompletion)(GYAPIPermissionsResponse* _Nullable, N
typedef void(^GYGetOfferingsCompletion)(GYAPIOfferingsResponse* _Nullable, NSError* _Nullable);
typedef void(^GYGetSignatureCompletion)(GYAPISignatureResponse* _Nullable, NSError* _Nullable);
typedef void(^GYGetPropertiesCompletion)(GYAPIPropertiesResponse* _Nullable, NSError* _Nullable);
typedef void(^GYGetSkuCompletion)(GYAPISkuResponse* _Nullable, NSError* _Nullable);
typedef void(^GYBaseCompletion)(GYAPIBaseResponse* _Nullable, NSError* _Nullable);

typedef GYBaseCompletion GYProductsCompletion;
Expand All @@ -38,14 +40,15 @@ NS_ASSUME_NONNULL_BEGIN

- (void)getInitWithInfoWithCompletion:(GYGetInitCompletion _Nullable)block;

- (void)getSku:(NSString *)skuid withCompletion:(GYGetSkuCompletion _Nullable)block;
- (void)getOfferingsWithCompletion:(GYGetOfferingsCompletion _Nullable)block;
- (void)getPermissionsWithCompletion:(GYGetPermissionsCompletion _Nullable)block;

- (void)postProducts:(NSArray<SKProduct *> *)products
completion:(GYProductsCompletion _Nullable)block;

- (void)postReceipt:(NSData *)receipt
product:(SKProduct *_Nullable)product
sku:(GYSku *_Nullable)sku
transaction:(SKPaymentTransaction *_Nullable)transaction
completion:(GYGetPermissionsCompletion _Nullable)block;

Expand Down
28 changes: 22 additions & 6 deletions Source/GYAPIManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@
//

#import <CommonCrypto/CommonDigest.h>
#import "GYSysInfo.h"
#import "GYAPIManager.h"
#import "Glassfy+Private.h"
#import "SKProduct+GYEncode.h"
#import "GYUserProperties+Private.h"
#import "GYSku+Private.h"
#import "SKPaymentTransaction+GYEncode.h"
#import "SKProduct+GYEncode.h"
#import "GYSysInfo.h"
#import "GYAPIManager.h"
#import "GYError.h"
#import "GYLogger.h"
#import "GYCacheManager.h"
#import "GYUtils.h"
#import "GYUserProperties+Private.h"

#define BASE_URL @"https://api.glassfy.net/v0"

Expand Down Expand Up @@ -80,6 +81,18 @@ - (void)getInitWithInfoWithCompletion:(GYGetInitCompletion)block
[self callApiWithRequest:req response:GYAPIInitResponse.class completion:block];
}

- (void)getSku:(NSString *)skuid withCompletion:(GYGetSkuCompletion)block
{
NSURLComponents *url = [self baseURL];
url.path = [url.path stringByAppendingPathComponent:@"sku"];
NSMutableArray<NSURLQueryItem*> *queryItems = [(url.queryItems ?: @[]) mutableCopy];
[queryItems addObject:[NSURLQueryItem queryItemWithName:@"identifier" value:skuid]];
url.queryItems = queryItems;

NSURLRequest *req = [self authorizedRequestWithComponents:url];
[self callApiWithRequest:req response:GYAPISkuResponse.class completion:block];
}

- (void)getOfferingsWithCompletion:(GYGetOfferingsCompletion)block
{
NSURLComponents *url = [self baseURL];
Expand Down Expand Up @@ -155,13 +168,16 @@ - (void)postProducts:(NSArray<SKProduct *> *)products completion:(GYBaseCompleti
}

- (void)postReceipt:(NSData *)receipt
product:(SKProduct *)product
sku:(GYSku *)sku
transaction:(SKPaymentTransaction *)transaction
completion:(GYGetPermissionsCompletion)block
{
NSMutableDictionary *bodyEncoded = [NSMutableDictionary dictionary];
NSDictionary *skuinfo = [sku encodedObject];
if ([skuinfo isKindOfClass:NSDictionary.class]) {
[bodyEncoded addEntriesFromDictionary:skuinfo];
}
bodyEncoded[@"receiptdata"] = [receipt base64EncodedStringWithOptions:kNilOptions];
bodyEncoded[@"productinfo"] = [product encodedObject];
bodyEncoded[@"transactioninfo"] = [transaction encodedObject];

NSError *err;
Expand Down
18 changes: 18 additions & 0 deletions Source/GYAPISkuResponse.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// GYAPISkuResponse.h
// Glassfy
//
// Created by Luca Garbolino on 15/06/21.
//

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

NS_ASSUME_NONNULL_BEGIN

@interface GYAPISkuResponse : GYAPIBaseResponse
@property(nonatomic, strong) GYSku *sku;
@end

NS_ASSUME_NONNULL_END
35 changes: 35 additions & 0 deletions Source/GYAPISkuResponse.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// GYAPISkuResponse.m
// Glassfy
//
// Created by Luca Garbolino on 15/06/21.
//

#import "GYAPISkuResponse.h"
#import "GYSku+Private.h"
#import "GYError.h"

@implementation GYAPISkuResponse

- (instancetype _Nullable)initWithObject:(NSDictionary *)obj error:(NSError **)error
{
self = [super initWithObject:obj error:error];
if (error && *error) {
return self;
}

if (self) {
NSDictionary *sku = obj[@"sku"];
if ([sku isKindOfClass:NSDictionary.class] && sku.allKeys.count > 0) {
self.sku = [[GYSku alloc] initWithObject:sku error:error];
}
else {
if (error) {
*error = [GYError serverError:GYErrorCodeSkuIDNotFound description:@"Sku not found"];
}
}
}
return self;
}

@end
7 changes: 3 additions & 4 deletions Source/GYManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@ NS_ASSUME_NONNULL_BEGIN

- (void)permissionsWithCompletion:(GYPermissionsCompletion)block;
- (void)offeringsWithCompletion:(GYOfferingsCompletion)block;
- (void)skuWithIdentifier:(NSString *)skuid completion:(GYSkuBlock)block;

- (void)purchaseSku:(GYSku *)sku completion:(GYPaymentTransactionBlock)block;
- (void)purchase:(NSString *)productId completion:(GYPaymentTransactionBlock)block;
- (void)purchaseProduct:(SKProduct *)product completion:(GYPaymentTransactionBlock)block;
- (void)purchaseProduct:(SKProduct *)product withDiscount:(SKProductDiscount *_Nullable)discount completion:(GYPaymentTransactionBlock)block API_AVAILABLE(ios(12.2));
- (void)purchaseSku:(GYSku *)sku withDiscount:(SKProductDiscount *_Nullable)discount completion:(GYPaymentTransactionBlock)block API_AVAILABLE(ios(12.2));

- (void)addUserProperty:(GYUserPropertyType)property value:(id)obj completion:(GYUserPropertiesCompletion)block;
- (void)setUserProperty:(GYUserPropertyType)property value:(id)obj completion:(GYUserPropertiesCompletion)block;
- (void)getUserProperties:(GYUserPropertiesCompletion)block;

- (void)restorePurchasesWithCompletion:(GYPermissionsCompletion)block;
Expand Down
Loading

0 comments on commit 0d22b68

Please sign in to comment.