'use strict';

angular.module('app')
	.service('jobApi', function(WS, $q) {

    // var ws = new WebSocket('ws://localhost:4020');

	this.encode = function(request) {
		return {
			cmd: '/job',
			payload: request
		};
	};

	this.submitTranslationJob = function(productId) {
		var def;

		def = $q.defer();

		var objToSend = {
			cmd: '/jobs/calculate-price-for-translation',
			payload: {configuration:{ QUERY:{
                _id: productId
            } }}
		};


		WS.send(objToSend)
            .then(function(data) {
                def.resolve(data);
            }, function(err) {
                def.resolve(err);
            });

		return def.promise;
	};


});