//
//  SubscribeRoomGroupRequest.m
//  SFS2X
//
//  Original development by Infosfer Game Technologies Ltd. | http://www.infosfer.com.
//
//  Maintained and developed by A51 Integrated.
//  Copyright 2012 A51 Integrated | http://a51integrated.com. All rights reserved.
//

#import "SubscribeRoomGroupRequest.h"


NSString * const SubscribeRoomGroupRequest_KEY_GROUP_ID = @"g";
NSString * const SubscribeRoomGroupRequest_KEY_ROOM_LIST = @"rl";

@implementation SubscribeRoomGroupRequest

@synthesize groupId = _groupId;


-(id)initWithGroupId:(NSString *)groupId {
	
	if ((self = [super initWithId:BaseRequest_SubscribeRoomGroup])) {
		self.groupId = groupId;
	}
	
	return self;
}

+(id)requestWithGroupId:(NSString *)groupId {
	SubscribeRoomGroupRequest *req = [[SubscribeRoomGroupRequest alloc] initWithGroupId:groupId];
	return req;
}

-(void)validate:(SmartFox2XClient *)sfs {
	
	NSMutableArray *errors = [NSMutableArray array];
	
	if (_groupId == nil || [_groupId length] == 0) {
		[errors addObject:@"Invalid groupId. Must be a string with at least 1 character."];
	}
	
	if ([errors count] > 0) {
		@throw [SFSValidationException validationExceptionWithReason:@"SubscribeGroup request error" errors:errors];
	}
}


-(void)execute:(SmartFox2XClient *)sfs{
	
	[_sfso putUtfString:SubscribeRoomGroupRequest_KEY_GROUP_ID value:_groupId];
	
}



@end
