MT#62578 Migrate api v1 to v2 for subscriber phonebook

- Add include option for customers to display the shared phonebook

Change-Id: Id14f95e159e1719d7aa6a0168e724ca7db3b8497
master
nidrissi-zouggari 3 months ago committed by Nouhaila Idrissi-Zouggari
parent ee99017a28
commit ec97299ed7

@ -773,20 +773,8 @@ export async function getSubscriberRegistrations (options) {
return list
}
export async function getSubscriberPhonebook (options) {
let all = false
if (options.rows === 0) {
delete options.rows
delete options.page
all = true
}
if (!options.order_by) {
delete options.order_by
delete options.order_by_direction
}
options.include = 'all'
const list = await getList({
resource: 'subscriberphonebookentries',
all,
const list = await get({
path: `api/v2/subscribers/${options.subscriber_id}/phonebook`,
params: options
})
return list
@ -813,9 +801,10 @@ export async function createPhonebook (data) {
const payLoad = {
name: data.name,
number: data.number,
shared: data.shared
shared: data.shared,
subscriber_id: Number(data.subscriber_id)
}
return await httpApi.post('api/subscriberphonebookentries/', payLoad)
return await httpApi.post(`api/v2/subscribers/${data.subscriber_id}/phonebook`, payLoad)
}
export async function createCustomerPhonebook (data) {
const payLoad = {

@ -241,6 +241,7 @@ export default {
rows: rowsPerPage,
order_by: sortBy,
order_by_direction: descending ? 'desc' : 'asc',
include: 'customer',
subscriber_id: this.getSubscriberId
})
this.pagination = { ...props.pagination }
@ -272,7 +273,10 @@ export default {
cancel: true,
persistent: true
}).onOk(async (data) => {
await this.removeSubscriberPhonebook(row)
await this.removeSubscriberPhonebook({
row,
subscriberId: this.getSubscriberId
})
await this.refresh()
})
},
@ -320,6 +324,7 @@ export default {
rows: this.pagination.rowsPerPage,
order_by: this.pagination.sortBy,
order_by_direction: this.pagination.descending ? 'desc' : 'asc',
include: 'customer',
subscriber_id: this.getSubscriberId
})
}

@ -107,7 +107,8 @@ export default {
},
computed: {
...mapGetters('user', [
'prefilledNumber'
'prefilledNumber',
'getSubscriberId'
]),
nameErrorMessage () {
const errorsTab = this.v$.formData.name.$errors
@ -158,6 +159,7 @@ export default {
},
async confirm () {
try {
this.formData.subscriber_id = this.getSubscriberId
await this.createPhonebookSubscriber(this.formData)
await this.$router.push('/user/subscriber-phonebook/')
} catch (error) {

@ -75,6 +75,7 @@
<script>
import CscPageSticky from 'components/CscPageSticky'
import { mapWaitingActions } from 'vue-wait-vue3'
import { mapGetters } from 'vuex'
export default {
name: 'CscPageSubscriberPhonebookDetails',
components: {
@ -92,6 +93,11 @@ export default {
async mounted () {
await this.getPhonebook(this.id)
},
computed: {
...mapGetters('user', [
'getSubscriberId'
])
},
methods: {
...mapWaitingActions('user', {
getPhonebookDetails: 'getPhonebookDetails',
@ -100,7 +106,7 @@ export default {
getValueNumber: 'getValueNumber'
}),
async getPhonebook (id) {
const response = await this.getPhonebookDetails(id)
const response = await this.getPhonebookDetails({ phonebookId: id, subscriberId: this.getSubscriberId })
this.name = response.data.name
this.number = response.data.number
this.shared = response.data.shared

@ -571,7 +571,7 @@ export default {
const list = await getSubscriberPhonebook({
...options
})
commit('setSubscriberPhonebook', list.items)
commit('setSubscriberPhonebook', list.data)
return list.totalCount
} catch (err) {
commit('setSubscriberPhonebook', [])
@ -611,8 +611,8 @@ export default {
async removeSubscriberRegistration (context, row) {
await httpApi.delete(`api/subscriberregistrations/${row.id}`)
},
async removeSubscriberPhonebook (context, row) {
await httpApi.delete(`api/subscriberphonebookentries/${row.id}`)
async removeSubscriberPhonebook (context, { row, subscriberId }) {
await httpApi.delete(`api/v2/subscribers/${subscriberId}/phonebook/${row.id}`)
},
async removeCustomerPhonebook (context, row) {
await httpApi.delete(`api/customerphonebookentries/${row.id}`)
@ -652,8 +652,8 @@ export default {
async setNcosLevelsSubscriber (value) {
await setPreference(getSubscriberId(), 'ncos', value)
},
async getPhonebookDetails (context, id) {
const list = await httpApi.get(`api/subscriberphonebookentries/${id}`)
async getPhonebookDetails (context, { phonebookId, subscriberId }) {
const list = await httpApi.get(`api/v2/subscribers/${subscriberId}/phonebook/${phonebookId}`)
return list
},
async getPhonebookCustomerDetails (context, id) {

Loading…
Cancel
Save