TyphoonRestClient
is a library for integration against contract-first web service.
More...
Properties | |
BOOL | reachable |
Returns YES if connection supports reachability and network is reachable - otherwise NO More... | |
TRCConnectionReachabilityState | reachabilityState |
Returns current reachabilityState. More... | |
id< TRCErrorHandler > | errorHandler |
Set your TRCErrorHandler here. Default nil . More... | |
id< TRCConnection > | connection |
Set your TRCConnection here. Default nil . You must set this property. More... | |
TRCSerialization | defaultResponseSerialization |
Default: TRCSerializationJson. More... | |
BOOL | shouldSuppressWarnings |
If enabled, warning messages would be printed using NSLog. Disable if you are nervous, enable if you careful. Default: NO. More... | |
TRCOptions | options |
Set validation and processing options here. Default: TRCOptionsNone More... | |
TRCSerializerHttpQueryOptions | querySerializationOptions |
This options allows you to specify specific query serialization parameters It used while generating request's URL query and also by TRCSerializerHttpQuery to generate the body. More... | |
NSOperationQueue * | callbackQueue |
This queue used to call completion blocks. Main Queue used by default. More... | |
NSOperationQueue * | workQueue |
This queue used to do all serialization, deserialization, validations and parsing. Main Queue used by default. More... | |
TyphoonRestClient
is a library for integration against contract-first web service.
It provides facilities for customisable serialisation / marshalling, validation and stubbing requests.
TRC helps to quickly achieve end-to-end proof of concept, at the same time as providing a robust platform for deploying into demanding production environments.
|
readnonatomicassign |
Returns YES
if connection
supports reachability and network is reachable - otherwise NO
|
readnonatomicassign |
Returns current reachabilityState.
TRCConnectionReachabilityState
|
readwritenonatomicstrong |
Set your TRCErrorHandler
here. Default nil
.
|
readwritenonatomicstrong |
Set your TRCConnection
here. Default nil
. You must set this property.
|
readwritenonatomicassign |
Default: TRCSerializationJson.
|
readwritenonatomicassign |
If enabled, warning messages would be printed using NSLog. Disable if you are nervous, enable if you careful. Default: NO.
|
readwritenonatomicassign |
Set validation and processing options here. Default: TRCOptionsNone
|
readwritenonatomicassign |
This options allows you to specify specific query serialization parameters It used while generating request's URL query and also by TRCSerializerHttpQuery to generate the body.
|
readwritenonatomicstrong |
This queue used to call completion blocks. Main Queue used by default.
|
readwritenonatomicstrong |
This queue used to do all serialization, deserialization, validations and parsing. Main Queue used by default.
- (id<TRCProgressHandler>) sendRequest: | (id< TRCRequest >) | request | |
completion: | (void(^)(id result, NSError *error)) | completion | |
Sends your TRCRequest
using connection
and returns result in completion
block.
Make sure that connection
property set before calling this method.
TRCRequest
TRCConnection
- (void) registerValueTransformer: | (id< TRCValueTransformer >) | valueTransformer | |
forTag: | (NSString *) | tag | |
Registers TRCValueTransformer
for specific tag
string.
Use this tag
in your schemes to mark values which must be processed by this valueTransformer
TRCValueTransformer
- (void) registerObjectMapper: | (id< TRCObjectMapper >) | objectMapper | |
forTag: | (NSString *) | tag | |
Registers TRCObjectMapper
for specific tag
string.
Use this tag
in schemas to mark which part of object should be processed by this objectMapper
For example, you have next JSON object:
and your mappers process objects:
then you can register your mapper, for example, with tag = <people>
. After that registration you can modify your scheme into that:
TRCObjectMapper
- (void) registerPreProcessor: | (id< TRCPreProcessor >) | preProcessor |
Adds your TRCPreProcessor
into registry.
See TRCPreProcessor
for more details
TRCPostProcessor
- (void) registerPostProcessor: | (id< TRCPostProcessor >) | postProcessor |
Adds your TRCPostProcessor
into registry.
See TRCPostProcessor
for more details
TRCPostProcessor
- (void) registerDefaultRequestSerialization: | (TRCSerialization) | requestSerialization | |
forBodyObjectWithClass: | (Class) | clazz | |
Registers TRCSerialization
as default for body object class.
That's useful to avoid typing TRCRequest.requestBodySerialization
in each TRCRequest
in most cases.
Default registration is:
NSArray
registered with TRCSerializationJson
NSDictionary
registered with TRCSerializationJson
NSData
registered with TRCSerializationData
NSInputStream
registered with TRCSerializationRequestInputStream
NSString
registered with TRCSerializationString
So if you return NSInputStream
as bodyObject.TRCRequest
and avoid implementation of TRCRequest.requestBodySerialization
then TRCSerializationRequestInputStream
serialization would be used automatically
Feel free to change that registration, by re-registering for same classes, or registering nil
s
NSObject.isKindOfClass
method. If you register different TRCSerialization
-s for classes that inherit each over, then result is unexpected. For example if you register TRCSerializationJson
for NSArray
and TRCSerializationPlist
for NSMutableArray
it's undefined which serialization would be taken for NSMutableArray
.requestSerialization | TRCSerialization string identifier to register or nil to undo registration |
clazz | class used for matching when search for default serialization. |
- (id) convertThenValidateRequestObject: | (id) | object | |
usingSchemaTag: | (NSString *) | tag | |
options: | (TRCTransformationOptions) | options | |
error: | (NSError **) | pError | |
Provided by category TyphoonRestClient(Extensions).
- (id) validateThenConvertResponseObject: | (id) | object | |
usingSchemaTag: | (NSString *) | tag | |
options: | (TRCTransformationOptions) | options | |
error: | (NSError **) | pError | |
Provided by category TyphoonRestClient(Extensions).
- (void) registerRequestSerializer: | (id< TRCRequestSerializer >) | serializer | |
forName: | (TRCSerialization) | serializerName | |
Registers TRCRequestSerializer
for special string identifier TRCSerialization
.
Use TRCSerialization
identifier later in your TRCRequest
-s
Provided by category TyphoonRestClient(Infrastructure).
- (void) registerResponseSerializer: | (id< TRCResponseSerializer >) | serializer | |
forName: | (TRCSerialization) | serializerName | |
Registers TRCResponseSerializer
for special string identifier TRCSerialization
.
Use TRCSerialization
identifier later in your TRCRequest
-s
Provided by category TyphoonRestClient(Infrastructure).
- (void) registerSchemeFormat: | (id< TRCSchemaFormat >) | schemeFormat | |
forFileExtension: | (NSString *) | extension | |
Registers scheme file format in TyphoonRestClient
.
You are free to invent your own schema format to process and validate your own serialization formats.
By default, only one format available for schema. It's JSON format (with file extension 'json')
All scheme files must have path extensions of registered scheme format. For example all JSON schemes must ends with .json extension
TRCSchemaFormat
Provided by category TyphoonRestClient(Infrastructure).
- (void) registerValidationErrorPrinter: | (id< TRCValidationErrorPrinter >) | printer | |
forFormatWithFileExtension: | (NSString *) | extension | |
Registers validation error printer for schema file extension.
Because schema files with different extensions, looks different, then full description of validation error should also looks different per extension.
TRCValidationErrorPrinter
Provided by category TyphoonRestClient(Infrastructure).
- (void) registerTRCValueTransformerType: | (TRCValueTransformerType *) | type | |
withValueClass: | (Class) | clazz | |
Registers TRCValueTransformerType
with objective-c class.
Then TRCValueTransformerType
can be used as identifier in TRCValueTransformer
to specify input types, and type validation would be done based on classes registered with it.
To use TRCValueTransformerType
as identifier, it useful to have them as global variable in serializer header, and register pointer to that variables with classes. Calling that method will set correct value to these variables.
Note that value of type
variable would be set as BitMask, so you can later combine all acceptable types as one value like that: type1 | type2 | type3
TRCValueTransformerType
Provided by category TyphoonRestClient(Infrastructure).