Skip to content

Commit

Permalink
Merge pull request #164 from tumblr/bsu/AddConsentProvider
Browse files Browse the repository at this point in the history
Add ConsentProvider to TMApiError
  • Loading branch information
benjamin-su authored Aug 11, 2020
2 parents 851590a + 84beab2 commit 941a816
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 41 deletions.
5 changes: 5 additions & 0 deletions Classes/Errors/TMAPIError.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
*/
@property (nonatomic, readonly) BOOL needsConsent;

/**
A string that describes the expected consent flow.
*/
@property (nonatomic, readonly, nullable) NSString *consentProvider;

/**
A specific property associated with some errors for the GUCE Consent flow.
*/
Expand Down
3 changes: 2 additions & 1 deletion Classes/Errors/TMAPIErrorFactory.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ - (nonnull instancetype)initWithErrors:(nonnull NSArray <NSDictionary *> *)error
id needsAge = error[@"gdpr_needs_age"];
id authToken = error[@"gdpr_auth_token"];
id minimumRequiredAge = error[@"gdpr_minimum_required_age"];
id consentProvider = error[@"consent_provider"];

/**
* Only accept these things if they are the right type :/
Expand All @@ -64,7 +65,7 @@ - (nonnull instancetype)initWithErrors:(nonnull NSArray <NSDictionary *> *)error
const NSInteger finalCodeValue = [code integerValue];
const NSInteger finalMinimumRequiredAgeValue = [minimumRequiredAge integerValue];

[APIErrors addObject:[[TMTopLevelAPIError alloc] initWithLogout:finalLogoutValue title:title detail:detail code:finalCodeValue needsConsent:finalNeedsConsentValue isConsentBlocking:finalIsConsentBockingValue needsAge:finalNeedsAgeValue minimumRequiredAge:finalMinimumRequiredAgeValue authToken:authToken]];
[APIErrors addObject:[[TMTopLevelAPIError alloc] initWithLogout:finalLogoutValue title:title detail:detail code:finalCodeValue needsConsent:finalNeedsConsentValue isConsentBlocking:finalIsConsentBockingValue needsAge:finalNeedsAgeValue minimumRequiredAge:finalMinimumRequiredAgeValue consentProvider:consentProvider authToken:authToken]];
}
}
return APIErrors;
Expand Down
1 change: 1 addition & 0 deletions Classes/Errors/TMLegacyAPIError.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ @implementation TMLegacyAPIError
@synthesize minimumRequiredAge = _minimumRequiredAge;
@synthesize isConsentBlocking = _isConsentBlocking;
@synthesize authToken = _authToken;
@synthesize consentProvider = _consentProvider;

- (nonnull instancetype)initWithTitle:(nonnull NSString *)title detail:(nonnull NSString *)detail {
NSParameterAssert(title);
Expand Down
2 changes: 1 addition & 1 deletion Classes/Errors/TMTopLevelAPIError.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ __attribute__((objc_subclassing_restricted))
*
* @return An initialized instance of @c TMTopLevelAPIError.
*/
- (nonnull instancetype)initWithLogout:(BOOL)logout title:(nonnull NSString *)title detail:(nonnull NSString *)detail code:(NSInteger)code needsConsent:(BOOL)needsConsent isConsentBlocking:(BOOL)isConsentBlocking needsAge:(BOOL)needsAge minimumRequiredAge:(NSInteger)minimumRequiredAge authToken:(NSString * _Nullable)authToken;
- (nonnull instancetype)initWithLogout:(BOOL)logout title:(nonnull NSString *)title detail:(nonnull NSString *)detail code:(NSInteger)code needsConsent:(BOOL)needsConsent isConsentBlocking:(BOOL)isConsentBlocking needsAge:(BOOL)needsAge minimumRequiredAge:(NSInteger)minimumRequiredAge consentProvider:(NSString * _Nullable)consentProvider authToken:(NSString * _Nullable)authToken;

@end
4 changes: 3 additions & 1 deletion Classes/Errors/TMTopLevelAPIError.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ @implementation TMTopLevelAPIError
@synthesize minimumRequiredAge = _minimumRequiredAge;
@synthesize isConsentBlocking = _isConsentBlocking;
@synthesize authToken = _authToken;
@synthesize consentProvider = _consentProvider;

- (nonnull instancetype)initWithLogout:(BOOL)logout title:(nonnull NSString *)title detail:(nonnull NSString *)detail code:(NSInteger)code needsConsent:(BOOL)needsConsent isConsentBlocking:(BOOL)isConsentBlocking needsAge:(BOOL)needsAge minimumRequiredAge:(NSInteger)minimumRequiredAge authToken:(NSString * _Nullable)authToken {
- (nonnull instancetype)initWithLogout:(BOOL)logout title:(nonnull NSString *)title detail:(nonnull NSString *)detail code:(NSInteger)code needsConsent:(BOOL)needsConsent isConsentBlocking:(BOOL)isConsentBlocking needsAge:(BOOL)needsAge minimumRequiredAge:(NSInteger)minimumRequiredAge consentProvider:(NSString *)consentProvider authToken:(NSString * _Nullable)authToken {
NSParameterAssert(title);
NSParameterAssert(detail);
self = [super init];
Expand All @@ -34,6 +35,7 @@ - (nonnull instancetype)initWithLogout:(BOOL)logout title:(nonnull NSString *)ti
_needsConsent = needsConsent;
_isConsentBlocking = isConsentBlocking;
_authToken = authToken;
_consentProvider = consentProvider;
}

return self;
Expand Down
40 changes: 4 additions & 36 deletions ExampleiOS/ExampleiOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,6 @@
B901B7271C3DC99B007691FA /* Frameworks */,
B901B7281C3DC99B007691FA /* Resources */,
204A77D2FEE83753023A02E7 /* [CP] Embed Pods Frameworks */,
15951C02DD9BA4726A6DFB51 /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand All @@ -340,7 +339,6 @@
B901B7401C3DC99B007691FA /* Frameworks */,
B901B7411C3DC99B007691FA /* Resources */,
FA77AE57BB0E92B244B8AD86 /* [CP] Embed Pods Frameworks */,
6BC2CF2A845D9AA7FF19F1BB /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -421,28 +419,13 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
15951C02DD9BA4726A6DFB51 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-ExampleiOS/Pods-ExampleiOS-resources.sh\"\n";
showEnvVarsInLog = 0;
};
204A77D2FEE83753023A02E7 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-ExampleiOS/Pods-ExampleiOS-frameworks.sh",
"${PODS_ROOT}/Target Support Files/Pods-ExampleiOS/Pods-ExampleiOS-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/TMTumblrSDK/TMTumblrSDK.framework",
);
name = "[CP] Embed Pods Frameworks";
Expand All @@ -451,7 +434,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-ExampleiOS/Pods-ExampleiOS-frameworks.sh\"\n";
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-ExampleiOS/Pods-ExampleiOS-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
35122AA6CEBF3302083F7076 /* [CP] Check Pods Manifest.lock */ = {
Expand All @@ -472,21 +455,6 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
6BC2CF2A845D9AA7FF19F1BB /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-ExampleiOSTests/Pods-ExampleiOSTests-resources.sh\"\n";
showEnvVarsInLog = 0;
};
E0F1E3731D0C9C45B8FF0037 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand All @@ -511,7 +479,7 @@
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-ExampleiOSTests/Pods-ExampleiOSTests-frameworks.sh",
"${PODS_ROOT}/Target Support Files/Pods-ExampleiOSTests/Pods-ExampleiOSTests-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/TMTumblrSDK/TMTumblrSDK.framework",
);
name = "[CP] Embed Pods Frameworks";
Expand All @@ -520,7 +488,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-ExampleiOSTests/Pods-ExampleiOSTests-frameworks.sh\"\n";
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-ExampleiOSTests/Pods-ExampleiOSTests-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
Expand Down
4 changes: 2 additions & 2 deletions TMTumblrSDK.podspec.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "TMTumblrSDK",
"version": "5.3.1",
"version": "5.3.2",
"summary": "An unopinionated and flexible library for easily integrating Tumblr data into your iOS or OS X application.",
"homepage": "https://github.com/tumblr/TMTumblrSDK",
"source": {
"git": "https://github.com/tumblr/TMTumblrSDK.git",
"tag": "5.3.1"
"tag": "5.3.2"
},
"license": {
"type": "Apache 2.0",
Expand Down

0 comments on commit 941a816

Please sign in to comment.