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

Commit

Permalink
Merge pull request #100 from contentful/deprecate-persistence
Browse files Browse the repository at this point in the history
tvOS support; drop persistence; drop CMA
  • Loading branch information
loudmouth authored Jul 30, 2018
2 parents fe163e7 + 8e23780 commit 3e6528a
Show file tree
Hide file tree
Showing 415 changed files with 1,339 additions and 29,246 deletions.
3 changes: 1 addition & 2 deletions .env
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
DELIVERY_SDK_VERSION=2.0.4
MANAGEMENT_SDK_VERSION=0.10.1
DELIVERY_SDK_VERSION=3.0.0

3 changes: 1 addition & 2 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export DELIVERY_SDK_VERSION=2.0.4
export MANAGEMENT_SDK_VERSION=0.10.1
export DELIVERY_SDK_VERSION=3.0.0
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

13 changes: 5 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,26 @@ language: objective-c
git:
depth: 50
submodules: false
osx_image: xcode8.3
osx_image: xcode9.3
rvm:
- 2.4.1
before_install:
- git submodule sync
- git submodule update --init --recursive
- bundle install
- bundle exec pod repo update --silent
install:
- bundle exec pod install
script:
- "./scripts/travis-build-test.sh"
- "./scripts/travis-lint.sh"
after_success:
- bundle exec pod lib lint ContentfulDeliveryAPI.podspec --allow-warnings
notifications:
slack:
- secure: pbLVGeA+577zmld+ie/1KUWxin8PFB+uXogz1zrVhEqnparjbHNMvFfaAGG1gbaAJC0skGksCe+LeBrhLargbLSgAT3HrObwDCIu7H8IjaYOEhpNTHCObrwRIyOeBVHHAhjgjeElM7hvptJjRMuERErcnL65EOlaIdm4ZqOg3/0=
env:
matrix:
- CONTENTFUL_SDK="CDA"
global:
- IOS_SDK=iphonesimulator10.3 IOS_VERSION=10.3.1 DEVICE_NAME='iPhone 6s'
- ARTIFACTS_S3_BUCKET=static.cdnorigin.contentful.com
- IOS_SDK=iphonesimulator IOS_VERSION=11.3 DEVICE_NAME='iPhone 6s'
- secure: n/hnbmOoeLt4g+Mzm6Nm/fnxwr7fFjfFTlNxEco7kk9oeNklj0vudOwbYtxL2AWuMNWX/tSHlUieKf4UGOiwzFeQmWyLdi0dkwSKRMNBNz2XQrlzjemZNf8V9+E6+JPeH8BVBKyscYgNevrp7R0Lx2h5mcDVogHm416yUiNzGOQ=
- secure: FAIgFb/XlYTHWXAE7dzl5KFAMmST39forxsfmJdysXdaIUXK1Y44PJnS4HQ0cRa79e+o+NSOJSHLGI+qboXNoDAHqaDGBqtC7QROjW7ed0ZQp0iyNeebSq8TQzuOwdrqEjh9SGK24bgbTgQx+i8brYRJA+N8igfNtVoTUXj7buI=
- secure: LyiQhHG89Zn0FdprFntjvT34DOcvFU/IITWhhowfgYrXGObUTEOyIyE3ve6fJpMm23B8/u1EUNxBVvqxevdGmA2RuoJiMMy+V/uFsBHmuOeJ8TeDYOgjyWJgsJt1bfDLpFwX2Ztu0smdMeuBpmsOA2I3FW0mDCx5tiAuScNidnE=
- secure: L0njJqmusJJZPCWwMUTvb1vMJP3r4rNpLgDcWW1XtdZyNHE/F4CFzbawX/ve2ApzMXRV69XBIGLmBfl3hW0XCwyHR9nCe3u8/MRSZxapSNuArSjodHrPrddUGtAsgjKfKw1DlzNGByg2LpXLnfEBLnJYcYCosza3TI52JNcEv3c=

14 changes: 9 additions & 5 deletions ContentfulDeliveryAPI.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,19 @@ Pod::Spec.new do |s|
'ContentfulDeliveryAPI/Resources/{CDAArray,CDAAsset,CDAContentType,CDAEntry,CDAError,CDASpace,CDAResource}.h',
'ContentfulDeliveryAPI/{CDAClient,CDAConfiguration,CDANullabilityStubs,CDARequest,CDAResponse,CDAField,CDASyncedSpace,ContentfulDeliveryAPI,CDAPersistenceManager,CDAPersistedAsset,CDAPersistedEntry,CDAPersistedSpace,CDALocalizablePersistedEntry,CDALocalizedPersistedEntry}.h'
]

s.ios.deployment_target = '8.0'
s.ios.source_files = 'ContentfulDeliveryAPI/UIKit/*.{h,m}'
# iOS specific
s.ios.deployment_target = '9.0'
s.ios.frameworks = 'UIKit', 'MapKit'
s.ios.public_header_files = 'ContentfulDeliveryAPI/UIKit/{CDAEntriesViewController,CDAFieldsViewController,UIImageView+CDAAsset,CDAMapViewController,CDAResourcesCollectionViewController,CDAResourcesViewController,CDAResourceCell}.h'

# macOS specific
s.osx.deployment_target = '10.12'

# tvOS specific
s.tvos.deployment_target = '9.0'
s.tvos.frameworks = 'UIKit', 'MapKit'


s.dependency 'AFNetworking', '~> 3.1.0'
s.dependency 'AFNetworking', '~> 3.2.1'
s.dependency 'ISO8601', '~> 0.6.0'
end

4 changes: 2 additions & 2 deletions ContentfulDeliveryAPI/CDAPersistenceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ NS_ASSUME_NONNULL_BEGIN
* @param success Completion handler called when the synchronization finished successfully.
* @param failure Error handler called when any problem occured during the synchronization.
*/
-(void)performSynchronizationWithSuccess:(void (^)())success
-(void)performSynchronizationWithSuccess:(void (^)(void))success
failure:(CDARequestFailureBlock)failure;

/** @name Defining Classes for Persistent Resources */
Expand Down Expand Up @@ -266,7 +266,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @param block A block to be performed asynchronously
*/
-(void)performBlock:(void (^)())block;
-(void)performBlock:(void (^)(void))block;

/**
* Save all changes of the object model to the persistent store.
Expand Down
10 changes: 5 additions & 5 deletions ContentfulDeliveryAPI/CDAPersistenceManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ -(void)handleEntry:(CDAEntry*)entry {
}
}

-(void)handleResponseArray:(CDAArray*)array withSuccess:(void (^)())success {
-(void)handleResponseArray:(CDAArray*)array withSuccess:(void (^)(void))success {
for (CDAEntry* entry in array.items) {
[self handleEntry:entry];

Expand Down Expand Up @@ -267,11 +267,11 @@ -(NSDictionary *)relationshipMappingForEntriesOfContentTypeWithIdentifier:(NSStr
return [relationshipMapping copy];
}

-(void)performBlock:(void (^)())block {
-(void)performBlock:(void (^)(void))block {
block();
}

-(void)performInitalSynchronizationForQueryWithSuccess:(void (^)())success
-(void)performInitalSynchronizationForQueryWithSuccess:(void (^)(void))success
failure:(CDARequestFailureBlock)failure {
NSDate* syncTimestamp = [self roundedCurrentDate];

Expand All @@ -285,7 +285,7 @@ -(void)performInitalSynchronizationForQueryWithSuccess:(void (^)())success
} failure:failure];
}

-(void)performSubsequentSynchronizationWithSuccess:(void (^)())success
-(void)performSubsequentSynchronizationWithSuccess:(void (^)(void))success
failure:(CDARequestFailureBlock)failure {
NSDate* syncTimestamp = [self roundedCurrentDate];
NSMutableDictionary* query = [self.query mutableCopy];
Expand Down Expand Up @@ -318,7 +318,7 @@ -(void)performSubsequentSynchronizationWithSuccess:(void (^)())success
} failure:failure];
}

-(void)performSynchronizationWithSuccess:(void (^)())success
-(void)performSynchronizationWithSuccess:(void (^)(void))success
failure:(CDARequestFailureBlock)failure {
NSAssert(self.classesForEntries.count > 0, @"At least one Entry class should be defined.");
NSParameterAssert(self.classForAssets);
Expand Down
17 changes: 5 additions & 12 deletions ContentfulDeliveryAPI/CDARequestOperationManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@
//

@import Darwin.TargetConditionals;

#if TARGET_OS_IPHONE
#import <AFNetworking/AFNetworkActivityIndicatorManager.h>
#endif

@import ObjectiveC.runtime;

#import "CDAConfiguration.h"
Expand Down Expand Up @@ -189,19 +184,14 @@ -(instancetype)initWithSpaceKey:(NSString *)spaceKey

self = [super initWithBaseURL:[NSURL URLWithString:urlString]];
if (self) {
self.requestSerializer = [[CDARequestSerializer alloc] initWithAccessToken:accessToken
isCMARequest:isCMARequest];
self.requestSerializer = [[CDARequestSerializer alloc] initWithAccessToken:accessToken];
self.responseSerializer = [[CDAResponseSerializer alloc] initWithClient:client];
self.rateLimiting = configuration.rateLimiting;

self.dateFormatter = [NSDateFormatter new];
NSLocale *posixLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
[self.dateFormatter setLocale:posixLocale];
[self.dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZ"];

#if TARGET_OS_IPHONE
[AFNetworkActivityIndicatorManager sharedManager].enabled = YES;
#endif
}
return self;
}
Expand Down Expand Up @@ -274,7 +264,10 @@ -(NSURLSessionTask*)sessionTaskWithRequest:(NSURLRequest*)request
success:(CDAObjectFetchedBlock)success
failure:(CDARequestFailureBlock)failure {

NSURLSessionTask* task = [self dataTaskWithRequest:request completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
NSURLSessionTask* task = [self dataTaskWithRequest:request
uploadProgress:nil
downloadProgress:nil
completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
NSAssert(!response || [response isKindOfClass:NSHTTPURLResponse.class], @"Invalid response.");
NSHTTPURLResponse* httpResponse = (NSHTTPURLResponse*)response;

Expand Down
4 changes: 1 addition & 3 deletions ContentfulDeliveryAPI/CDARequestSerializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,5 @@

@property (nonatomic) NSString* userAgent;

-(instancetype)initWithAccessToken:(NSString*)accessToken
isCMARequest:(BOOL)isCMARequest;

-(instancetype)initWithAccessToken:(NSString*)accessToken;
@end
16 changes: 5 additions & 11 deletions ContentfulDeliveryAPI/CDARequestSerializer.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,28 @@

@implementation CDARequestSerializer

-(instancetype)initWithAccessToken:(NSString*)accessToken
isCMARequest:(BOOL)isCMARequest {
-(instancetype)initWithAccessToken:(NSString*)accessToken {
NSParameterAssert(accessToken);

self = [super init];
if (self) {
[self setValue:[@"Bearer " stringByAppendingString:accessToken] forHTTPHeaderField:@"Authorization"];

NSString *userAgentHeaderString = [self userAgentHeaderString:isCMARequest];
NSString *userAgentHeaderString = [self userAgentHeaderString];
[self setValue:userAgentHeaderString forHTTPHeaderField:@"X-Contentful-User-Agent"];
}
return self;
}

- (NSString *)userAgentHeaderString:(BOOL)isCMARequest {
- (NSString *)userAgentHeaderString {
NSMutableString *userAgentString = [[NSMutableString alloc] initWithString:@""];

NSString *appVersionString = [self appVersionString];
if (appVersionString != nil) {
[userAgentString appendString:[NSString stringWithFormat:@"app %@; ", appVersionString]];
}

[userAgentString appendString:[NSString stringWithFormat:@"sdk %@;", [self sdkVersionString:isCMARequest]]];
[userAgentString appendString:[NSString stringWithFormat:@"sdk %@;", [self sdkVersionString]]];
[userAgentString appendString:[NSString stringWithFormat:@" platform %@;", [self platformVersionString]]];

NSString *operatingSystemVersionString = [self operatingSystemVersionString];
Expand All @@ -60,16 +59,11 @@ - (NSString *)platformVersionString {
return @"Objective-C";
}

- (NSString *)sdkVersionString:(BOOL)isCMARequest {
- (NSString *)sdkVersionString {

NSString *sdkVersion = DELIVERY_SDK_VERSION;
NSString *sdkVersionString = [NSString stringWithFormat:@"contentful.objc/%@", sdkVersion];

if (isCMARequest) {
sdkVersion = MANAGEMENT_SDK_VERSION;
sdkVersionString = [NSString stringWithFormat:@"contentful-management.objc/%@", sdkVersion];
}

return sdkVersionString;
}

Expand Down
2 changes: 1 addition & 1 deletion ContentfulDeliveryAPI/CDASyncedSpace.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ NS_ASSUME_NONNULL_BEGIN
* @param success A block which is called upon the successful synchronization of the Space.
* @param failure A block which is called if any errors occur during the synchronization process.
*/
-(void)performSynchronizationWithSuccess:(void (^)())success failure:(CDARequestFailureBlock __nullable)failure;
-(void)performSynchronizationWithSuccess:(void (^)(void))success failure:(CDARequestFailureBlock __nullable)failure;

/** @name Persisting Synchronized Spaces */

Expand Down
10 changes: 5 additions & 5 deletions ContentfulDeliveryAPI/CDASyncedSpace.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ -(NSArray *)entries {
}

-(void)handleSynchronizationResponseWithArray:(CDAArray*)array
success:(void (^)())success
success:(void (^)(void))success
failure:(CDARequestFailureBlock)failure {
NSMutableDictionary* newAssets = [@{} mutableCopy];
NSMutableDictionary* newEntries = [@{} mutableCopy];
Expand Down Expand Up @@ -200,7 +200,7 @@ -(instancetype)initWithAssets:(NSArray *)assets entries:(NSArray *)entries {
return self;
}

-(void)performSynchronizationWithSuccess:(void (^)())success
-(void)performSynchronizationWithSuccess:(void (^)(void))success
failure:(CDARequestFailureBlock)failure {
NSParameterAssert(self.client);

Expand Down Expand Up @@ -233,7 +233,7 @@ -(void)performSynchronizationWithSuccess:(void (^)())success
}

-(void)resolveLinksInArray:(CDAArray*)array
success:(void (^)())success
success:(void (^)(void))success
failure:(CDARequestFailureBlock)failure {
NSMutableArray* entriesInQuery = [@[] mutableCopy];
NSMutableArray* unresolvedAssets = [@[] mutableCopy];
Expand Down Expand Up @@ -277,8 +277,8 @@ -(void)resolveLinksInArray:(CDAArray*)array

-(void)resolveLinksInEntries:(NSArray*)entries
usingAssets:(NSArray*)assets
unresolvedEntryIds:(NSArray*)unresolvedEntryIds
success:(void (^)())success
unresolvedEntryIds:(NSArray*)unresolvedEntryIds
success:(void (^)(void))success
failure:(CDARequestFailureBlock)failure {
if (assets.count == 0 && unresolvedEntryIds.count == 0) {
success();
Expand Down
2 changes: 1 addition & 1 deletion ContentfulDeliveryAPI/CDAUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

@class CDAResource;

NSString* CDACacheDirectory();
NSString* CDACacheDirectory(void);
NSString* CDACacheFileNameForQuery(CDAClient* client, CDAResourceType resourceType, NSDictionary* query);
NSString* CDACacheFileNameForResource(CDAResource* resource);
NSArray* CDAClassGetSubclasses(Class parentClass);
Expand Down
10 changes: 0 additions & 10 deletions ContentfulDeliveryAPI/ContentfulDeliveryAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,3 @@
#import "CDAResponse.h"
#import "CDASpace.h"
#import "CDASyncedSpace.h"

#if TARGET_OS_IPHONE
#import "CDAEntriesViewController.h"
#import "CDAFieldsViewController.h"
#import "CDAMapViewController.h"
#import "CDAResourceCell.h"
#import "CDAResourcesCollectionViewController.h"
#import "CDAResourcesViewController.h"
#import "UIImageView+CDAAsset.h"
#endif
18 changes: 0 additions & 18 deletions ContentfulDeliveryAPI/Resources/CDAAsset+Private.h

This file was deleted.

25 changes: 0 additions & 25 deletions ContentfulDeliveryAPI/Resources/CDAAsset.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
#import "CDAEntry.h"
#import "CDANullabilityStubs.h"

#import "CDAPersistedAsset.h"

/** Pass this constant as image quality to not modify the quality. */
extern const CGFloat CDAImageQualityOriginal;

Expand Down Expand Up @@ -159,27 +157,4 @@ typedef NS_ENUM(NSInteger, CDAFitType) {
*/
+(NSData* __nullable)cachedDataForAsset:(CDAAsset* __nonnull)asset;

/**
* Access previously cached data for an Asset.
*
* @param persistedAsset The Asset whose cached data should be accessed.
* @param client The client to use for Contentful requests.
*
* @return Cached data or `nil` if none was found.
*/
+(NSData* __nullable)cachedDataForPersistedAsset:(id<CDAPersistedAsset> __nonnull)persistedAsset client:(CDAClient* __nonnull)client;

/**
* Cache the data of an Asset to disk.
*
* @param persistedAsset The Asset whose cached data should be cached.
* @param client The client to use for Contentful requests.
* @param forceOverwrite If `NO` and file already exists, nothing will be done.
* @param handler This block will be called after persisting the asset.
*/
+(void)cachePersistedAsset:(id<CDAPersistedAsset> __nonnull)persistedAsset
client:(CDAClient* __nonnull)client
forcingOverwrite:(BOOL)forceOverwrite
completionHandler:(void (^ __nonnull)(BOOL success))handler;

@end
Loading

0 comments on commit 3e6528a

Please sign in to comment.