Objective-C Fatturazione Elettronica Aruba IT: Create Transmission Request List

Back to Index

Creazione richiesta di trasmissione “Comunicazioni Finanziarie” in formato zip.

Documentation: https://fatturazioneelettronica.aruba.it/apidoc/docs.html#_createtransmissionrequestlist

CURL Command

curl -X POST  https://testws.fatturazioneelettronica.aruba.it/services/ClientRequest/CreateTransmissionRequestList?username=Utente&password=Password \
-H 'Accept: application/json' \
-H 'Content-Type: application/json;charset=UTF-8' \
-d '{
  "userName" : "Utente",
  "password" : "Password",
  "userID" : "Utente",
  "comunicationType" : "LI",
  "dataFile" : "dGVzdA=="
}'

Objective-C Example

#import <CkoRest.h>
#import <CkoJsonObject.h>
#import <CkoStringBuilder.h>
#import <NSString.h>

CkoRest *rest = [[CkoRest alloc] init];
BOOL success;

//  URL: https://testws.fatturazioneelettronica.aruba.it/services/ClientRequest/CreateTransmissionRequestList?username=Utente&password=Password
BOOL bTls = YES;
int port = 443;
BOOL bAutoReconnect = YES;
success = [rest Connect: @"testws.fatturazioneelettronica.aruba.it" port: [NSNumber numberWithInt: port] tls: bTls autoReconnect: bAutoReconnect];
if (success != YES) {
    NSLog(@"%@%d",@"ConnectFailReason: ",[rest.ConnectFailReason intValue]);
    NSLog(@"%@",rest.LastErrorText);
    return;
}

//  See the Online Tool for Generating JSON Creation Code
CkoJsonObject *json = [[CkoJsonObject alloc] init];
[json UpdateString: @"userName" value: @"Utente"];
[json UpdateString: @"password" value: @"Password"];
[json UpdateString: @"userID" value: @"Utente"];
[json UpdateString: @"comunicationType" value: @"LI"];
[json UpdateString: @"dataFile" value: @"dGVzdA=="];

[rest AddHeader: @"Content-Type" value: @"application/json;charset=UTF-8"];
[rest AddHeader: @"Accept" value: @"application/json"];

CkoStringBuilder *sbRequestBody = [[CkoStringBuilder alloc] init];
[json EmitSb: sbRequestBody];
CkoStringBuilder *sbResponseBody = [[CkoStringBuilder alloc] init];
success = [rest FullRequestSb: @"POST" uriPath: @"/services/ClientRequest/CreateTransmissionRequestList?username=Utente&password=Password" requestBody: sbRequestBody responseBody: sbResponseBody];
if (success != YES) {
    NSLog(@"%@",rest.LastErrorText);
    return;
}

int respStatusCode = [rest.ResponseStatusCode intValue];
if (respStatusCode >= 400) {
    NSLog(@"%@%d",@"Response Status Code = ",respStatusCode);
    NSLog(@"%@",@"Response Header:");
    NSLog(@"%@",rest.ResponseHeader);
    NSLog(@"%@",@"Response Body:");
    NSLog(@"%@",[sbResponseBody GetAsString]);
    return;
}

CkoJsonObject *jsonResponse = [[CkoJsonObject alloc] init];
[jsonResponse LoadSb: sbResponseBody];

//  See the Online Tool for Generating JSON Parse Code
NSString *errorCode = 0;
NSString *errorDescription = 0;
NSString *requestID = 0;
int i;
int count_i;
NSString *fileName = 0;

errorCode = [jsonResponse StringOf: @"errorCode"];
errorDescription = [jsonResponse StringOf: @"errorDescription"];
requestID = [jsonResponse StringOf: @"requestID"];
i = 0;
count_i = [[jsonResponse SizeOfArray: @"requestIDList"] intValue];
while (i < count_i) {
    jsonResponse.I = [NSNumber numberWithInt: i];
    fileName = [jsonResponse StringOf: @"requestIDList[i].fileName"];
    requestID = [jsonResponse StringOf: @"requestIDList[i].requestID"];
    i = i + 1;
}

Sample JSON Response Body

{
  "errorCode": "",
  "errorDescription": "",
  "requestID": "YWWCED5QWHU7AQGL",
  "requestIDList": [
    {
      "fileName": "ITADFSREETDSD_LI_0001.xml",
      "requestID": "4LMW5CCCBLXKS522"
    },
    {
      "fileName": "ITADFSREETDSD_LI_0002.xml",
      "requestID": "62LXGBLXJCDEAX3M"
    },
    {
      "fileName": "ITADFSREETDSD_LI_0003.xml",
      "requestID": "GBJDXIYJSWMRKQBP"
    }
  ]
}