myems-admin/app/services/settings/store/storemeter.service.js

Summary

Maintainability
D
2 days
Test Coverage
'use strict';
app.factory('StoreMeterService', function($http) {
    return {
        addPair: function(storeID, meterID, metertype, headers, callback) {
            var meter={};
            if(metertype=='meters'){
                meter={'meter_id':meterID};
            }else if(metertype=='virtualmeters'){
                meter={"virtual_meter_id":meterID};
            }else{
                meter={'offline_meter_id':meterID};
            }

            $http.post(getAPI()+'stores/'+storeID+'/'+metertype,{data:meter}, {headers})
            .then(function (response) {
                callback(response);
            }, function (response) {
                callback(response);
            });
        },

        deletePair: function(storeID, meterID, metertype, headers, callback) {
            $http.delete(getAPI()+'stores/'+storeID+'/'+metertype+'/'+meterID, {headers})
            .then(function (response) {
                callback(response);
            }, function (response) {
                callback(response);
            });
        },
        getMetersByStoreID: function(id, metertype, headers, callback) {
            $http.get(getAPI()+'stores/'+id+'/'+metertype, {headers})
            .then(function (response) {
                callback(response);
            }, function (response) {
                callback(response);
            });
        }
    };
});