/**
 *
 * Creating users using Mangopay SDK Models and hash of properties
 *
 */


// In your app you will require('mangopay2-nodejs-sdk')
var mangopay = require('../index');

// In your app you will define your own set of configurations.
// Check README.md for the full list
var api = new mangopay({
    clientId: 'sdk-unit-tests',
    clientApiKey: 'cqFfFrWfCcb7UadHNxx2C9Lo6Djw8ZduLi7J9USTmu8bhxxpju'
});

/**
 *
 * Create a new user using Mangopay SDK Model
 * Promise style handling of the response
 *
 */
var myUser = new api.models.UserLegal({
    Name: 'MangoPay',
    Email: 'info@mangopay.com',
    LegalPersonType: 'BUSINESS',
    LegalRepresentativeFirstName: 'Mango',
    LegalRepresentativeLastName: 'Pay',
    LegalRepresentativeEmail: 'mango@mangopay.com',
    HeadquartersAddress: new api.models.Address({
        AddressLine1: "4101 Reservoir Rd NW",
        AddressLine2: "",
        City: "Washington",
        Region: "District of Columbia",
        PostalCode: "20007",
        Country: "US"
    }),
    LegalRepresentativeBirthday: 1300186358,
    LegalRepresentativeNationality: 'FR',
    LegalRepresentativeCountryOfResidence: 'FR',
    Tag: 'custom tag'
});

api.Users.create(myUser).then(function(){
    // Output the created user data to console
    console.log(myUser.Name + ' user created at ' + myUser.CreationDate);
});

/**
 *
 * Create a user using a hash of properties. Res
 * Don't forget to define PersonType
 * This example uses callback pattern approach
 *
 */
api.Users.create({
    Name: 'MangoPay',
    Email: 'info@mangopay.com',
    LegalPersonType: 'BUSINESS',
    LegalRepresentativeFirstName: 'Mango',
    LegalRepresentativeLastName: 'Pay',
    LegalRepresentativeEmail: 'mango@mangopay.com',
    PersonType: "LEGAL",
    HeadquartersAddress: {
        "AddressLine1": "4101 Reservoir Rd NW",
        "AddressLine2": "",
        "City": "Washington",
        "Region": "District of Columbia",
        "PostalCode": "20007",
        "Country": "US"
    },
    LegalRepresentativeBirthday: 1300186358,
    LegalRepresentativeNationality: 'FR',
    LegalRepresentativeCountryOfResidence: 'FR',
    Tag: 'custom tag'
}, function(myOtherUser) {
    // Output the created user data to console
    console.log(myOtherUser.Name + ' user created at ' + myOtherUser.CreationDate);
});
@@ -1220,10 +1220,26 @@
 tion
-()
+ (myReturnedUser) 
 %7B%0A  
@@ -1306,32 +1306,38 @@
 (myUser.Name + '
+ legal
  user created at
@@ -1343,16 +1343,24 @@
 t ' + my
+Returned
 User.Cre
@@ -2195,16 +2195,17 @@
 function
+ 
 (myOther
@@ -2251,32 +2251,32 @@
 data to console%0A
-
     console.log(
@@ -2326,28 +2326,668 @@
 OtherUser.CreationDate);%0A%7D);
+%0A%0A/**%0A *%0A * Create a new natural user with only required values%0A * Promise style handling of the response%0A *%0A */%0Aapi.Users.create(%7B%0A    PersonType: %22NATURAL%22,%0A    FirstName: %22John%22,%0A    LastName: %22Smith%22,%0A    Birthday: 1300186358,%0A    Nationality: %22FR%22,%0A    CountryOfResidence: %22GB%22,%0A    Email: %22john@smith.eu%22,%0A%7D).then(function (response) %7B%0A    console.log(%22Natural user created%22, response);%0A%7D);%0A%0A/**%0A *%0A * Fail at creating a new natural user, error caught%0A * Promise style handling of the response%0A *%0A */%0Aapi.Users.create(%7B%0A    PersonType: %22NATURAL%22,%0A%7D).catch(function (error) %7B%0A    console.log(%22Natural user creation failed%22, error);%0A%7D);

fix 'undefined' value and add more examples