Link

Create Vendor

Sample Requests and Responses

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

Request

//  Create a Map to store all the data of a Vendor
Map<String, Object> nsVendor = new Map<String, Object>();
    nsVendor.put('companyName', 'Pyramid Construction Inc.');
    nsVendor.put('currencyRecord', new Map<String, Object>{'internalId'=>'1'});
    nsVendor.put('payablesAccount', new Map<String, Object>{'internalId'=>'114'});
    nsVendor.put('subsidiary', new Map<String, Object>{'internalId'=>'1'});
    nsVendor.put('terms', new Map<String, Object>{'internalId'=>'6'});
    nsVendor.put('url', 'https://www.pyramid.com');

//  Initializing the Vendor Custom Fields
List<Object> vendCustomFieldList = new List<Object>();
Map<String,Object> vendCustomField1 = new Map<String,Object>();
    vendCustomField1.put('fieldType', 'select');
    vendCustomField1.put('scriptId', 'custentity_atlas_pbcs_category');
    vendCustomField1.put('valueLookup', new Map<String,Object>{'internalId'=>'1'});
    vendCustomFieldList.add(vendCustomField1);
Map<String,Object> vendCustomField2 = new Map<String,Object>();
    vendCustomField2.put('fieldType', 'date');
    vendCustomField2.put('scriptId', 'custentity_renewal_date');
    vendCustomField2.put('value', String.valueOf(DateTime.newInstance(2020, 12, 31).getTime()/1000));
    vendCustomFieldList.add(vendCustomField2);

//  Adding the Vendor Custom Fields
    nsVendor.put('customFieldList', new Map<String,Object>{'customField'=>vendCustomFieldList});

//  Initializing the Vendor 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('addr1','2334 N. Michigan Avenue, Suite 1500');
    addressbookAddress.put('city','Chicago');
    addressbookAddress.put('state','IL');
    addressbookAddress.put('country','_unitedStates');
    addressbookAddress.put('zip','60601');
    
    addressBook.put('addressbookAddress',addressbookAddress);
    addressBook.put('defaultBilling',true);
    addressBook.put('defaultShipping',true);
    addressBook.put('isResidential',true);
    
    addressBookList.add(addressBook);
    
    nsVendor.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('vendors', new List<Object>{nsVendor});
    String reqJSON = JSON.serialize(requestJSONMap);

Map<String, Object> reqObj = new Map<String, Object>();
    reqObj.put('version', '1.0');
    reqObj.put('action', 'createVendor');
    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=createVendor,
  timestamp=1607419613160,
  validRequest=true,
  version=1.0,
  responseJSON={
    "status": "200",
    "errors": [],
    "vendors": [
      {
        "url": "https://www.pyramid.com",
        "title": null,
        "terms": {
          "type": null,
          "name": "2% 10 Net 30",
          "internalId": "6",
          "externalId": null
        },
        "taxItem": null,
        "taxIdNum": null,
        "subsidiary": {
          "type": null,
          "name": "Parent Company",
          "internalId": "1",
          "externalId": null
        },
        "salutation": null,
        "salesforceID": "a012w00000XUnDLAA1",
        "phone": null,
        "payablesAccount": {
          "type": null,
          "name": "Accounts Payable",
          "internalId": "114",
          "externalId": null
        },
        "nullFieldList": null,
        "mobilePhone": null,
        "middleName": null,
        "legalName": null,
        "lastName": null,
        "lastModifiedDate": 1607419610,
        "isPerson": false,
        "isJobResourceVend": false,
        "isInactive": false,
        "isAccountant": null,
        "is1099Eligible": null,
        "internalId": "32442",
        "incoterm": null,
        "homePhone": null,
        "firstName": null,
        "fax": null,
        "externalId": null,
        "expenseAccount": null,
        "entityId": "Pyramid Construction Inc.",
        "email": null,
        "dateCreated": 1607419609,
        "customForm": {
          "type": null,
          "name": "Custom Vendor Form",
          "internalId": "4",
          "externalId": null
        },
        "customFieldList": {
          "customField": [
            {
              "valueLookup": null,
              "value": "1609353000",
              "scriptId": "custentity_renewal_date",
              "internalId": "434",
              "fieldType": null
            },
            {
              "valueLookup": {
                "type": null,
                "name": "Forecast",
                "internalId": "1",
                "externalId": null
              },
              "value": null,
              "scriptId": "custentity_atlas_pbcs_category",
              "internalId": "131",
              "fieldType": null
            }
          ]
        },
        "currencyRecord": {
          "type": null,
          "name": "INR",
          "internalId": "1",
          "externalId": null
        },
        "currencyList": {
          "vendorCurrency": [
            {
              "currencyRecord": {
                "type": null,
                "name": "INR",
                "internalId": "1",
                "externalId": null
              }
            }
          ],
          "currencyRecord": null
        },
        "creditLimit": null,
        "companyName": "Pyramid Construction Inc.",
        "category": null,
        "bcn": null,
        "addressbookList": {
          "replaceAll": null,
          "addressbook": [
            {
              "label": "2334 N. Michigan Avenue, Suite 1500",
              "isResidential": null,
              "internalId": "29789",
              "defaultShipping": true,
              "defaultBilling": true,
              "addressbookAddress": {
                "zip": "60601",
                "state": "IL",
                "internalId": null,
                "country": "_unitedStates",
                "city": "Chicago",
                "attention": null,
                "addrPhone": null,
                "addressee": "Pyramid Construction Inc.",
                "addr3": null,
                "addr2": null,
                "addr1": "2334 N. Michigan Avenue, Suite 1500"
              }
            }
          ]
        },
        "accountNumber": null
      }
    ]
  }
}