#import "TGShareMtSerialization.h" #import "ApiLayer38.h" #import #import @implementation TGShareMtSerialization - (NSUInteger)currentLayer { return 39; } - (id)parseMessage:(NSData *)data { return [Api38__Environment parseObject:data]; } - (MTExportAuthorizationResponseParser)exportAuthorization:(int32_t)datacenterId data:(__autoreleasing NSData **)data { Api38_FunctionContext *exportAuthorization = [Api38 auth_exportAuthorizationWithDcId:@(datacenterId)]; if (data) *data = exportAuthorization.payload; return ^MTExportedAuthorizationData *(NSData *data) { id response = exportAuthorization.responseParser(data); if ([response isKindOfClass:[Api38_auth_ExportedAuthorization class]]) { Api38_auth_ExportedAuthorization *exportedAuthorization = response; return [[MTExportedAuthorizationData alloc] initWithAuthorizationBytes:exportedAuthorization.bytes authorizationId:[exportedAuthorization.pid intValue]]; } return nil; }; } - (NSData *)importAuthorization:(int32_t)authId bytes:(NSData *)bytes { Api38_FunctionContext *importAuthorization = [Api38 auth_importAuthorizationWithPid:@(authId) bytes:bytes]; return importAuthorization.payload; } - (MTRequestDatacenterAddressListParser)requestDatacenterAddressList:(int32_t)datacenterId data:(__autoreleasing NSData **)data { Api38_FunctionContext *getConfig = [Api38 help_getConfig]; if (data) *data = getConfig.payload; return ^MTDatacenterAddressListData *(NSData *data) { id response = getConfig.responseParser(data); if ([response isKindOfClass:[Api38_Config class]]) { NSMutableArray *addressList = [[NSMutableArray alloc] init]; for (Api38_DcOption *dcOption in ((Api38_Config *)response).dcOptions) { if ([dcOption.pid intValue] == datacenterId) { MTDatacenterAddress *address = [[MTDatacenterAddress alloc] initWithIp:dcOption.ipAddress port:(uint16_t)[dcOption.port intValue] preferForMedia:[dcOption.flags intValue] & (1 << 1)]; [addressList addObject:address]; } } return [[MTDatacenterAddressListData alloc] initWithAddressList:addressList]; } return nil; }; } @end