Closed denizoguz closed 7 years ago
Hi, I'll look into it. Are you getting an 'unknown type' error or sth else?
@drkameleon
it gives "Unexpected: id" error for the line self.id = 2;
id is defined on the base class. If I remove that line it gives another error "Unexpected: ^" for the line :(void (^)(TrackingResult *trackingResult))callback {
Can not convert following valid code.
`
import "ArasKargo.h"
import "TrackingResult.h"
import "AFURLRequestSerialization.h"
import "AFHTTPRequestOperationManager.h"
import "TrackingNumberHistory.h"
import "HTMLReader/HTMLReader.h"
import "PreTrackingConfiguration.h"
static NSString *const HOST = @"http://kargotakip.araskargo.com.tr";
@implementation ArasKargo {
}
(void)trackWithTrackingNumber:(NSString )trackingNumber usingCaptcha:(NSString )captcha inManagedObjectContext:(NSManagedObjectContext )managedObjectContext andGiveResult:(void (^)(TrackingResult trackingResult))callback { manager = [self getHttpRequestOperationManagerWithHTTP]; TrackingResult trackingResult = [self getEmptyTrackingResult:trackingNumber withManagedObjectContext:managedObjectContext]; NSString queryURL = [NSString stringWithFormat:@"%@%@", self.URL, trackingNumber]; [manager GET:queryURL parameters:nil success:^(AFHTTPRequestOperation operation, id responseObject) { if (!operation.responseString) { [self setCannotTrack:trackingResult withCallback:callback]; return; } HTMLDocument htmlDocument = [HTMLDocument documentWithString:operation.responseString]; NSArray *labels = [htmlDocument nodesMatchingSelector:@"#Label1"]; if (!labels.firstObject) { [self setCannotTrack:trackingResult withCallback:callback]; return; } trackingResult.trackingNumberHistory.status = [labels.firstObject textContent];
} failure:^(AFHTTPRequestOperation operation, NSError error) { [self setCannotTrack:trackingResult withCallback:callback]; return; }]; }
(void)setBasicInfoFromBody:(NSString )secondRequestBody withResponse:(TrackingResult )trackingResult { if (secondRequestBody == nil) { trackingResult.success = NO; trackingResult.trackingNumberHistory.status = NSLocalizedString(@"Cat not track", ""); return; } HTMLDocument document = [HTMLDocument documentWithString:secondRequestBody]; HTMLElement element = [document firstNodeMatchingSelector:@"#LabelIlkCikis > a"]; NSString departingBranchName = element.innerHTML; NSString departingBranchLink = [element.attributes valueForKey:@"href"]; element = [document firstNodeMatchingSelector:@"#varis_subesi > a"]; NSString arrivalBranchName = element.innerHTML; NSString arrivalBranchLink = [element.attributes valueForKey:@"href"]; element = [document firstNodeMatchingSelector:@"#fatura_turu"]; NSString paymentType = [element textContent]; NSString shipmentDate = [[document firstNodeMatchingSelector:@"#cikis_tarihi"] innerHTML]; NSString receiverName = [[document firstNodeMatchingSelector:@"#alici_adi_soyadi"] innerHTML]; NSString senderName = [[document firstNodeMatchingSelector:@"#gonderici_adi_soyadi"] innerHTML]; NSString signatureName = [[document firstNodeMatchingSelector:@"#Teslim_Alan"] innerHTML]; NSString deliveryDate = [[document firstNodeMatchingSelector:@"#Teslim_Tarihi"] innerHTML]; NSString *status = [[document firstNodeMatchingSelector:@"#Son_Durum"] innerHTML];
trackingResult.success = YES; trackingResult.trackingNumberHistory.status = status; [trackingResult.queryResult setValue:senderName forKey:SENDER_NAME]; [trackingResult.queryResult setValue:shipmentDate forKey:SHIPMENT_DATE]; [trackingResult.queryResult setValue:receiverName forKey:RECEIVER_NAME]; [trackingResult.queryResult setValue:departingBranchName forKey:DEPARTING_BRANCH]; [trackingResult.queryResult setValue:departingBranchLink forKey:DEPARTING_BRANCH_LINK]; [trackingResult.queryResult setValue:arrivalBranchName forKey:ARRIVAL_BRANCH]; [trackingResult.queryResult setValue:arrivalBranchLink forKey:ARRIVAL_BRANCH_LINK]; [trackingResult.queryResult setValue:paymentType forKey:PAYMENT_TYPE]; [trackingResult.queryResult setValue:status forKey:STATUS]; [trackingResult.queryResult setValue:signatureName forKey:SIGNATURE_NAME]; [trackingResult.queryResult setValue:deliveryDate forKey:DELIVERY_DATE]; }
}
@end
`