SCWebServiceDefinition Class Reference
Inherits from | SCDictionaryDefinition : SCDataDefinition : NSObject |
Declared in | SCWebServiceDefinition.h |
Overview
This class functions as a means to further extend the definition of remote web services. Using web service definitions, classes like SCObjectCell and SCObjectSection will be able to better generate user interface elements that truly represent their bound web service.
Sample use: // Define the Twitter API search web service for the search term ‘#iosdev’. SCWebServiceDefinition tweetDef = [SCWebServiceDefinition definitionWithBaseURL:@“http://search.twitter.com/” fetchObjectsAPI:@“search.json” resultsKeyName:@“results” resultsDictionaryKeyNames:nil]; [tweetDef.fetchObjectsParameters setValue:@“#iosdev” forKey:@“q”]; [tweetDef.fetchObjectsParameters setValue:@“recent” forKey:@“result_type”]; tweetDef.batchSizeParameterName = @“rpp”; tweetDef.nextBatchURLKeyName = @“next_page”; SCPropertyDefinition textPropertyDef = [SCPropertyDefinition definitionWithName:@“text” title:@“Tweet” type:SCPropertyTypeTextView]; [tweetDef addPropertyDefinition:textPropertyDef];
// Create a section that will display the tweets in batches of 50
SCArrayOfObjectsSecion *tweetsSection = [SCArrayOfObjectsSection sectionWithHeaderTitle:nil
webServiceDefinition:tweetDef batchSize:50];
[self.tableViewModel addSection:tweetsSection];
Tasks
Creation and Initialization
-
+ definitionWithBaseURL:fetchObjectsAPI:resultsKeyName:resultsDictionaryKeyNamesString:
-
+ definitionWithBaseURL:fetchObjectsAPI:resultsKeyName:resultsDictionaryKeyNames:
-
– initWithBaseURL:fetchObjectsAPI:resultsKeyName:resultsDictionaryKeyNamesString:
-
– initWithBaseURL:fetchObjectsAPI:resultsKeyName:resultsDictionaryKeyNames:
Configuration
-
baseURL
property -
baseURLString
property -
insertURL
property -
updateURL
property -
deleteURL
property -
httpHeaders
property -
fetchObjectsAPI
property -
fetchObjectsParameters
property -
resultsKeyName
property -
atomicResultKeyName
property -
batchSizeParameterName
property -
batchStartIndexParameterName
property -
batchInitialStartIndex
property -
nextBatchURLKeyName
property -
nextBatchTokenKeyName
property -
batchTokenParameterName
property -
objectIdKeyName
property -
readOnlyKeyNames
property -
insertObjectAPI
property -
insertHTTPMethod
property -
insertObjectParameters
property -
updateObjectAPI
property -
updateHTTPMethod
property -
updateObjectParameters
property -
deleteObjectAPI
property -
deleteObjectParameters
property
Authorization Methods
Properties
atomicResultKeyName
Set only if the fetched result is an atomic array of a single dictionary object. When this is the case, resultsKeyName can be set to a key in the returned atomic dictionary.
@property (nonatomic, copy) NSString *atomicResultKeyName
Declared In
SCWebServiceDefinition.h
baseURL
The base URL of the web service.
@property (nonatomic, strong) NSURL *baseURL
Declared In
SCWebServiceDefinition.h
baseURLString
The base URL in string format.
@property (nonatomic, copy) NSString *baseURLString
Declared In
SCWebServiceDefinition.h
batchInitialStartIndex
The initial starting index for the batch. Default: 0.
@property (nonatomic, readwrite) NSUInteger batchInitialStartIndex
Discussion
Note: Only has effect if batchStartIndexParameterName is set.
Declared In
SCWebServiceDefinition.h
batchSizeParameterName
The name of the parameter that can be assigned the fetched batch size.
@property (nonatomic, copy) NSString *batchSizeParameterName
Declared In
SCWebServiceDefinition.h
batchStartIndexParameterName
The name of the parameter that can be assigned the batch starting index.
@property (nonatomic, copy) NSString *batchStartIndexParameterName
Declared In
SCWebServiceDefinition.h
batchTokenParameterName
The name of the parameter to send the value received from nextBatchTokenKeyName in.
@property (nonatomic, copy) NSString *batchTokenParameterName
Declared In
SCWebServiceDefinition.h
deleteObjectAPI
The string containing the delete object API.
@property (nonatomic, copy) NSString *deleteObjectAPI
Declared In
SCWebServiceDefinition.h
deleteObjectParameters
The dictionary of delete object parameters.
@property (nonatomic, strong, readonly) NSMutableDictionary *deleteObjectParameters
Declared In
SCWebServiceDefinition.h
deleteURL
The DELETE URL computed based on baseURL and deleteObjectAPI;
@property (nonatomic, readonly) NSURL *deleteURL
Declared In
SCWebServiceDefinition.h
fetchObjectsAPI
The string containing the fetch objects API.
@property (nonatomic, copy) NSString *fetchObjectsAPI
Declared In
SCWebServiceDefinition.h
fetchObjectsParameters
The dictionary of fetch objects parameters.
@property (nonatomic, readonly) NSMutableDictionary *fetchObjectsParameters
Discussion
Sample use: [tweetDef.fetchObjectsParameters setValue:@“#iosdev” forKey:@“q”];
Declared In
SCWebServiceDefinition.h
httpHeaders
The dictionary of HTTP header values.
@property (nonatomic, strong, readonly) NSMutableDictionary *httpHeaders
Discussion
Sample use: [myWebServiceDef.httpHeaders setValue:@“application/json” forKey:@“Content-Type”];
Declared In
SCWebServiceDefinition.h
insertHTTPMethod
The HTTP method used for INSERT operations. Default: @“POST”.
@property (nonatomic, copy) NSString *insertHTTPMethod
Declared In
SCWebServiceDefinition.h
insertObjectAPI
The string containing the insert object API.
@property (nonatomic, copy) NSString *insertObjectAPI
Declared In
SCWebServiceDefinition.h
insertObjectParameters
The dictionary of insert object parameters.
@property (nonatomic, strong, readonly) NSMutableDictionary *insertObjectParameters
Declared In
SCWebServiceDefinition.h
insertURL
The INSERT URL computed based on baseURL and insertObjectAPI;
@property (nonatomic, readonly) NSURL *insertURL
Declared In
SCWebServiceDefinition.h
nextBatchTokenKeyName
The name of the dictionary key that contains the token to the next batch of objects.
@property (nonatomic, copy) NSString *nextBatchTokenKeyName
Declared In
SCWebServiceDefinition.h
nextBatchURLKeyName
The name of the dictionary key that contains the URL to the next batch of objects.
@property (nonatomic, copy) NSString *nextBatchURLKeyName
Declared In
SCWebServiceDefinition.h
objectIdKeyName
The name of the object key containing a unique id.
@property (nonatomic, copy) NSString *objectIdKeyName
Declared In
SCWebServiceDefinition.h
readOnlyKeyNames
The string containing all the readonly object keys separated by semi-colons. All keys specified here will not be updated during an object update operation.
@property (nonatomic, copy) NSString *readOnlyKeyNames
Declared In
SCWebServiceDefinition.h
resultsKeyName
The name of the results dictionary key that will contain the objects fetched from the web service. This value has no effect if the returned results are an array instead of a dictionary.
@property (nonatomic, copy) NSString *resultsKeyName
Declared In
SCWebServiceDefinition.h
updateHTTPMethod
The HTTP method used for UPDATE operations. Default: @“PUT”.
@property (nonatomic, copy) NSString *updateHTTPMethod
Declared In
SCWebServiceDefinition.h
updateObjectAPI
The string containing the update object API.
@property (nonatomic, copy) NSString *updateObjectAPI
Declared In
SCWebServiceDefinition.h
updateObjectParameters
The dictionary of update object parameters.
@property (nonatomic, strong, readonly) NSMutableDictionary *updateObjectParameters
Declared In
SCWebServiceDefinition.h
updateURL
The UPDATE URL computed based on baseURL and updateObjectAPI;
@property (nonatomic, readonly) NSURL *updateURL
Declared In
SCWebServiceDefinition.h
Class Methods
definitionWithBaseURL:fetchObjectsAPI:resultsKeyName:resultsDictionaryKeyNames:
Allocates and returns an initialized SCWebServiceDefinition.
+ (instancetype)definitionWithBaseURL:(NSString *)baseURL fetchObjectsAPI:(NSString *)api resultsKeyName:(NSString *)resultsKey resultsDictionaryKeyNames:(NSArray *)keyNames
Parameters
- baseURL
The base URL of the web service.
- api
The api string used to fetch the objects.
- resultsKey
The name of the dictionary key that will contain the fetched objects.
- keyNames
An array containing the key names of the results dictionary.
Declared In
SCWebServiceDefinition.h
definitionWithBaseURL:fetchObjectsAPI:resultsKeyName:resultsDictionaryKeyNamesString:
Allocates and returns an initialized SCWebServiceDefinition.
+ (instancetype)definitionWithBaseURL:(NSString *)baseURL fetchObjectsAPI:(NSString *)api resultsKeyName:(NSString *)resultsKey resultsDictionaryKeyNamesString:(NSString *)keyNamesString
Parameters
- baseURL
The base URL of the web service.
- api
The api string used to fetch the objects.
- resultsKey
The name of the dictionary key that will contain the fetched objects.
- keyNamesString
A string containing the key names of the results dictionary separated by semi-colons. Example string: @“firstName;lastName”. Property groups can also be defined in the string using the following format: @“Personal Details:(firstName, lastName); Address:(street, state, country)”. The group title can also be ommitted to create a group with no title. For example: @“:(firstName, lastName)”.
Key names string syntax options: @“key1;key2;key3;…” @“group1 header:(key1, key2,…):group1 footer;group2…”
Declared In
SCWebServiceDefinition.h
Instance Methods
clearAuthorizationHeader
Clears any existing value for the “Authorization” HTTP header.
- (void)clearAuthorizationHeader
Declared In
SCWebServiceDefinition.h
initWithBaseURL:fetchObjectsAPI:resultsKeyName:resultsDictionaryKeyNames:
Allocates and returns an initialized SCWebServiceDefinition.
- (instancetype)initWithBaseURL:(NSString *)baseURL fetchObjectsAPI:(NSString *)api resultsKeyName:(NSString *)resultsKey resultsDictionaryKeyNames:(NSArray *)keyNames
Parameters
- baseURL
The base URL of the web service.
- api
The api string used to fetch the objects.
- resultsKey
The name of the dictionary key that will contain the fetched objects.
- keyNames
An array containing the key names of the results dictionary.
Declared In
SCWebServiceDefinition.h
initWithBaseURL:fetchObjectsAPI:resultsKeyName:resultsDictionaryKeyNamesString:
Returns an initialized SCWebServiceDefinition.
- (instancetype)initWithBaseURL:(NSString *)baseURL fetchObjectsAPI:(NSString *)api resultsKeyName:(NSString *)resultsKey resultsDictionaryKeyNamesString:(NSString *)keyNamesString
Parameters
- baseURL
The base URL of the web service.
- api
The api string used to fetch the objects.
- resultsKey
The name of the dictionary key that will contain the fetched objects.
- keyNamesString
A string containing the key names of the results dictionary separated by semi-colons. Example string: @“firstName;lastName”. Property groups can also be defined in the string using the following format: @“Personal Details:(firstName, lastName); Address:(street, state, country)”. The group title can also be ommitted to create a group with no title. For example: @“:(firstName, lastName)”.
Key names string syntax options: @“key1;key2;key3;…” @“group1 header:(key1, key2,…):group1 footer;group2…”
Declared In
SCWebServiceDefinition.h
setAuthorizationHeaderWithToken:
Sets the “Authorization” HTTP header to a token-based authentication value, such as an OAuth access token. This overwrites any existing value for this header.
- (void)setAuthorizationHeaderWithToken:(NSString *)token
Parameters
- token
The authentication token
Declared In
SCWebServiceDefinition.h
setAuthorizationHeaderWithUsername:password:
Sets the “Authorization” HTTP header to a HTTP basic authentication value with Base64-encoded username and password. This overwrites any existing value for this header.
- (void)setAuthorizationHeaderWithUsername:(NSString *)username password:(NSString *)password
Parameters
- username
The HTTP basic auth username
- password
The HTTP basic auth password
Declared In
SCWebServiceDefinition.h