Link

Update Customer

Sample Requests and Responses

The following is an example request which can be used while using ‘updateCustomer’ action.

Request

//  Create a Map to store all the data of a Customer
Map<String, Object> nsCustomer = new Map<String, Object>();
	nsCustomer.put('internalId', '32342');
	nsCustomer.put('priceLevel', new Map<String, Object>{'internalId'=>'2'});
	nsCustomer.put('email', 'james@grandhotel.com');

//  Initializing the Customer Custom Fields
List<Object> custCustomFieldList = new List<Object>();
Map<String,Object> custCustomField = new Map<String,Object>();
    custCustomField.put('fieldType', 'double');
    custCustomField.put('scriptId', 'custentity_decimal');
    custCustomField.put('value', '156.99');
    custCustomFieldList.add(custCustomField);

//  Adding the Customer Custom Fields
    nsCustomer.put('customFieldList', new Map<String,Object>{'customField'=>custCustomFieldList});

//  Initializing the Customer Addresses
List<Object> addressBookList = new List<Object>();
Map<String,Object> addressBook = new Map<String,Object>();
Map<String,Object> addressbookAddress = new Map<String,Object>();
	addressbookAddress.put('internalId','29188');
	addressbookAddress.put('addrPhone','3435435356');
	addressbookAddress.put('addr1','2334 N. Michigan Avenue');
	addressbookAddress.put('addr2','Suite 1500');
	addressbookAddress.put('city','Chicago');
	addressbookAddress.put('state','IL');
	addressbookAddress.put('country','_unitedStates');
	addressbookAddress.put('zip','60601');
	addressBook.put('addressbookAddress',addressbookAddress);
	addressBook.put('isResidential',false);

	addressBookList.add(addressBook);

	nsCustomer.put('addressbookList', new Map<String,Object>{'addressbook'=>addressBookList});	

//  Initializing the RequestJSON Data to be passed.
Map<String, Object> requestJSONMap = new Map<String, Object>();
    requestJSONMap.put('customers', new List<Object>{nsCustomer});
    String reqJSON = JSON.serialize(requestJSONMap);

Map<String, Object> reqObj = new Map<String, Object>();
    reqObj.put('version', '1.0');
    reqObj.put('action', 'updateCustomer');
    reqObj.put('requestJSON', reqJSON);

//  Placing a request to Breadwinner Global API
Map<String, Object> resp = breadwinner_ns.BreadwinnerNetSuiteAPI.call(reqObj);
System.debug(resp);

Response

{
  action=updateCustomer,
  timestamp=1606909041457,
  validRequest=true,
  version=1.0,
  responseJSON={
    "status": "200",
    "errors": [],
    "customers": [
      {
        "vatRegNumber": null,
        "url": "https://www.grandhotel.com",
        "title": null,
        "territory": {
          "type": null,
          "name": "Default Round-Robin",
          "internalId": "-5",
          "externalId": null
        },
        "terms": {
          "type": null,
          "name": "1% 10 Net 30",
          "internalId": "5",
          "externalId": null
        },
        "taxItem": null,
        "subsidiary": {
          "type": null,
          "name": "Parent Company",
          "internalId": "1",
          "externalId": null
        },
        "startDate": 1606847400,
        "stage": "_customer",
        "salutation": null,
        "salesRep": null,
        "salesforceID": "a012w00000XUP93AAH",
        "resaleNumber": null,
        "reminderDays": null,
        "receivablesAccount": {
          "type": null,
          "name": "Accounts Receivable",
          "internalId": "122",
          "externalId": null
        },
        "priceLevel": {
          "type": null,
          "name": "Alternate Price 1",
          "internalId": "2",
          "externalId": null
        },
        "phone": null,
        "parent": null,
        "nullFieldList": null,
        "middleName": null,
        "lastName": null,
        "lastModifiedDate": 1606909039,
        "itemPricingList": null,
        "isPerson": false,
        "isInactive": false,
        "internalId": "32342",
        "firstName": null,
        "fax": null,
        "externalId": null,
        "entityStatus": {
          "type": null,
          "name": "CUSTOMER-Closed Won",
          "internalId": "13",
          "externalId": null
        },
        "entityId": "CUST533AT Grand Hotels & Resorts Ltd",
        "endDate": null,
        "email": "james@grandhotel.com",
        "dateCreated": 1606907165,
        "customForm": {
          "type": null,
          "name": "Standard Customer Form",
          "internalId": "-2",
          "externalId": null
        },
        "customFieldList": {
          "customField": [
            {
              "valueLookup": null,
              "value": "156.99",
              "scriptId": "custentity_decimal",
              "internalId": "435",
              "fieldType": null
            },
            {
              "valueLookup": {
                "type": null,
                "name": "Acquired",
                "internalId": "2",
                "externalId": null
              },
              "value": null,
              "scriptId": "custentityrating",
              "internalId": "42",
              "fieldType": null
            }
          ]
        },
        "currencyRecord": {
          "type": null,
          "name": "INR",
          "internalId": "1",
          "externalId": null
        },
        "currencyList": {
          "vendorCurrency": null,
          "currencyRecord": [
            {
              "currencyRecord": {
                "type": null,
                "name": "INR",
                "internalId": "1",
                "externalId": null
              }
            }
          ]
        },
        "creditLimit": null,
        "creditHoldOverride": "_auto",
        "companyName": "Grand Hotels & Resorts Ltd",
        "category": null,
        "addressbookList": {
          "replaceAll": null,
          "addressbook": [
            {
              "label": "2334 N. Michigan Avenue",
              "isResidential": false,
              "internalId": "29388",
              "defaultShipping": true,
              "defaultBilling": true,
              "addressbookAddress": {
                "zip": "60601",
                "state": "IL",
                "internalId": null,
                "country": "_unitedStates",
                "city": "Chicago",
                "attention": null,
                "addrPhone": "3435435356",
                "addressee": "CUST533AT Grand Hotels & Resorts Ltd",
                "addr3": null,
                "addr2": "Suite 1500",
                "addr1": "2334 N. Michigan Avenue"
              }
            }
          ]
        },
        "accountNumber": null
      }
    ]
  }
}