"use strict";

var _Object$keys2 = require("@babel/runtime-corejs2/core-js/object/keys");
var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs2/core-js/object/get-own-property-symbols");
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptors");
var _Object$defineProperties = require("@babel/runtime-corejs2/core-js/object/define-properties");
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
_Object$defineProperty(exports, "__esModule", {
  value: true
});
exports.createContactsClient = exports.ContactsClient = void 0;
var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
var _values = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/values"));
var _entries = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/entries"));
var _keys = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/keys"));
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/slicedToArray"));
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/toConsumableArray"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
var _constants = require("../common/constants");
var _types = require("../common/types");
var _SDKConnector = _interopRequireDefault(require("../SDKConnector"));
var _Logger = _interopRequireDefault(require("../Logger"));
var _constants2 = require("./constants");
var _types2 = require("./types");
var _Utils = require("../common/Utils");
function ownKeys(e, r) { var t = _Object$keys2(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; } /* eslint-disable no-await-in-loop */
/**
 * `ContactsClient` module is designed to offer a set of APIs for retrieving and updating contacts and groups from the contacts-service.
 *
 * This code snippet demonstrates how to create an instance of `ContactClient` using webex and logger.
 *
 * Example
 * ```javascript
 * const contactClient = createContactsClient(webex, logger);
 * ```
 */
var ContactsClient = exports.ContactsClient = /*#__PURE__*/function () {
  /**
   * @ignore
   */
  function ContactsClient(webex, logger) {
    var _this$webex$internal$;
    (0, _classCallCheck2.default)(this, ContactsClient);
    (0, _defineProperty2.default)(this, "sdkConnector", void 0);
    (0, _defineProperty2.default)(this, "encryptionKeyUrl", void 0);
    (0, _defineProperty2.default)(this, "webex", void 0);
    (0, _defineProperty2.default)(this, "groups", void 0);
    (0, _defineProperty2.default)(this, "contacts", void 0);
    (0, _defineProperty2.default)(this, "defaultGroupId", void 0);
    (0, _defineProperty2.default)(this, "contactsServiceUrl", void 0);
    this.sdkConnector = _SDKConnector.default;
    if (!this.sdkConnector.getWebex()) {
      _SDKConnector.default.setWebex(webex);
    }
    this.webex = this.sdkConnector.getWebex();
    this.encryptionKeyUrl = '';
    this.groups = undefined;
    this.contacts = undefined;
    this.defaultGroupId = '';
    this.contactsServiceUrl = ((_this$webex$internal$ = this.webex.internal.services._serviceUrls) === null || _this$webex$internal$ === void 0 ? void 0 : _this$webex$internal$.contactsService) || this.webex.internal.services.get(this.webex.internal.services._activeServices.contactsService);
    _Logger.default.setLogger(logger.level, _constants2.CONTACTS_CLIENT);
  }

  /**
   * Decrypt emails, phoneNumbers, sipAddresses.
   */
  return (0, _createClass2.default)(ContactsClient, [{
    key: "decryptContactDetail",
    value: (function () {
      var _decryptContactDetail = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee(encryptionKeyUrl, contactDetails) {
        var _this = this;
        var decryptedContactDetail, decryptedValues;
        return _regenerator.default.wrap(function (_context) {
          while (1) switch (_context.prev = _context.next) {
            case 0:
              decryptedContactDetail = (0, _toConsumableArray2.default)(contactDetails);
              _context.next = 1;
              return _promise.default.all(decryptedContactDetail.map(function (detail) {
                return _this.webex.internal.encryption.decryptText(encryptionKeyUrl, detail.value);
              }));
            case 1:
              decryptedValues = _context.sent;
              decryptedValues.forEach(function (decryptedValue, index) {
                decryptedContactDetail[index].value = decryptedValue;
              });
              return _context.abrupt("return", decryptedContactDetail);
            case 2:
            case "end":
              return _context.stop();
          }
        }, _callee);
      }));
      function decryptContactDetail(_x, _x2) {
        return _decryptContactDetail.apply(this, arguments);
      }
      return decryptContactDetail;
    }()
    /**
     * Encrypt emails, phoneNumbers, sipAddresses.
     *
     */
    )
  }, {
    key: "encryptContactDetail",
    value: (function () {
      var _encryptContactDetail = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee2(encryptionKeyUrl, contactDetails) {
        var _this2 = this;
        var encryptedContactDetail, encryptedValues;
        return _regenerator.default.wrap(function (_context2) {
          while (1) switch (_context2.prev = _context2.next) {
            case 0:
              encryptedContactDetail = (0, _toConsumableArray2.default)(contactDetails);
              _context2.next = 1;
              return _promise.default.all(encryptedContactDetail.map(function (detail) {
                return _this2.webex.internal.encryption.encryptText(encryptionKeyUrl, detail.value);
              }));
            case 1:
              encryptedValues = _context2.sent;
              encryptedValues.forEach(function (encryptedValue, index) {
                encryptedContactDetail[index].value = encryptedValue;
              });
              return _context2.abrupt("return", encryptedContactDetail);
            case 2:
            case "end":
              return _context2.stop();
          }
        }, _callee2);
      }));
      function encryptContactDetail(_x3, _x4) {
        return _encryptContactDetail.apply(this, arguments);
      }
      return encryptContactDetail;
    }()
    /**
     * Encrypts a given contact.
     */
    )
  }, {
    key: "encryptContact",
    value: (function () {
      var _encryptContact = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee5(contact) {
        var _this3 = this;
        var encryptionKeyUrl, encryptedContact, encryptionPromises, encryptedFieldsList;
        return _regenerator.default.wrap(function (_context5) {
          while (1) switch (_context5.prev = _context5.next) {
            case 0:
              encryptionKeyUrl = contact.encryptionKeyUrl;
              encryptedContact = _objectSpread({}, contact);
              encryptionPromises = (0, _values.default)(_constants2.encryptedFields).map(/*#__PURE__*/function () {
                var _ref = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee4(field) {
                  var plaintextAddressInfo, encryptedAddressInfo, encryptedAddressInfoPromises, plainTextDetails, encryptedDetails, encryptedValue, _t3, _t4;
                  return _regenerator.default.wrap(function (_context4) {
                    while (1) switch (_context4.prev = _context4.next) {
                      case 0:
                        _t3 = field;
                        _context4.next = _t3 === _constants2.encryptedFields.ADDRESS_INFO ? 1 : _t3 === _constants2.encryptedFields.EMAILS ? 4 : _t3 === _constants2.encryptedFields.PHONE_NUMBERS ? 4 : _t3 === _constants2.encryptedFields.SIP_ADDRESSES ? 4 : 7;
                        break;
                      case 1:
                        plaintextAddressInfo = encryptedContact.addressInfo;
                        if (!plaintextAddressInfo) {
                          _context4.next = 3;
                          break;
                        }
                        encryptedAddressInfoPromises = (0, _entries.default)(plaintextAddressInfo).map(/*#__PURE__*/function () {
                          var _ref3 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee3(_ref2) {
                            var _ref4, key, value, _t, _t2;
                            return _regenerator.default.wrap(function (_context3) {
                              while (1) switch (_context3.prev = _context3.next) {
                                case 0:
                                  _ref4 = (0, _slicedToArray2.default)(_ref2, 2), key = _ref4[0], value = _ref4[1];
                                  _t = key;
                                  _context3.next = 1;
                                  return _this3.webex.internal.encryption.encryptText(encryptionKeyUrl, value);
                                case 1:
                                  _t2 = _context3.sent;
                                  return _context3.abrupt("return", [_t, _t2]);
                                case 2:
                                case "end":
                                  return _context3.stop();
                              }
                            }, _callee3);
                          }));
                          return function (_x7) {
                            return _ref3.apply(this, arguments);
                          };
                        }());
                        _t4 = Object;
                        _context4.next = 2;
                        return _promise.default.all(encryptedAddressInfoPromises);
                      case 2:
                        encryptedAddressInfo = _t4.fromEntries.call(_t4, _context4.sent);
                      case 3:
                        return _context4.abrupt("return", [field, encryptedAddressInfo]);
                      case 4:
                        plainTextDetails = encryptedContact[field];
                        if (!plainTextDetails) {
                          _context4.next = 6;
                          break;
                        }
                        _context4.next = 5;
                        return _this3.encryptContactDetail(encryptionKeyUrl, plainTextDetails);
                      case 5:
                        encryptedDetails = _context4.sent;
                      case 6:
                        return _context4.abrupt("return", [field, encryptedDetails]);
                      case 7:
                        if (!((0, _values.default)(_constants2.encryptedFields).includes(field) && encryptedContact[field])) {
                          _context4.next = 9;
                          break;
                        }
                        _context4.next = 8;
                        return _this3.webex.internal.encryption.encryptText(encryptionKeyUrl, encryptedContact[field]);
                      case 8:
                        encryptedValue = _context4.sent;
                      case 9:
                        return _context4.abrupt("return", [field, encryptedValue]);
                      case 10:
                      case "end":
                        return _context4.stop();
                    }
                  }, _callee4);
                }));
                return function (_x6) {
                  return _ref.apply(this, arguments);
                };
              }());
              _context5.next = 1;
              return _promise.default.all(encryptionPromises);
            case 1:
              encryptedFieldsList = _context5.sent;
              encryptedFieldsList.forEach(function (_ref5) {
                var _ref6 = (0, _slicedToArray2.default)(_ref5, 2),
                  field = _ref6[0],
                  value = _ref6[1];
                if (value !== undefined) {
                  encryptedContact[field] = value;
                }
              });
              return _context5.abrupt("return", encryptedContact);
            case 2:
            case "end":
              return _context5.stop();
          }
        }, _callee5);
      }));
      function encryptContact(_x5) {
        return _encryptContact.apply(this, arguments);
      }
      return encryptContact;
    }()
    /**
     * Decrypts a given contact.
     */
    )
  }, {
    key: "decryptContact",
    value: (function () {
      var _decryptContact = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee8(contact) {
        var _this4 = this;
        var encryptionKeyUrl, decryptedContact, decryptionPromises, decryptedFieldsList;
        return _regenerator.default.wrap(function (_context8) {
          while (1) switch (_context8.prev = _context8.next) {
            case 0:
              encryptionKeyUrl = contact.encryptionKeyUrl;
              decryptedContact = _objectSpread({}, contact);
              decryptionPromises = (0, _values.default)(_constants2.encryptedFields).map(/*#__PURE__*/function () {
                var _ref7 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee7(field) {
                  var plaintextAddressInfo, decryptedAddressInfo, decryptedAddressInfoPromises, plainTextDetails, decryptedDetails, decryptedValue, _t7, _t8;
                  return _regenerator.default.wrap(function (_context7) {
                    while (1) switch (_context7.prev = _context7.next) {
                      case 0:
                        _t7 = field;
                        _context7.next = _t7 === _constants2.encryptedFields.ADDRESS_INFO ? 1 : _t7 === _constants2.encryptedFields.EMAILS ? 4 : _t7 === _constants2.encryptedFields.PHONE_NUMBERS ? 4 : _t7 === _constants2.encryptedFields.SIP_ADDRESSES ? 4 : 7;
                        break;
                      case 1:
                        plaintextAddressInfo = decryptedContact.addressInfo;
                        if (!plaintextAddressInfo) {
                          _context7.next = 3;
                          break;
                        }
                        decryptedAddressInfoPromises = (0, _entries.default)(plaintextAddressInfo).map(/*#__PURE__*/function () {
                          var _ref9 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee6(_ref8) {
                            var _ref0, key, value, _t5, _t6;
                            return _regenerator.default.wrap(function (_context6) {
                              while (1) switch (_context6.prev = _context6.next) {
                                case 0:
                                  _ref0 = (0, _slicedToArray2.default)(_ref8, 2), key = _ref0[0], value = _ref0[1];
                                  _t5 = key;
                                  _context6.next = 1;
                                  return _this4.webex.internal.encryption.decryptText(encryptionKeyUrl, value);
                                case 1:
                                  _t6 = _context6.sent;
                                  return _context6.abrupt("return", [_t5, _t6]);
                                case 2:
                                case "end":
                                  return _context6.stop();
                              }
                            }, _callee6);
                          }));
                          return function (_x0) {
                            return _ref9.apply(this, arguments);
                          };
                        }());
                        _t8 = Object;
                        _context7.next = 2;
                        return _promise.default.all(decryptedAddressInfoPromises);
                      case 2:
                        decryptedAddressInfo = _t8.fromEntries.call(_t8, _context7.sent);
                      case 3:
                        return _context7.abrupt("return", [field, decryptedAddressInfo]);
                      case 4:
                        plainTextDetails = decryptedContact[field];
                        if (!plainTextDetails) {
                          _context7.next = 6;
                          break;
                        }
                        _context7.next = 5;
                        return _this4.decryptContactDetail(encryptionKeyUrl, plainTextDetails);
                      case 5:
                        decryptedDetails = _context7.sent;
                      case 6:
                        return _context7.abrupt("return", [field, decryptedDetails]);
                      case 7:
                        if (!((0, _values.default)(_constants2.encryptedFields).includes(field) && decryptedContact[field])) {
                          _context7.next = 9;
                          break;
                        }
                        _context7.next = 8;
                        return _this4.webex.internal.encryption.decryptText(encryptionKeyUrl, decryptedContact[field]);
                      case 8:
                        decryptedValue = _context7.sent;
                      case 9:
                        return _context7.abrupt("return", [field, decryptedValue]);
                      case 10:
                      case "end":
                        return _context7.stop();
                    }
                  }, _callee7);
                }));
                return function (_x9) {
                  return _ref7.apply(this, arguments);
                };
              }());
              _context8.next = 1;
              return _promise.default.all(decryptionPromises);
            case 1:
              decryptedFieldsList = _context8.sent;
              decryptedFieldsList.forEach(function (_ref1) {
                var _ref10 = (0, _slicedToArray2.default)(_ref1, 2),
                  field = _ref10[0],
                  value = _ref10[1];
                if (value !== undefined) {
                  decryptedContact[field] = value;
                }
              });
              return _context8.abrupt("return", decryptedContact);
            case 2:
            case "end":
              return _context8.stop();
          }
        }, _callee8);
      }));
      function decryptContact(_x8) {
        return _decryptContact.apply(this, arguments);
      }
      return decryptContact;
    }())
  }, {
    key: "resolveCloudContacts",
    value: function resolveCloudContacts(contactsDataMap, inputList) {
      var loggerContext = {
        file: _constants2.CONTACTS_CLIENT,
        method: 'resolveCloudContacts'
      };
      var finalContactList = [];
      var resolvedList = [];
      try {
        inputList.Resources.forEach(function (item) {
          resolvedList.push(item.id);
        });
        (0, _values.default)(contactsDataMap).forEach(function (item) {
          var isResolved = resolvedList.some(function (listItem) {
            return listItem === item.contactId;
          });
          if (!isResolved) {
            finalContactList.push(_objectSpread(_objectSpread({}, item), {}, {
              resolved: false
            }));
          }
        });
        for (var n = 0; n < inputList.Resources.length; n += 1) {
          var _filteredContact$name, _filteredContact$name2, _filteredContact$SCIM, _filteredContact$SCIM2, _filteredContact$SCIM3;
          var filteredContact = inputList.Resources[n];
          var displayName = filteredContact.displayName,
            emails = filteredContact.emails,
            phoneNumbers = filteredContact.phoneNumbers,
            photos = filteredContact.photos;
          var sipAddresses = void 0;
          if (filteredContact[_constants.SCIM_WEBEXIDENTITY_USER]) {
            sipAddresses = filteredContact[_constants.SCIM_WEBEXIDENTITY_USER].sipAddresses;
          }
          var firstName = (_filteredContact$name = filteredContact.name) === null || _filteredContact$name === void 0 ? void 0 : _filteredContact$name.givenName;
          var lastName = (_filteredContact$name2 = filteredContact.name) === null || _filteredContact$name2 === void 0 ? void 0 : _filteredContact$name2.familyName;
          var manager = (_filteredContact$SCIM = filteredContact[_constants.SCIM_ENTERPRISE_USER]) === null || _filteredContact$SCIM === void 0 ? void 0 : (_filteredContact$SCIM2 = _filteredContact$SCIM.manager) === null || _filteredContact$SCIM2 === void 0 ? void 0 : _filteredContact$SCIM2.displayName;
          var department = (_filteredContact$SCIM3 = filteredContact[_constants.SCIM_ENTERPRISE_USER]) === null || _filteredContact$SCIM3 === void 0 ? void 0 : _filteredContact$SCIM3.department;
          var avatarURL = photos !== null && photos !== void 0 && photos.length ? photos[0].value : '';
          var _contactsDataMap$inpu = contactsDataMap[inputList.Resources[n].id],
            contactType = _contactsDataMap$inpu.contactType,
            avatarUrlDomain = _contactsDataMap$inpu.avatarUrlDomain,
            encryptionKeyUrl = _contactsDataMap$inpu.encryptionKeyUrl,
            ownerId = _contactsDataMap$inpu.ownerId,
            groups = _contactsDataMap$inpu.groups;
          var cloudContact = {
            avatarUrlDomain: avatarUrlDomain,
            avatarURL: avatarURL,
            contactId: inputList.Resources[n].id,
            contactType: contactType,
            department: department,
            displayName: displayName,
            emails: emails,
            encryptionKeyUrl: encryptionKeyUrl,
            firstName: firstName,
            groups: groups,
            lastName: lastName,
            manager: manager,
            ownerId: ownerId,
            phoneNumbers: phoneNumbers,
            sipAddresses: sipAddresses,
            resolved: true
          };
          finalContactList.push(cloudContact);
        }
      } catch (error) {
        _Logger.default.warn('Error occurred while parsing resolved contacts', loggerContext);
        return null;
      }
      return finalContactList;
    }

    /**
     * Returns list of contacts.
     */
  }, {
    key: "getContacts",
    value: (function () {
      var _getContacts = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee1() {
        var _this5 = this;
        var loggerContext, contactList, cloudContactsMap, _response$headers, response, responseBody, contacts, groups, contactIdList, totalContacts, MAX_CONTACTS_PER_QUERY, i, contactIdListChunk, query, result, slicedCloudContactsMap, resolvedContacts, contactResponse, errorStatus, _t9, _t0;
        return _regenerator.default.wrap(function (_context1) {
          while (1) switch (_context1.prev = _context1.next) {
            case 0:
              loggerContext = {
                file: _constants2.CONTACTS_CLIENT,
                method: _constants2.METHODS.GET_CONTACTS
              };
              _Logger.default.info(_constants.METHOD_START_MESSAGE, loggerContext);
              contactList = [];
              cloudContactsMap = {};
              _context1.prev = 1;
              _context1.next = 2;
              return this.webex.request({
                // eslint-disable-next-line no-underscore-dangle
                uri: "".concat(this.contactsServiceUrl, "/").concat(_constants2.ENCRYPT_FILTER, "/").concat(_constants2.USERS, "/").concat(_constants2.CONTACT_FILTER),
                method: _types.HTTP_METHODS.GET
              });
            case 2:
              response = _context1.sent;
              _Logger.default.log("Response code: ".concat(response.statusCode, " and Response trackingId: ").concat(response === null || response === void 0 ? void 0 : (_response$headers = response.headers) === null || _response$headers === void 0 ? void 0 : _response$headers.trackingid), loggerContext);
              responseBody = response.body;
              if (responseBody) {
                _context1.next = 3;
                break;
              }
              throw new Error("".concat(response));
            case 3:
              contacts = responseBody.contacts, groups = responseBody.groups;
              _context1.next = 4;
              return _promise.default.all(contacts.map(/*#__PURE__*/function () {
                var _ref11 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee9(contact) {
                  var decryptedContact;
                  return _regenerator.default.wrap(function (_context9) {
                    while (1) switch (_context9.prev = _context9.next) {
                      case 0:
                        if (!(contact.contactType === _types2.ContactType.CUSTOM)) {
                          _context9.next = 2;
                          break;
                        }
                        _context9.next = 1;
                        return _this5.decryptContact(contact);
                      case 1:
                        decryptedContact = _context9.sent;
                        contactList.push(decryptedContact);
                        _context9.next = 3;
                        break;
                      case 2:
                        if (contact.contactType === _types2.ContactType.CLOUD && contact.contactId) {
                          cloudContactsMap[contact.contactId] = contact;
                        }
                      case 3:
                      case "end":
                        return _context9.stop();
                    }
                  }, _callee9);
                }));
                return function (_x1) {
                  return _ref11.apply(this, arguments);
                };
              }()));
            case 4:
              if (!(0, _keys.default)(cloudContactsMap).length) {
                _context1.next = 10;
                break;
              }
              contactIdList = (0, _keys.default)(cloudContactsMap);
              totalContacts = contactIdList.length;
              MAX_CONTACTS_PER_QUERY = 50;
              i = 0;
            case 5:
              if (!(i < totalContacts)) {
                _context1.next = 10;
                break;
              }
              _context1.prev = 6;
              contactIdListChunk = contactIdList.slice(i, i + MAX_CONTACTS_PER_QUERY);
              query = contactIdListChunk.map(function (item) {
                return "".concat(_constants2.SCIM_ID_FILTER, " \"").concat(item, "\"");
              }).join(_constants2.OR);
              _context1.next = 7;
              return (0, _Utils.scimQuery)(query);
            case 7:
              result = _context1.sent;
              slicedCloudContactsMap = Object.fromEntries((0, _entries.default)(cloudContactsMap).slice(i, i + MAX_CONTACTS_PER_QUERY));
              resolvedContacts = this.resolveCloudContacts(slicedCloudContactsMap, result.body);
              if (resolvedContacts) {
                resolvedContacts.forEach(function (item) {
                  return contactList.push(item);
                });
              }
              _context1.next = 9;
              break;
            case 8:
              _context1.prev = 8;
              _t9 = _context1["catch"](6);
              _Logger.default.warn("Error processing contact chunk ".concat(i, "-").concat(i + MAX_CONTACTS_PER_QUERY), loggerContext);
            case 9:
              i += MAX_CONTACTS_PER_QUERY;
              _context1.next = 5;
              break;
            case 10:
              _context1.next = 11;
              return _promise.default.all(groups.map(/*#__PURE__*/function () {
                var _ref12 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee0(group, idx) {
                  return _regenerator.default.wrap(function (_context0) {
                    while (1) switch (_context0.prev = _context0.next) {
                      case 0:
                        _context0.next = 1;
                        return _this5.webex.internal.encryption.decryptText(group.encryptionKeyUrl, group.displayName);
                      case 1:
                        groups[idx].displayName = _context0.sent;
                      case 2:
                      case "end":
                        return _context0.stop();
                    }
                  }, _callee0);
                }));
                return function (_x10, _x11) {
                  return _ref12.apply(this, arguments);
                };
              }()));
            case 11:
              this.groups = groups;
              this.contacts = contactList;
              contactResponse = {
                statusCode: Number(response[_constants.STATUS_CODE]),
                data: {
                  contacts: contactList,
                  groups: groups
                },
                message: _constants.SUCCESS_MESSAGE
              };
              _Logger.default.log('Successfully fetched contacts and groups', loggerContext);
              return _context1.abrupt("return", contactResponse);
            case 12:
              _context1.prev = 12;
              _t0 = _context1["catch"](1);
              _Logger.default.error("Error fetching contacts: ".concat((0, _stringify.default)(_t0)), loggerContext);
              errorStatus = (0, _Utils.serviceErrorCodeHandler)(_t0, loggerContext);
              _context1.next = 13;
              return (0, _Utils.uploadLogs)();
            case 13:
              return _context1.abrupt("return", errorStatus);
            case 14:
            case "end":
              return _context1.stop();
          }
        }, _callee1, this, [[1, 12], [6, 8]]);
      }));
      function getContacts() {
        return _getContacts.apply(this, arguments);
      }
      return getContacts;
    }()
    /**
     * Creates a new KMS Resource Object (KRO) and Content Key (CK) which is used for encryption.
     *
     * @returns EncryptionKeyUrl as a Promise.
     */
    )
  }, {
    key: "createNewEncryptionKeyUrl",
    value: (function () {
      var _createNewEncryptionKeyUrl = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee10() {
        var loggerContext, unboundedKeyUri, unboundedKeys;
        return _regenerator.default.wrap(function (_context10) {
          while (1) switch (_context10.prev = _context10.next) {
            case 0:
              loggerContext = {
                file: _constants2.CONTACTS_CLIENT,
                method: _constants2.METHODS.CREATE_NEW_ENCRYPTION_KEY_URL
              };
              _Logger.default.info(_constants.METHOD_START_MESSAGE, loggerContext);
              unboundedKeyUri = '';
              _Logger.default.info('Requesting kms for a new KRO and key', loggerContext);
              _context10.next = 1;
              return this.webex.internal.encryption.kms.createUnboundKeys({
                count: 1
              });
            case 1:
              unboundedKeys = _context10.sent;
              unboundedKeyUri = unboundedKeys[0].uri;
              this.webex.internal.encryption.kms.createResource({
                keyUris: [unboundedKeyUri]
              });
              return _context10.abrupt("return", unboundedKeyUri);
            case 2:
            case "end":
              return _context10.stop();
          }
        }, _callee10, this);
      }));
      function createNewEncryptionKeyUrl() {
        return _createNewEncryptionKeyUrl.apply(this, arguments);
      }
      return createNewEncryptionKeyUrl;
    }()
    /**
     * Fetches the encryptionKeyUrl from one of the groups. Creates a new key and default group if there is no data.
     *
     * @returns EncryptionKeyUrl as a Promise.
     */
    )
  }, {
    key: "fetchEncryptionKeyUrl",
    value: (function () {
      var _fetchEncryptionKeyUrl = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee11() {
        var _response$data$group;
        var loggerContext, response, _response$data$group2;
        return _regenerator.default.wrap(function (_context11) {
          while (1) switch (_context11.prev = _context11.next) {
            case 0:
              loggerContext = {
                file: _constants2.CONTACTS_CLIENT,
                method: _constants2.METHODS.FETCH_ENCRYPTION_KEY_URL
              };
              _Logger.default.info(_constants.METHOD_START_MESSAGE, loggerContext);
              if (!this.encryptionKeyUrl) {
                _context11.next = 1;
                break;
              }
              return _context11.abrupt("return", this.encryptionKeyUrl);
            case 1:
              if (!(this.groups === undefined)) {
                _context11.next = 2;
                break;
              }
              _context11.next = 2;
              return this.getContacts();
            case 2:
              if (!(this.groups && this.groups.length)) {
                _context11.next = 3;
                break;
              }
              return _context11.abrupt("return", this.groups[0].encryptionKeyUrl);
            case 3:
              _context11.next = 4;
              return this.createNewEncryptionKeyUrl();
            case 4:
              this.encryptionKeyUrl = _context11.sent;
              _Logger.default.log("Creating a default group: ".concat(_constants2.DEFAULT_GROUP_NAME), {
                file: _constants2.CONTACTS_CLIENT,
                method: this.fetchEncryptionKeyUrl.name
              });
              _context11.next = 5;
              return this.createContactGroup(_constants2.DEFAULT_GROUP_NAME, this.encryptionKeyUrl);
            case 5:
              response = _context11.sent;
              if ((_response$data$group = response.data.group) !== null && _response$data$group !== void 0 && _response$data$group.groupId) {
                this.defaultGroupId = (_response$data$group2 = response.data.group) === null || _response$data$group2 === void 0 ? void 0 : _response$data$group2.groupId;
                _Logger.default.log("Successfully created default group with ID: ".concat(this.defaultGroupId), {
                  file: _constants2.CONTACTS_CLIENT,
                  method: this.fetchEncryptionKeyUrl.name
                });
              }
              return _context11.abrupt("return", this.encryptionKeyUrl);
            case 6:
            case "end":
              return _context11.stop();
          }
        }, _callee11, this);
      }));
      function fetchEncryptionKeyUrl() {
        return _fetchEncryptionKeyUrl.apply(this, arguments);
      }
      return fetchEncryptionKeyUrl;
    }()
    /**
     * Fetches a default group.
     *
     * @returns GroupId of default group.
     */
    )
  }, {
    key: "fetchDefaultGroup",
    value: (function () {
      var _fetchDefaultGroup = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee12() {
        var loggerContext, i, response, group, groupId;
        return _regenerator.default.wrap(function (_context12) {
          while (1) switch (_context12.prev = _context12.next) {
            case 0:
              loggerContext = {
                file: _constants2.CONTACTS_CLIENT,
                method: _constants2.METHODS.FETCH_DEFAULT_GROUP
              };
              _Logger.default.info(_constants.METHOD_START_MESSAGE, loggerContext);
              if (!this.defaultGroupId) {
                _context12.next = 1;
                break;
              }
              _Logger.default.log("Using existing default group with ID: ".concat(this.defaultGroupId), {
                file: _constants2.CONTACTS_CLIENT,
                method: this.fetchDefaultGroup.name
              });
              return _context12.abrupt("return", this.defaultGroupId);
            case 1:
              if (!(this.groups && this.groups.length)) {
                _context12.next = 4;
                break;
              }
              i = 0;
            case 2:
              if (!(i < this.groups.length)) {
                _context12.next = 4;
                break;
              }
              if (!(this.groups[i].displayName === _constants2.DEFAULT_GROUP_NAME)) {
                _context12.next = 3;
                break;
              }
              this.defaultGroupId = this.groups[i].groupId;
              _Logger.default.log("Found default group with ID: ".concat(this.defaultGroupId), {
                file: _constants2.CONTACTS_CLIENT,
                method: this.fetchDefaultGroup.name
              });
              return _context12.abrupt("return", this.defaultGroupId);
            case 3:
              i += 1;
              _context12.next = 2;
              break;
            case 4:
              _Logger.default.log('No default group found.', {
                file: _constants2.CONTACTS_CLIENT,
                method: this.fetchDefaultGroup.name
              });
              _context12.next = 5;
              return this.createContactGroup(_constants2.DEFAULT_GROUP_NAME);
            case 5:
              response = _context12.sent;
              group = response.data.group;
              if (!group) {
                _context12.next = 6;
                break;
              }
              groupId = group.groupId;
              _Logger.default.log("Successfully created new default group with ID: ".concat(groupId), {
                file: _constants2.CONTACTS_CLIENT,
                method: this.fetchDefaultGroup.name
              });
              return _context12.abrupt("return", groupId);
            case 6:
              return _context12.abrupt("return", '');
            case 7:
            case "end":
              return _context12.stop();
          }
        }, _callee12, this);
      }));
      function fetchDefaultGroup() {
        return _fetchDefaultGroup.apply(this, arguments);
      }
      return fetchDefaultGroup;
    }()
    /**
     * Creates a personal contact group.
     * Also creates a KRO, if there aren't any groups.
     * @param displayName - Name of the group to create.
     * @param encryptionKeyUrl - EncryptionKeyUrl to encrypt the displayName.
     * @param groupType - Type of the group to create.
     */
    )
  }, {
    key: "createContactGroup",
    value: (function () {
      var _createContactGroup = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee13(displayName, encryptionKeyUrl, groupType) {
        var loggerContext, encryptionKeyUrlFinal, isExistingGroup, encryptedDisplayName, groupInfo, _response$headers2, _this$groups, response, group, contactResponse, errorStatus, _t1, _t10;
        return _regenerator.default.wrap(function (_context13) {
          while (1) switch (_context13.prev = _context13.next) {
            case 0:
              loggerContext = {
                file: _constants2.CONTACTS_CLIENT,
                method: _constants2.METHODS.CREATE_CONTACT_GROUP
              };
              _Logger.default.info("".concat(_constants.METHOD_START_MESSAGE, " with displayName: ").concat(displayName), loggerContext);
              _t1 = encryptionKeyUrl;
              if (_t1) {
                _context13.next = 2;
                break;
              }
              _context13.next = 1;
              return this.fetchEncryptionKeyUrl();
            case 1:
              _t1 = _context13.sent;
            case 2:
              encryptionKeyUrlFinal = _t1;
              if (!(this.groups === undefined)) {
                _context13.next = 3;
                break;
              }
              _context13.next = 3;
              return this.getContacts();
            case 3:
              if (!(this.groups && this.groups.length)) {
                _context13.next = 4;
                break;
              }
              isExistingGroup = this.groups.find(function (group) {
                return group.displayName === displayName;
              });
              if (!isExistingGroup) {
                _context13.next = 4;
                break;
              }
              _Logger.default.warn("Group name ".concat(displayName, " already exists."), loggerContext);
              return _context13.abrupt("return", {
                statusCode: 400,
                data: {
                  error: 'Group displayName already exists'
                },
                message: _constants.FAILURE_MESSAGE
              });
            case 4:
              _context13.next = 5;
              return this.webex.internal.encryption.encryptText(encryptionKeyUrlFinal, displayName);
            case 5:
              encryptedDisplayName = _context13.sent;
              groupInfo = {
                schemas: _constants2.CONTACTS_SCHEMA,
                displayName: encryptedDisplayName,
                groupType: groupType || _types2.GroupType.NORMAL,
                encryptionKeyUrl: encryptionKeyUrlFinal
              };
              _context13.prev = 6;
              _context13.next = 7;
              return this.webex.request({
                // eslint-disable-next-line no-underscore-dangle
                uri: "".concat(this.contactsServiceUrl, "/").concat(_constants2.ENCRYPT_FILTER, "/").concat(_constants2.USERS, "/").concat(_constants2.GROUP_FILTER),
                method: _types.HTTP_METHODS.POST,
                body: groupInfo
              });
            case 7:
              response = _context13.sent;
              _Logger.default.log("Response code: ".concat(response.statusCode), loggerContext);
              _Logger.default.log("Response trackingId: ".concat(response === null || response === void 0 ? void 0 : (_response$headers2 = response.headers) === null || _response$headers2 === void 0 ? void 0 : _response$headers2.trackingid), loggerContext);
              group = response.body;
              group.displayName = displayName;
              contactResponse = {
                statusCode: Number(response[_constants.STATUS_CODE]),
                data: {
                  group: group
                },
                message: _constants.SUCCESS_MESSAGE
              };
              (_this$groups = this.groups) === null || _this$groups === void 0 ? void 0 : _this$groups.push(group);
              _Logger.default.log("Contact group ".concat(displayName, " successfully created"), loggerContext);
              return _context13.abrupt("return", contactResponse);
            case 8:
              _context13.prev = 8;
              _t10 = _context13["catch"](6);
              _Logger.default.error("Unable to create contact group: ".concat((0, _stringify.default)(_t10)), loggerContext);
              errorStatus = (0, _Utils.serviceErrorCodeHandler)(_t10, loggerContext);
              _context13.next = 9;
              return (0, _Utils.uploadLogs)();
            case 9:
              return _context13.abrupt("return", errorStatus);
            case 10:
            case "end":
              return _context13.stop();
          }
        }, _callee13, this, [[6, 8]]);
      }));
      function createContactGroup(_x12, _x13, _x14) {
        return _createContactGroup.apply(this, arguments);
      }
      return createContactGroup;
    }()
    /**
     * Deletes a contact group.
     * @param groupId - GroupId of the group to delete.
     */
    )
  }, {
    key: "deleteContactGroup",
    value: (function () {
      var _deleteContactGroup = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee14(groupId) {
        var loggerContext, _response$headers3, _this$groups2, _this$groups4, response, contactResponse, groupToDelete, _this$groups3, errorStatus, _t11;
        return _regenerator.default.wrap(function (_context14) {
          while (1) switch (_context14.prev = _context14.next) {
            case 0:
              loggerContext = {
                file: _constants2.CONTACTS_CLIENT,
                method: _constants2.METHODS.DELETE_CONTACT_GROUP
              };
              _Logger.default.info("".concat(_constants.METHOD_START_MESSAGE, " with groupId: ").concat(groupId), loggerContext);
              _context14.prev = 1;
              _Logger.default.info("Deleting contact group: ".concat(groupId), loggerContext);
              _context14.next = 2;
              return this.webex.request({
                // eslint-disable-next-line no-underscore-dangle
                uri: "".concat(this.contactsServiceUrl, "/").concat(_constants2.ENCRYPT_FILTER, "/").concat(_constants2.USERS, "/").concat(_constants2.GROUP_FILTER, "/").concat(groupId),
                method: _types.HTTP_METHODS.DELETE
              });
            case 2:
              response = _context14.sent;
              _Logger.default.log("Response trackingId: ".concat(response === null || response === void 0 ? void 0 : (_response$headers3 = response.headers) === null || _response$headers3 === void 0 ? void 0 : _response$headers3.trackingid), loggerContext);
              contactResponse = {
                statusCode: Number(response[_constants.STATUS_CODE]),
                data: {},
                message: _constants.SUCCESS_MESSAGE
              };
              groupToDelete = (_this$groups2 = this.groups) === null || _this$groups2 === void 0 ? void 0 : _this$groups2.findIndex(function (group) {
                return group.groupId === groupId;
              });
              if (groupToDelete !== undefined && groupToDelete !== -1) {
                (_this$groups3 = this.groups) === null || _this$groups3 === void 0 ? void 0 : _this$groups3.splice(groupToDelete, 1);
              }
              if (!((_this$groups4 = this.groups) !== null && _this$groups4 !== void 0 && _this$groups4.length)) {
                this.defaultGroupId = '';
              }
              _Logger.default.log("Contact group ".concat(groupId, " successfully deleted"), loggerContext);
              return _context14.abrupt("return", contactResponse);
            case 3:
              _context14.prev = 3;
              _t11 = _context14["catch"](1);
              _Logger.default.error("Unable to delete contact group ".concat(groupId, ": ").concat((0, _stringify.default)(_t11)), loggerContext);
              errorStatus = (0, _Utils.serviceErrorCodeHandler)(_t11, loggerContext);
              _context14.next = 4;
              return (0, _Utils.uploadLogs)();
            case 4:
              return _context14.abrupt("return", errorStatus);
            case 5:
            case "end":
              return _context14.stop();
          }
        }, _callee14, this, [[1, 3]]);
      }));
      function deleteContactGroup(_x15) {
        return _deleteContactGroup.apply(this, arguments);
      }
      return deleteContactGroup;
    }()
    /**
     * Creates a custom contact.
     * @param contactInfo - Contact object to create.
     */
    )
  }, {
    key: "createContact",
    value: (function () {
      var _createContact = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee15(contactInfo) {
        var loggerContext, _response$headers4, contact, defaultGroupId, requestBody, encryptedContact, _encryptedContact, response, newContact, contactResponse, query, res, resolvedContact, _this$contacts, _this$contacts2, errorStatus, _t12, _t13;
        return _regenerator.default.wrap(function (_context15) {
          while (1) switch (_context15.prev = _context15.next) {
            case 0:
              loggerContext = {
                file: _constants2.CONTACTS_CLIENT,
                method: _constants2.METHODS.CREATE_CONTACT
              };
              _Logger.default.info("".concat(_constants.METHOD_START_MESSAGE, " with contactType: ").concat(contactInfo.contactType), loggerContext);
              _context15.prev = 1;
              contact = _objectSpread({}, contactInfo);
              if (contact.encryptionKeyUrl) {
                _context15.next = 3;
                break;
              }
              _context15.next = 2;
              return this.fetchEncryptionKeyUrl();
            case 2:
              contact.encryptionKeyUrl = _context15.sent;
            case 3:
              if (!(!contact.groups || contact.groups.length === 0)) {
                _context15.next = 5;
                break;
              }
              _context15.next = 4;
              return this.fetchDefaultGroup();
            case 4:
              defaultGroupId = _context15.sent;
              contact.groups = [defaultGroupId];
            case 5:
              contact.schemas = _constants2.CONTACTS_SCHEMA;
              requestBody = {};
              _t12 = contact.contactType;
              _context15.next = _t12 === _types2.ContactType.CUSTOM ? 6 : _t12 === _types2.ContactType.CLOUD ? 8 : 11;
              break;
            case 6:
              _context15.next = 7;
              return this.encryptContact(contact);
            case 7:
              encryptedContact = _context15.sent;
              requestBody = encryptedContact;
              return _context15.abrupt("continue", 12);
            case 8:
              if (contact.contactId) {
                _context15.next = 9;
                break;
              }
              return _context15.abrupt("return", {
                statusCode: 400,
                data: {
                  error: 'contactId is required for contactType:CLOUD.'
                },
                message: _constants.FAILURE_MESSAGE
              });
            case 9:
              _context15.next = 10;
              return this.encryptContact(contact);
            case 10:
              _encryptedContact = _context15.sent;
              requestBody = _encryptedContact;
              return _context15.abrupt("continue", 12);
            case 11:
              return _context15.abrupt("return", {
                statusCode: 400,
                data: {
                  error: 'Unknown contactType received.'
                },
                message: _constants.FAILURE_MESSAGE
              });
            case 12:
              _context15.next = 13;
              return this.webex.request({
                // eslint-disable-next-line no-underscore-dangle
                uri: "".concat(this.contactsServiceUrl, "/").concat(_constants2.ENCRYPT_FILTER, "/").concat(_constants2.USERS, "/").concat(_constants2.CONTACT_FILTER),
                method: _types.HTTP_METHODS.POST,
                body: requestBody
              });
            case 13:
              response = _context15.sent;
              _Logger.default.log("Response code: ".concat(response.statusCode), loggerContext);
              _Logger.default.log("Response trackingId: ".concat(response === null || response === void 0 ? void 0 : (_response$headers4 = response.headers) === null || _response$headers4 === void 0 ? void 0 : _response$headers4.trackingid), loggerContext);
              newContact = response.body;
              contact.contactId = newContact.contactId;
              contactResponse = {
                statusCode: Number(response[_constants.STATUS_CODE]),
                data: {
                  contact: contact
                },
                message: _constants.SUCCESS_MESSAGE
              };
              if (!(contact.contactType === _types2.ContactType.CLOUD && newContact.contactId)) {
                _context15.next = 15;
                break;
              }
              query = "".concat(_constants2.SCIM_ID_FILTER, " \"").concat(newContact.contactId, "\"");
              _context15.next = 14;
              return (0, _Utils.scimQuery)(query);
            case 14:
              res = _context15.sent;
              resolvedContact = this.resolveCloudContacts(Object.fromEntries([[newContact.contactId, newContact]]), res.body);
              if (resolvedContact) {
                (_this$contacts = this.contacts) === null || _this$contacts === void 0 ? void 0 : _this$contacts.push(resolvedContact[0]);
              }
              _context15.next = 16;
              break;
            case 15:
              (_this$contacts2 = this.contacts) === null || _this$contacts2 === void 0 ? void 0 : _this$contacts2.push(contact);
            case 16:
              _Logger.default.log("Contact successfully created", loggerContext);
              return _context15.abrupt("return", contactResponse);
            case 17:
              _context15.prev = 17;
              _t13 = _context15["catch"](1);
              _Logger.default.error("Failed to create contact: ".concat((0, _stringify.default)(_t13)), loggerContext);
              errorStatus = (0, _Utils.serviceErrorCodeHandler)(_t13, loggerContext);
              _context15.next = 18;
              return (0, _Utils.uploadLogs)();
            case 18:
              return _context15.abrupt("return", errorStatus);
            case 19:
            case "end":
              return _context15.stop();
          }
        }, _callee15, this, [[1, 17]]);
      }));
      function createContact(_x16) {
        return _createContact.apply(this, arguments);
      }
      return createContact;
    }()
    /**
     * Delete a contact.
     * @param contactId - ContactId of the contact to delete.
     */
    )
  }, {
    key: "deleteContact",
    value: (function () {
      var _deleteContact = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee16(contactId) {
        var loggerContext, _this$contacts3, response, contactResponse, contactToDelete, _this$contacts4, errorStatus, _t14;
        return _regenerator.default.wrap(function (_context16) {
          while (1) switch (_context16.prev = _context16.next) {
            case 0:
              loggerContext = {
                file: _constants2.CONTACTS_CLIENT,
                method: _constants2.METHODS.DELETE_CONTACT
              };
              _Logger.default.info("".concat(_constants.METHOD_START_MESSAGE, " with contactId: ").concat(contactId), loggerContext);
              _context16.prev = 1;
              _Logger.default.info("Deleting contact : ".concat(contactId), loggerContext);
              _context16.next = 2;
              return this.webex.request({
                // eslint-disable-next-line no-underscore-dangle
                uri: "".concat(this.contactsServiceUrl, "/").concat(_constants2.ENCRYPT_FILTER, "/").concat(_constants2.USERS, "/").concat(_constants2.CONTACT_FILTER, "/").concat(contactId),
                method: _types.HTTP_METHODS.DELETE
              });
            case 2:
              response = _context16.sent;
              contactResponse = {
                statusCode: Number(response[_constants.STATUS_CODE]),
                data: {},
                message: _constants.SUCCESS_MESSAGE
              };
              contactToDelete = (_this$contacts3 = this.contacts) === null || _this$contacts3 === void 0 ? void 0 : _this$contacts3.findIndex(function (contact) {
                return contact.contactId === contactId;
              });
              if (contactToDelete !== undefined && contactToDelete !== -1) {
                (_this$contacts4 = this.contacts) === null || _this$contacts4 === void 0 ? void 0 : _this$contacts4.splice(contactToDelete, 1);
              }
              _Logger.default.log("Contact ".concat(contactId, " successfully deleted"), loggerContext);
              return _context16.abrupt("return", contactResponse);
            case 3:
              _context16.prev = 3;
              _t14 = _context16["catch"](1);
              _Logger.default.error("Unable to delete contact ".concat(contactId, ": ").concat((0, _stringify.default)(_t14)), loggerContext);
              errorStatus = (0, _Utils.serviceErrorCodeHandler)(_t14, loggerContext);
              _context16.next = 4;
              return (0, _Utils.uploadLogs)();
            case 4:
              return _context16.abrupt("return", errorStatus);
            case 5:
            case "end":
              return _context16.stop();
          }
        }, _callee16, this, [[1, 3]]);
      }));
      function deleteContact(_x17) {
        return _deleteContact.apply(this, arguments);
      }
      return deleteContact;
    }()
    /**
     * @ignore
     */
    )
  }, {
    key: "getSDKConnector",
    value: function getSDKConnector() {
      return this.sdkConnector;
    }
  }]);
}();
/**
 * Creates a ContactsClient instance
 *
 * @param {WebexSDK} webex - `Webex SDK`instance.
 * @param {LoggerInterface} logger - An instance implementing LoggerInterface used to set the log level for the module.
 */
var createContactsClient = exports.createContactsClient = function createContactsClient(webex, logger) {
  return new ContactsClient(webex, logger);
};
//# sourceMappingURL=ContactsClient.js.map
