function updateResource(project, slug, xlfFile, apiHostname, credentials) {
    return new Promise((resolve, reject) => {
        const data = JSON.stringify({ content: xlfFile.contents.toString() });
        const options = {
            hostname: apiHostname,
            path: `/api/2/project/${project}/resource/${slug}/content`,
            headers: {
                'Content-Type': 'application/json',
                'Content-Length': Buffer.byteLength(data)
            },
            auth: credentials,
            method: 'PUT'
        };
        let request = https.request(options, (res) => {
            if (res.statusCode === 200) {
                res.setEncoding('utf8');
                let responseBuffer = '';
                res.on('data', function (chunk) {
                    responseBuffer += chunk;
                });
                res.on('end', () => {
                    const response = JSON.parse(responseBuffer);
                    log(`Resource ${project}/${slug} successfully updated on Transifex. Strings added: ${response.strings_added}, updated: ${response.strings_added}, deleted: ${response.strings_added}`);
                    resolve();
                });
            }
            else {
                reject(`Something went wrong in the request updating ${slug} in ${project}. ${res.statusCode}`);
            }
        });
        request.on('error', (err) => {
            reject(`Failed to update ${project}/${slug} on Transifex: ${err}`);
        });
        request.write(data);
        request.end();
    });
}
function updateResource(project, slug, xlfFile, apiHostname, credentials) {
    return new Promise((resolve, reject) => {
        const data = JSON.stringify({ content: xlfFile.contents.toString() });
        const options = {
            hostname: apiHostname,
            path: `/api/2/project/${project}/resource/${slug}/content`,
            headers: {
                'Content-Type': 'application/json',
                'Content-Length': Buffer.byteLength(data)
            },
            auth: credentials,
            method: 'PUT'
        };
        let request = https.request(options, (res) => {
            if (res.statusCode === 200) {
                res.setEncoding('utf8');
                let responseBuffer = '';
                res.on('data', function (chunk) {
                    responseBuffer += chunk;
                });
                res.on('end', () => {
                    const response = JSON.parse(responseBuffer);
                    log(`Resource ${project}/${slug} successfully updated on Transifex. Strings added: ${response.strings_added}, updated: ${response.strings_added}, deleted: ${response.strings_added}`);
                    resolve();
                });
            }
            else {
                reject(`Something went wrong in the request updating ${slug} in ${project}. ${res.statusCode}`);
            }
        });
        request.on('error', (err) => {
            reject(`Failed to update ${project}/${slug} on Transifex: ${err}`);
        });
        request.write(data);
        request.end();
    });
}
function updateResource ( project , slug , xlfFile , apiHostname , credentials ) { return new Promise ( ( resolve , reject ) => { const data = JSON . stringify ( { content : xlfFile . contents . toString ( ) } ) ; const options = { hostname : apiHostname , path : ` ${ project } ${ slug } ` , headers : { 'Content-Type' : 'application/json' , 'Content-Length' : Buffer . byteLength ( data ) } , auth : credentials , method : 'PUT' } ; let request = https . request ( options , ( res ) => { if ( res . statusCode === 200 ) { res . setEncoding ( 'utf8' ) ; let responseBuffer = '' ; res . on ( 'data' , function ( chunk ) { responseBuffer += chunk ; } ) ; res . on ( 'end' , ( ) => { const response = JSON . parse ( responseBuffer ) ; log ( ` ${ project } ${ slug } ${ response . strings_added } ${ response . strings_added } ${ response . strings_added } ` ) ; resolve ( ) ; } ) ; } else { reject ( ` ${ slug } ${ project } ${ res . statusCode } ` ) ; } } ) ; request . on ( 'error' , ( err ) => { reject ( ` ${ project } ${ slug } ${ err } ` ) ; } ) ; request . write ( data ) ; request . end ( ) ; } ) ; }
The following link provides information about how Transifex handles updates of a resource file:
https://dev.befoolish.co/tx-docs/public/projects/updating-content#what-happens-when-you-update-files
The following link provides information about how Transifex handles updates of a resource file : https : // dev . befoolish . co / tx - docs / public / projects / updating - content#what - happens - when - you - update - files
Updates a resource on Transifex