Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <cffunction name="upsertAccount" output="false" access="public" returntype="any" returnformat="json" hint="Create or Update a web store account / Returns internal Netsuite ID for created or updated record.">
- <cfargument name="obj" type="struct" required="no" default="">
- <cfscript>
- var json = {};
- var data = {};
- var addresses = [];
- var addr = {};
- var x = 0;
- //json.command = "upsert_account";
- //json.secret = variables.secret;
- data.mura_id = arguments.obj.user_id; // this will be the id of the Slatwall account
- data.email = arguments.obj.email;
- data.first_name = arguments.obj.first_name;
- data.last_name = arguments.obj.last_name;
- if ( (StructKeyExists(arguments.obj, "tax_exempt") and Len(StructKeyExists(arguments.obj, "tax_exempt"))) and (StructKeyExists(arguments.obj, "fed_id_number") and Len(StructKeyExists(arguments.obj, "fed_id_number"))) ) {
- data.tax_exempt = arguments.obj.tax_exempt;
- data.fed_id_number = arguments.obj.fed_id_number;
- };
- x++;
- if ( StructKeyExists(arguments.obj, "city") ) {
- addr.mura_id = arguments.obj.address_id; // this will be the id of the Slatwall address for this user
- addr.addr1 = arguments.obj.address;
- addr.addr2 = arguments.obj.address2;
- addr.city = arguments.obj.city;
- addr.state = arguments.obj.state;
- addr.zip = arguments.obj.zip;
- addr.country = arguments.obj.country;
- addr.is_residential = arguments.obj.is_residential;
- };
- data.addresses[x] = addr;
- json.data = data;
- // var results = postToNetsuite(json);
- writeDump(var=json, abort=true);
- return results;
- </cfscript>
- </cffunction>
- <!--- this is a test cfm for you to use --->
- <cfscript>
- gw = CreateObject("component", "netsuite");
- obj = {};
- obj.user_id = "12345";
- obj.first_name = "Felix";
- obj.last_name = "Gaita";
- obj.email = "felix.gaita@bsg75.net";
- obj.tax_exempt = "";
- obj.fed_id_number = "";
- obj.address_id = 2;
- obj.address = "Three Battlestar Way";
- obj.address2 = "Engine Room";
- obj.city = "BSG75";
- obj.state = "California";
- obj.zip = "94561";
- obj.country = "US";
- obj.is_residential = "F";
- result = gw.upsertAccount(obj);
- writeDump(result);
- </cfscript>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement