403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/location/core/src/repository/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/location/core/src/repository/formatrepository.js
import BaseRepository from "./baserepository";
import Format from "../entity/format";
import {Type} from "main.core";

/**
 * Class responsible for the addresses format obtaining.
 */
export default class FormatRepository extends BaseRepository
{
	constructor(props = {}) {
		props.path = 'location.api.format';
		super(props);
	}

	/**
	 * Find all available formats
	 * @param {string} languageId
	 * @returns {Promise}
	 */
	findAll(languageId: string): Promise
	{
		if(!Type.isString(languageId))
		{
			throw new TypeError('languageId must be type of string');
		}

		return this.actionRunner.run(
			'findAll',
			{
				languageId: languageId
			})
			.then(this.processResponse)
			.then(
				(data) => this.convertFormatCollection(data)
			);
	}

	/**
	 * Find address format by its code
	 * @param {string} formatCode
	 * @param {string} languageId
	 * @returns {Promise}
	 */
	findByCode(formatCode: string, languageId: string): Promise
	{
		if(!Type.isString(formatCode))
		{
			throw new TypeError('formatCode must be type of string');
		}

		if(!Type.isString(languageId))
		{
			throw new TypeError('languageId must be type of string');
		}

		return this.actionRunner.run(
			'findByCode',
			{
				formatCode: formatCode,
				languageId: languageId
			})
			.then(this.processResponse)
			.then(this.convertFormatData);
	}

	/**
	 * Find default address format
	 * @param {string} languageId
	 * @returns {Promise}
	 */
	findDefault(languageId: string): Promise
	{
		if(!Type.isString(languageId))
		{
			throw new TypeError('languageId must be type of string');
		}

		return this.actionRunner.run(
			'findDefault',
			{
				languageId: languageId
			})
			.then(this.processResponse)
			.then(this.convertFormatData);
	}

	convertFormatCollection(formatDataCollection: Array): Array<Format>
	{
		if(!Type.isArray(formatDataCollection))
		{
			throw new TypeError('Can\'t convert format collection data');
		}

		let result = [];

		formatDataCollection.forEach((format) => {
			result.push(
				this.convertFormatData(format)
			);
		});
		
		return result;
	}

	convertFormatData(formatData: {}): Format
	{
		if(!Type.isObject(formatData))
		{
			throw new TypeError('Can\'t convert format data');
		}

		return new Format(formatData);
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit