PLYEndpoint.h
IntroductionUse the links in the table of contents to the left to access the documentation. ProtocolsMethods
deleteWithCompletion:- (void)deleteWithCompletion:(void(^)(id object, NSError *error))completion; ParametersSee
endpoint+ (instancetype)endpoint; Return ValueA new instance of the endpoint DiscussionInitializes a new endpoint with an empty slug and an empty query parameters endpointWithParameters:+ (instancetype)endpointWithParameters:(id<PLYParameterEncodableType>)parameters; ParametersReturn Valuea fully initialized endpoint DiscussionInitializes the endpoint with the given query parameters to populate the request endpointWithSlug:+ (instancetype)endpointWithSlug:(id)slug; ParametersReturn Valuea fully initialized endpoint DiscussionInitializes the endpoint with the given slug that should be used to populate the endpoint endpointWithSlug:andParameters:+ (instancetype)endpointWithSlug:(id)slug andParameters:(id<PLYParameterEncodableType>)parameters; ParametersReturn Valuea fully initialized endpoint DiscussionInitializes the endpoint with the given slug and query parameters getWithCompletion:- (void)getWithCompletion:(void(^)(id object, NSError *error))completion; Parameters
Discussion* Network method to perform a get request for a given endpoint * * initWithParameters:- (instancetype)initWithParameters:(id<PLYParameterEncodableType>)parameters; ParametersReturn Valuea fully initialized endpoint DiscussionInitializes the endpoint with the given query parameters to populate the request initWithSlug:- (instancetype)initWithSlug:(id)slug; ParametersReturn Valuea fully initialized endpoint DiscussionInitializes the endpoint with the given slug that should be used to populate the endpoint initWithSlug:andParameters:- (instancetype)initWithSlug:(id)slug andParameters:(id<PLYParameterEncodableType>)parameters NS_DESIGNATED_INITIALIZER; ParametersReturn Valuea fully initialized endpoint DiscussionInitializes the endpoint with the given slug and query parameters patchWithCompletion:- (void)patchWithCompletion:(void(^)(id object, NSError *error))completion; ParametersSee
postWithCompletion:- (void)postWithCompletion:(void(^)(id object, NSError *error))completion; ParametersSee
putWithCompletion:- (void)putWithCompletion:(void(^)(id object, NSError *error))completion; ParametersSee
transformResponseToMappableRawType:- (id<GenomeMappableRawType>) transformResponseToMappableRawType:(id)response; ParametersReturn Valuethe value received from the response DiscussionWhen a response is received from an api, you can use this method to provide customized behavior. A common use ase for this is when using an XML api that can not be automatically converted to a dictionary. You can use this to transform the data to a mappable type. You can also implement customized functionality as necessary for specialized circumstances. valueForSlugPath:withSlug:- (id)valueForSlugPath:(NSString *)slugPath withSlug:(id)slug; ParametersReturn Valuethe value to insert into the url, or nil if the slugpath should be removed from the url DiscussionWhen populating the endpoint with a given slug, by default, the endpoint will call: `[slug valueForKeyPath:slugPath];`. You can use this to override that behavior and provide custom functionality that allows for multiple slug types to be used. valueIsValid:forSlugPath:- (BOOL)valueIsValid:(id)value forSlugPath:(NSString *)slugPath; ParametersReturn Valuewhether or not to inject this value into the url at the given slug path, if NO, the path is not appended DiscussionUse this to prevent a value from being set to a slug, for example an NSInteger identifier might be invalid if it has a value of 0, or less than one and shouldn't be appended to the url. Properties
acceptableContentTypes@property (nonatomic, readonly) NSSet *acceptableContentTypes; DiscussionThe content types that can be accepted baseUrl@property (nonatomic, readonly, copy) NSString *baseUrl; DiscussionUse this to configure the base Url. An ideal architecture only overrides this in one base class and then each endpoint subclasses from there endpointUrl@property (nonatomic, readonly, copy) NSString *endpointUrl; DiscussionThe endpoint url that will be appended to the end of the base url, or a complete URL Example: @"/repos/:owner/:name/issues/:identifier" headerFields@property (nonatomic, readonly) NSDictionary *headerFields; DiscussionThe header fields to be added to the request requestSerializer@property (nonatomic, readonly) AFHTTPRequestSerializer<AFURLRequestSerialization> *requestSerializer; DiscussionA custom request serializer responseKeyPath@property (nonatomic, readonly, copy) NSString *responseKeyPath; DiscussionThe key to use when parsing a JSON response. responseSerializer@property (nonatomic, readonly) AFHTTPResponseSerializer<AFURLResponseSerialization> *responseSerializer; DiscussionA custom response serializer returnClass@property (nonatomic, readonly) Class returnClass; DiscussionThe type of class that is returned from this endpoint. WARNING: Must conform to protocol JSONMappableObject shouldAppendHeaderToResponse@property (nonatomic, readonly) BOOL shouldAppendHeaderToResponse; Discussion* In some cases, a header includes values that need to be appended to the model. For these situations, the header can be appended to the JSON mapping dictionary. If the response is a dictionary, an additional field will be added called 'Header', and values can be accessed via keypath syntax, ie: Header.etag. * * If the response is an array, it will be appended to the key "response" for mapping. * * The use case is when the header has values you want parsed into your model. For example a results page where the next, previous, and last page are included in the header. In these situations, you can use the keypath Header.Link, etc. in your mapping to map from the header. * * Use Header.headerValue when accessing header values in your object mapping * * Headers will be appended in the following format * @code // Array Responses @{ @"Header" : @{ @"headerKey" : @"headerVal" }, @"response" : @[] // array response } // Dictionary Responses @{ @"Header" : @{ @"headerKey" : @"headerVal" }, // The rest of the response appears here w/ top level keys as normal } |