Skip to content

Instantly share code, notes, and snippets.

@grosscorporation
Created August 4, 2018 03:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grosscorporation/ed73c18db49ea743c60af91b7807f824 to your computer and use it in GitHub Desktop.
Save grosscorporation/ed73c18db49ea743c60af91b7807f824 to your computer and use it in GitHub Desktop.
parse server complete cloud http single thread
let now = new Date ();
let ISODate = new Date ( now.toISOString () );
let TimeStamp = ISODate.getTime ();
let api_access_key = "api_access_key";
let api_secret_key = "api_secret_key";
let url = "https://test-emoney-services.w-ha.com/api/";
let body = {
"subscriber" : {
"lastname" : "Martin",
"firstname" : "Philippe",
"birthdate" : "1986-03-01",
"nationality" : "FRA"
},
"address" : {
"label1" : "12 rue de Stalingrad",
"zip_code" : "92800",
"city" : "Puteaux",
"country" : "FRA"
},
"email" : "ms.phldiddppe@wha.fr",
"tag" : "account_type1"
};
let hmac = crypto.createHmac ( 'sha256', api_secret_key );
hmac.update ( api_access_key + ':' + TimeStamp + ':1:' + JSON.stringify ( body ) );
let signature = hmac.digest ( 'hex' );
Parse.Cloud.httpRequest ( {
method : 'post',
url : url + 'accounts/standard',
headers : {
'Authorization' : 'AUTH ' + api_access_key + ':' + TimeStamp + ':1:' + signature,
'Content-Type' : 'application/json',
},
body : body,
params : {}
} ).then ( function ( httpResponse ) {
res.set('x-timestamp', Date.now());
res.status( 200 ).send ( httpResponse.data )
//res.send ( httpResponse.text.data )
}, function ( error ) {
res.status( error.code ).send ( error.data );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment