<commit_before>import stampit from 'stampit';
import Request from './request';


/**
 * Wrapper around account endpoint. Meant to be used directly form {@link Syncano} instance.

 * @constructor
 * @type {Account}

 * @example {@lang javascript}
 * const {Account} = Syncano();
 * Account.login({email: '', password: ''}).then((user) => {
 *
 * });
 */
const Account = stampit().compose(Request)
  .props({
    _account: {
      registerPath: '/v1/account/register/',
      loginPath: '/v1/account/auth/',
      updatePath: '/v1/account/',
      userLoginPath: (instanceName) => `/v1/instances/${instanceName}/user/auth/`
    }
  })
  .methods({

    /**
    * A convenience method for creating a new account.

    * @memberOf Account
    * @instance

    * @param {Object} payload
    * @param {String} payload.email
    * @param {String} payload.password
    * @returns {Promise}

    */
    register(payload = {}) {
      const path = this._account.registerPath;
      return this.makeRequest('POST', path, {payload});
    },

    /**
    * A convenience method for authenticating with email and password.

    * @memberOf Account
    * @instance

    * @param {Object} payload
    * @param {String} payload.email
    * @param {String} payload.password
    * @param {Boolean} [setAccountKey = true]
    * @returns {Promise}

    */
    login(payload = {}, setAccountKey = true) {
      const config = this.getConfig();
      const path = this._account.loginPath;

      return this.makeRequest('POST', path, {payload}).then((user) => {
        if (setAccountKey === true) {
          config.setAccountKey(user.account_key);
        }
        return user;
      });
    },
<commit_msg>[LIB-509][ci skip] socialLogin method for Account object<commit_after>import stampit from 'stampit';
import Request from './request';


/**
 * Wrapper around account endpoint. Meant to be used directly form {@link Syncano} instance.

 * @constructor
 * @type {Account}

 * @example {@lang javascript}
 * const {Account} = Syncano();
 * Account.login({email: '', password: ''}).then((user) => {
 *
 * });
 */
const Account = stampit().compose(Request)
  .props({
    _account: {
      registerPath: '/v1/account/register/',
      loginPath: '/v1/account/auth/',
      updatePath: '/v1/account/',
      userLoginPath: (instanceName) => `/v1/instances/${instanceName}/user/auth/`,
      socialLoginPath: (instanceName, backend) => `/v1/instances/${instanceName}/user/auth/${backend}/`
    }
  })
  .methods({

    /**
    * A convenience method for creating a new account.

    * @memberOf Account
    * @instance

    * @param {Object} payload
    * @param {String} payload.email
    * @param {String} payload.password
    * @returns {Promise}

    */
    register(payload = {}) {
      const path = this._account.registerPath;
      return this.makeRequest('POST', path, {payload});
    },

    /**
    * A convenience method for authenticating with email and password.

    * @memberOf Account
    * @instance

    * @param {Object} payload
    * @param {String} payload.email
    * @param {String} payload.password
    * @param {Boolean} [setAccountKey = true]
    * @returns {Promise}

    */
    login(payload = {}, setAccountKey = true) {
      const config = this.getConfig();
      const path = this._account.loginPath;

      return this.makeRequest('POST', path, {payload}).then((user) => {
        if (setAccountKey === true) {
          config.setAccountKey(user.account_key);
        }
        return user;
      });
    },

    /**
    * A convenience method for authenticating instance user with a social media token.

    * @memberOf Account
    * @instance

    * @param {Object} payload
    * @param {String} payload.instanceName
    * @param {String} payload.backend
    * @param {String} payload.accessToken
    * @param {Boolean} [setUserKey = true]
    * @returns {Promise}

    */
    socialLogin(payload = {}, setAccountKey = true) {
      const config = this.getConfig();
      const path = this._account.socialLoginPath(payload.instanceName, payload.backend);

      return this.makeRequest('POST', path, {payload}).then((user) => {
        if (setAccountKey === true) {
          config.setAccountKey(user.account_key);
        }
        return user;
      });
    },

{'fraction_non_alphanumeric': 0.15, 'fraction_numerical': 0.002803738317757009, 'mean_word_length': 2.7618629173989455, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '177085', 'n_tokens_mistral': 1283, 'n_tokens_neox': 1254, 'n_words': 311}