Advertisement
snarfblat

Untitled

May 28th, 2014
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     <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.">
  2.         <cfargument name="obj" type="struct" required="no" default="">
  3.  
  4.         <cfscript>
  5.         var json = {};
  6.         var data = {};
  7.         var addresses = [];
  8.         var addr = {};
  9.         var x = 0;
  10.  
  11.         //json.command = "upsert_account";
  12.         //json.secret = variables.secret;
  13.  
  14.         data.mura_id = arguments.obj.user_id; // this will be the id of the Slatwall account
  15.         data.email = arguments.obj.email;
  16.         data.first_name = arguments.obj.first_name;
  17.         data.last_name = arguments.obj.last_name;
  18.  
  19.         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")))  ) {
  20.             data.tax_exempt = arguments.obj.tax_exempt;
  21.             data.fed_id_number = arguments.obj.fed_id_number;
  22.         };
  23.  
  24.         x++;
  25.  
  26.         if ( StructKeyExists(arguments.obj, "city") ) {
  27.  
  28.             addr.mura_id = arguments.obj.address_id; // this will be the id of the Slatwall address for this user
  29.             addr.addr1 = arguments.obj.address;
  30.             addr.addr2 = arguments.obj.address2;
  31.             addr.city = arguments.obj.city;
  32.             addr.state = arguments.obj.state;
  33.             addr.zip = arguments.obj.zip;
  34.             addr.country = arguments.obj.country;
  35.             addr.is_residential = arguments.obj.is_residential;
  36.  
  37.         };
  38.  
  39.         data.addresses[x] = addr;
  40.         json.data = data;
  41.  
  42.         // var results = postToNetsuite(json);
  43.  
  44.         writeDump(var=json, abort=true);
  45.  
  46.         return results;
  47.         </cfscript>
  48.  
  49.     </cffunction>
  50.  
  51.  
  52.  
  53. <!--- this is a test cfm for you to use --->
  54.  
  55.  
  56. <cfscript>
  57. gw = CreateObject("component", "netsuite");
  58.  
  59. obj = {};
  60.  
  61. obj.user_id = "12345";
  62. obj.first_name = "Felix";
  63. obj.last_name = "Gaita";
  64. obj.email = "felix.gaita@bsg75.net";
  65.  
  66. obj.tax_exempt = "";
  67. obj.fed_id_number = "";
  68.  
  69. obj.address_id = 2;
  70. obj.address = "Three Battlestar Way";
  71. obj.address2 = "Engine Room";
  72. obj.city = "BSG75";
  73. obj.state = "California";
  74. obj.zip = "94561";
  75. obj.country = "US";
  76. obj.is_residential = "F";
  77.  
  78. result = gw.upsertAccount(obj);
  79.  
  80. writeDump(result);
  81.  
  82. </cfscript>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement