<commit_before>//
//  CDAClient.h
//  ContentfulSDK
//
//  Created by <NAME> on 04/03/14.
//
//

#import <Foundation/Foundation.h>

@class CDAArray;
@class CDAAsset;
@class CDAConfiguration;
@class CDAContentType;
@class CDAEntry;
@class CDAResponse;
@class CDARequest;
@class CDASpace;
@class CDASyncedSpace;

/** Possible Resource types. */
typedef NS_ENUM(NSInteger, CDAResourceType) {
    /** Asset */
    CDAResourceTypeAsset,
    /** Content Type */
    CDAResourceTypeContentType,
    /** Entry */
    CDAResourceTypeEntry,
};

typedef void(^CDAArrayFetchedBlock)(CDAResponse* response, CDAArray* array);
typedef void(^CDAAssetFetchedBlock)(CDAResponse* response, CDAAsset* asset);
typedef void(^CDAContentTypeFetchedBlock)(CDAResponse* response, CDAContentType* contentType);
typedef void(^CDAEntryFetchedBlock)(CDAResponse* response, CDAEntry* entry);
typedef void(^CDARequestFailureBlock)(CDAResponse* response, NSError* error);
typedef void(^CDASpaceFetchedBlock)(CDAResponse* response, CDASpace* space);
typedef void(^CDASyncedSpaceFetchedBlock)(CDAResponse* response, CDASyncedSpace* space);

/**
 The CDAClient is used to request any information from the server. A client is associated with exactly
 one Space, but there is no limit to the concurrent number of clients existing at any one time.
 */
@interface CDAClient : NSObject

/** @name Creating a Client */

/**
*  Initializes a client for requesting data from the server.
*
*  @param spaceKey    The key of the Space containing the desired data.
*  @param accessToken The access token used for authentication against the API.
*
*  @return A client initialized for requesting data from the server.
*/
-(id)initWithSpaceKey:(NSString *)spaceKey accessToken:(NSString *)accessToken;

/**
 *  Initializes a client for requesting data from the server, while passing additional configuration
 *  options.
 *
 *  @param spaceKey      The key of the Space containing the desired data.
 *  @param accessToken   The access token used for authentication against the API.
 *  @param configuration Specific options for configuring the client.
 *
 *  @return A client initialized for requesting data from the server.
 */
-(id)initWithSpaceKey:(NSString *)spaceKey
          accessToken:(NSString *)accessToken
        configuration:(CDAConfiguration*)configuration;

/** @name Fetching Assets */

/**
 *  Fetch all Assets from the server.
 *
 *  @param success A block which gets called upon successful retrieval of all Assets.
 *  @param failure A block which gets called if an error occured during the retrieval process.
 *  @return The request used for fetching data.
 */
-(CDARequest*)fetchAssetsWithSuccess:(CDAArrayFetchedBlock)success
                             failure:(CDARequestFailureBlock)failure;

/**
 *  Fetch one specific Asset from the server.
 *
 *  @param identifier The identifier of the Asset to request.
 *  @param success    A block which gets called upon successful retrieval of the Asset.
 *  @param failure    A block which gets called if an error occured during the retrieval process.
 *  @return The request used for fetching data.
 */
-(CDARequest*)fetchAssetWithIdentifier:(NSString*)identifier
                               success:(CDAAssetFetchedBlock)success
                               failure:(CDARequestFailureBlock)failure;

/** @name Fetching Content Types */

/**
 *  Fetch all Content Types from the server.
 *
 *  @param success A block which gets called upon successful retrieval of all Content Types.
 *  @param failure A block which gets called if an error occured during the retrieval process.<commit_msg>Make method for fetching Assets using a query public.<commit_after>//
//  CDAClient.h
//  ContentfulSDK
//
//  Created by <NAME> on 04/03/14.
//
//

#import <Foundation/Foundation.h>

@class CDAArray;
@class CDAAsset;
@class CDAConfiguration;
@class CDAContentType;
@class CDAEntry;
@class CDAResponse;
@class CDARequest;
@class CDASpace;
@class CDASyncedSpace;

/** Possible Resource types. */
typedef NS_ENUM(NSInteger, CDAResourceType) {
    /** Asset */
    CDAResourceTypeAsset,
    /** Content Type */
    CDAResourceTypeContentType,
    /** Entry */
    CDAResourceTypeEntry,
};

typedef void(^CDAArrayFetchedBlock)(CDAResponse* response, CDAArray* array);
typedef void(^CDAAssetFetchedBlock)(CDAResponse* response, CDAAsset* asset);
typedef void(^CDAContentTypeFetchedBlock)(CDAResponse* response, CDAContentType* contentType);
typedef void(^CDAEntryFetchedBlock)(CDAResponse* response, CDAEntry* entry);
typedef void(^CDARequestFailureBlock)(CDAResponse* response, NSError* error);
typedef void(^CDASpaceFetchedBlock)(CDAResponse* response, CDASpace* space);
typedef void(^CDASyncedSpaceFetchedBlock)(CDAResponse* response, CDASyncedSpace* space);

/**
 The CDAClient is used to request any information from the server. A client is associated with exactly
 one Space, but there is no limit to the concurrent number of clients existing at any one time.
 */
@interface CDAClient : NSObject

/** @name Creating a Client */

/**
*  Initializes a client for requesting data from the server.
*
*  @param spaceKey    The key of the Space containing the desired data.
*  @param accessToken The access token used for authentication against the API.
*
*  @return A client initialized for requesting data from the server.
*/
-(id)initWithSpaceKey:(NSString *)spaceKey accessToken:(NSString *)accessToken;

/**
 *  Initializes a client for requesting data from the server, while passing additional configuration
 *  options.
 *
 *  @param spaceKey      The key of the Space containing the desired data.
 *  @param accessToken   The access token used for authentication against the API.
 *  @param configuration Specific options for configuring the client.
 *
 *  @return A client initialized for requesting data from the server.
 */
-(id)initWithSpaceKey:(NSString *)spaceKey
          accessToken:(NSString *)accessToken
        configuration:(CDAConfiguration*)configuration;

/** @name Fetching Assets */

/**
 *  Fetch all Assets matching a query from the server.
 *
 *  @param query   The query which retrieved Assets shall match. Queries are expressed as dictionaries,
 *                 see [Search Parameters](https://www.contentful.com/developers/documentation/content-delivery-api/#search) for more information.
 *  @param success A block which gets called upon successful retrieval of all matching Assets.
 *  @param failure A block which gets called if an error occured during the retrieval process.
 *  @return The request used for fetching data.
 */
-(CDARequest*)fetchAssetsMatching:(NSDictionary*)query
                          success:(CDAArrayFetchedBlock)success
                          failure:(CDARequestFailureBlock)failure;

/**
 *  Fetch all Assets from the server.
 *
 *  @param success A block which gets called upon successful retrieval of all Assets.
 *  @param failure A block which gets called if an error occured during the retrieval process.
 *  @return The request used for fetching data.
 */
-(CDARequest*)fetchAssetsWithSuccess:(CDAArrayFetchedBlock)success
                             failure:(CDARequestFailureBlock)failure;

/**
 *  Fetch one specific Asset from the server.
 *
 *  @param identifier The identifier of the Asset to request.
 *  @param success    A block which gets called upon successful retrieval of the Asset.
 *  @param failure    A block which gets called if an error occured during the retrieval process.
 *  @return The request used for fetching data.
 */
-(CDARequest*)fetchAssetWithIdentifier:(NSString*)identifier
                               success:(CDAAssetFetchedBlock)success
                               failure:(CDARequestFailureBlock)failure;

/** @name Fetching Content Types */

/**
 *  Fetch all Content Types from the server.
 *
 *  @param success A block which gets called upon successful retrieval of all Content Types.
 *  @param failure A block which gets called if an error occured during the retrieval process.
{'fraction_non_alphanumeric': 0.08451935081148565, 'fraction_numerical': 0.00149812734082397, 'mean_word_length': 3.95730198019802, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2526642', 'n_tokens_mistral': 2283, 'n_tokens_neox': 2190, 'n_words': 799}