//
// main.m
// RequestToWindcave2
//
// Created by Developer on 18/01/21.
// Copyright © 2021 Developer. All rights reserved.
//
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSMutableDictionary *requestMap = [[NSMutableDictionary alloc] initWithCapacity:32];
requestMap[@"type"] = @"purchase";
requestMap[@"amount"] = @"10.00";
requestMap[@"currency"] = @"NZD";
requestMap[@"card"] = @{
@"cardNumber": @"4111111111111111",
@"dateExpiryYear": @"23",
@"dateExpiryMonth": @"10",
@"cvc2": @"000"
};
NSData *requestBodyData = [NSJSONSerialization dataWithJSONObject:requestMap options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://dev.windcave.com/api/v1/transactions"] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60.0];
[request setHTTPMethod: @"POST"];
[request setValue: @"application/json" forHTTPHeaderField: @"content-type"];
[request setValue: @"Basic SGFqaW5LOjVlZGYzNzIyZmFjMjE1M2IwYzRmZjQyOGM2MDM5MjYwNjE5ZDI0N2M3Yzc3YWQ0Mzc5MThkZDUwNDMyMTc1MmU=" forHTTPHeaderField:@"Authorization"];
[request setHTTPBody: requestBodyData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session
dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error){
NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
NSLog(@"%@", dictionary);
}];
[dataTask resume];
while(true){}
}
return 0;
}