Skip to content

Instantly share code, notes, and snippets.

@pavelosipov
Last active August 29, 2015 14:23
Show Gist options
  • Save pavelosipov/fdb9f7784beace79632c to your computer and use it in GitHub Desktop.
Save pavelosipov/fdb9f7784beace79632c to your computer and use it in GitHub Desktop.
Endpoints
@protocol CMRRequest <NSObject>
@property (nonatomic, readonly) id CMRHTTPOptions;
- (NSMutableURLRequest *)buildRequestWithBaseURL:(NSURL* )baseURL;
@end
@protocol CMREndpoint <NSObject>
- (id)pushRequest:(id<CMRRequestBuilder>)requestBuilder;
@end
@interface CMRHTTPRequest : NSObject <CMRRequest>
+ (instancetype)GET:(NSString *)method parameters:(NSDictionary *)parameters;
@end
@interface CMRMetadRequest : NSObject <CMRRequest>
+ (instancetype)POST:(int)commandID parameters:(NSArray *)parameters;
@end
@interface MRCWebRequest : MRCObservable <CMRRequest>
// some...
@end
@interface CMRMetad : NSObject
+ (instancetype)PInt64:(int)value;
+ (instancetype)String:(NSString *)value;
@end
@interface AppDelegate ()
@property (nonatomic, readonly) id<CMREndpoint> endpoint;
@end
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
[[self.endpoint pushRequest:
[CMRMetadRequest
POST:102
parameters:@[
[CMRMetad PInt64:23],
[CMRMetad String:@"123"]
]]]
subscribeNext:(CMRHTTPResponse *response) {
}];
[[self.endpoint pushRequest:
[CMRHTTPRequest
GET:@"/users"
parameters:@{@"refresh_token": @"123456789"}]]
subscribeNext:(CMRHTTPResponse *response) {
}];
[self.endpoint pushRequest:webRequest];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment