//
// LoginJsonMapper.m
// LiveProject
//
// Created by Ziv on 15/9/16.
//
//

#import "LoginResponseJsonMapper.h"
#import <RestKit/RKObjectMappingOperationDataSource.h>

@implementation LoginResponseJsonMapper

- (instancetype)init {
	if (self = [super init]) {
		self.objectMapping = [LoginResponseBody objectMappingForClass:[LoginResponse class]];
	}
	return self;
}

#pragma mark - Public

- (NSError *)parseWithJSONObject:(id)jsonObject {
	self.response = [[LoginResponse alloc] init];

	RKMappingOperation *mappingOperation = [[RKMappingOperation alloc] initWithSourceObject:jsonObject destinationObject:self.response mapping:self.objectMapping];
	RKObjectMappingOperationDataSource *mappingOperationDataSource = [[RKObjectMappingOperationDataSource alloc] init];
	mappingOperation.dataSource = mappingOperationDataSource;

	NSError *error = nil;
	[mappingOperation performMapping:&error];
	return error;
}

@end
