This repository has been archived by the owner on Dec 23, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(bulk): add bulk for phone function keys
- Loading branch information
Jérémy DE CESARE
committed
Feb 12, 2018
1 parent
fc937f6
commit ccf4b73
Showing
5 changed files
with
217 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...om/voip/feature/line/line/phone/function/voip-feature-line-line-phone-function.factory.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* @ngdoc object | ||
* @name managerApp.object:VoipLinePhoneFunction | ||
* | ||
* @description | ||
* <p>Factory that describes a function key of a phone of a service with sip or mgcp feature type | ||
* with attributes returned by `/telephony/{billingAccount}/line/{serviceName}/phone/functionKey/{keyNum}` API.</p> | ||
* | ||
* @constructor | ||
* @param {Object} options Options required for creating a new instance of VoipLinePhoneFunction | ||
* (see {@link https://eu.api.ovh.com/console/#/telephony/%7BbillingAccount%7D/line/%7BserviceName%7D/phone/functionKey/%7BkeyNum%7D#GET `telephony.Phone.FunctionKey` enum} | ||
* for available options properties). | ||
* | ||
* Note that `billingAccount` and `serviceName` options are mandatory. | ||
*/ | ||
angular.module("managerApp").factory("VoipLinePhoneFunction", function () { | ||
"use strict"; | ||
|
||
const mandatoryOptions = ["billingAccount", "serviceName"]; | ||
|
||
class VoipLinePhoneFunction { | ||
constructor (options = {}) { | ||
// check for mandatory options | ||
mandatoryOptions.forEach((option) => { | ||
if (!options[option]) { | ||
throw new Error(`${option} option must be specified when creating a new VoipLinePhone`); | ||
} | ||
}); | ||
|
||
this.billingAccount = options.billingAccount; | ||
this.serviceName = options.serviceName; | ||
|
||
this.setOptions(options); | ||
} | ||
|
||
/** | ||
* @ngdoc method | ||
* @name managerApp.object:VoipLinePhoneFunction#setOptions | ||
* @propertyOf managerApp.object:VoipLinePhoneFunction | ||
* | ||
* @description | ||
* Set the options from `telephony.Phone.Function` enum. This is called by default by the constructor. | ||
* | ||
* @param {Object} options Optional options for creating a new instance of VoipLinePhoneFunction. | ||
* | ||
* @return {VoipLinePhoneFunction} The `VoipLinePhoneFunction` instance with options setted. | ||
*/ | ||
setOptions (options) { | ||
this.parameter = options.parameter; | ||
this.function = options.function; | ||
this.label = options.label; | ||
this.default = options.default; | ||
this.type = options.type; | ||
this.keyNum = options.keyNum; | ||
this.availableFunctions = options.availableFunctions || []; | ||
} | ||
} | ||
|
||
return VoipLinePhoneFunction; | ||
}); |
41 changes: 41 additions & 0 deletions
41
...om/voip/feature/line/line/phone/function/voip-feature-line-line-phone-function.service.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* @ngdoc service | ||
* @name managerApp.service:voipLinePhoneFunction | ||
* | ||
* @description | ||
* <p>Service that manage function keys of phone linked to sip and mgcp features of services with serviceType line.</p> | ||
* <p>This service will manage API calls to `/telephony/{billingAccount}/line/{serviceName}/phone/functionKey/{keyNum}`</p> | ||
*/ | ||
angular.module("managerApp").service("voipLinePhoneFunction", class { | ||
|
||
constructor ($q, OvhApiTelephony, VoipLinePhoneFunction) { | ||
this.$q = $q; | ||
this.OvhApiTelephony = OvhApiTelephony; | ||
this.VoipLinePhoneFunction = VoipLinePhoneFunction; | ||
} | ||
|
||
/** | ||
* @ngdoc method | ||
* @name managerApp.service:voipLinePhoneFunction#fetchAll | ||
* @methodOf managerApp.service:voipLinePhoneFunction | ||
* | ||
* @description | ||
* Fetch all function keys of all phone of all services of serviceType line with featureType sip or mgcp from any billingAccount. This use APIv7 with wildcard and aggregation to achieve it. | ||
* | ||
* @return {Promise} That return an array of VoipLinePhoneFunction instances. | ||
*/ | ||
fetchAll () { | ||
return this.OvhApiTelephony.Line().Phone().FunctionKey().Erika().query().aggregate("billingAccount").aggregate("serviceName").aggregate("keyNum").expand().execute().$promise.then((phoneResults) => | ||
phoneResults.map((phone) => { | ||
let splittedPath = phone.path.split("/"); | ||
|
||
let functionKeysOptions = angular.extend(phone.value, { | ||
billingAccount: splittedPath[2], | ||
serviceName: splittedPath[4] | ||
}); | ||
|
||
return new this.VoipLinePhoneFunction(functionKeysOptions); | ||
}) | ||
); | ||
} | ||
}); |