<commit_before>/* global moment */
import Ember from 'ember';
//http://www.programwitherik.com/ember-services-tutorial/
export default Ember.Service.extend({
	socketService: Ember.inject.service('websockets'),
	purecloud: Ember.inject.service(),
	analyticsService: Ember.inject.service(),

	idList: [],
	availableTopics: [],
	websocketMessages: [],
	socketRef: null,
	channelId: null,
	isPinned: false,

	init() {
		this._super(...arguments);

		let self = this;

		var api = self.get('purecloud').notificationsApi();

		api.postNotificationsChannels().then(function(channel){
			if ( !(self.get('isDestroyed') || self.get('isDestroying')) ) {
				console.log(channel);

				const socket = self.get('socketService').socketFor(channel.connectUri);

				socket.on('open', self.websocketOpenHandler, self);
				socket.on('message', self.websocketMessageHandler, self);

				self.set('socketRef', socket);
				self.set('channelId', channel.id);
			}
		});


		api.getNotificationsAvailabletopics('description,schema').then(function(topics){
			if ( !(self.get('isDestroyed') || self.get('isDestroying')) ) {
				self.set('availableTopics', topics.entities );
			}
		});

	},
	subscribe(id){
		let versionlessId = id.replace('v2.','');
		this.get('analyticsService').logNotificationRegistration(versionlessId.split('.')[0]);

		var that = this;
		var api = this.get('purecloud').notificationsApi();
		api.postNotificationsChannelSubscriptions(this.get('channelId'), [{id: id}]).then(function(){
			that.get('idList').pushObject(id);
		}).catch(function(error){
			console.log(error);
		});
	},
	unsubscribeAll(){
		var that = this;
		var api = this.get('purecloud').notificationsApi();
		api.putNotificationsChannelSubscriptions(this.get('channelId'), []).then(function(){
			that.get('idList').clear();
		}).catch(function(error){
			console.log(error);
		});<commit_msg>fix notification api call<commit_after>/* global moment */
import Ember from 'ember';
//http://www.programwitherik.com/ember-services-tutorial/
export default Ember.Service.extend({
	socketService: Ember.inject.service('websockets'),
	purecloud: Ember.inject.service(),
	analyticsService: Ember.inject.service(),

	idList: [],
	availableTopics: [],
	websocketMessages: [],
	socketRef: null,
	channelId: null,
	isPinned: false,

	init() {
		this._super(...arguments);

		let self = this;

		var api = self.get('purecloud').notificationsApi();

		api.postNotificationsChannels().then(function(channel){
			if ( !(self.get('isDestroyed') || self.get('isDestroying')) ) {
				console.log(channel);

				const socket = self.get('socketService').socketFor(channel.connectUri);

				socket.on('open', self.websocketOpenHandler, self);
				socket.on('message', self.websocketMessageHandler, self);

				self.set('socketRef', socket);
				self.set('channelId', channel.id);
			}
		});


		api.getNotificationsAvailabletopics({
      expand: ['description', 'schema']
    }).then(function(topics){
			if ( !(self.get('isDestroyed') || self.get('isDestroying')) ) {
				self.set('availableTopics', topics.entities );
			}
		});
	},
	subscribe(id){
		let versionlessId = id.replace('v2.','');
		this.get('analyticsService').logNotificationRegistration(versionlessId.split('.')[0]);

		var that = this;
		var api = this.get('purecloud').notificationsApi();
		api.postNotificationsChannelSubscriptions(this.get('channelId'), [{id: id}]).then(function(){
			that.get('idList').pushObject(id);
		}).catch(function(error){
			console.log(error);
		});
	},
	unsubscribeAll(){
		var that = this;
		var api = this.get('purecloud').notificationsApi();
		api.putNotificationsChannelSubscriptions(this.get('channelId'), []).then(function(){
			that.get('idList').clear();
		}).catch(function(error){
			console.log(error);
		});
{'fraction_non_alphanumeric': 0.18584305408271473, 'fraction_numerical': 0.0010604453870625664, 'mean_word_length': 5.056179775280899, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4651860', 'n_tokens_mistral': 1346, 'n_tokens_neox': 1200, 'n_words': 181}