Last active
August 29, 2015 14:23
-
-
Save pavelosipov/fdb9f7784beace79632c to your computer and use it in GitHub Desktop.
Endpoints
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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