TT#154550 API topuplogs - expand fields

* The next fields are expanded: package_after_id, package_before_id, profile_after_id, profile_before_id, contract_id, contract_balance_after_id, contract_balance_before_id, subscriber_idvoucher_id.

Change-Id: I4d5f12fb88eaaeb8daf45e673c14e92c1512e239
mr10.4
Oleksandr Duts 3 years ago
parent a15445fbe4
commit ace1698a3d

@ -98,4 +98,74 @@ has_field 'subscriber_id' => (
},
);
has_field 'package_after_id' => (
type => 'PosInteger',
element_attr => {
expand => {
class => 'NGCP::Panel::Role::API::ProfilePackages',
allowed_roles => [qw(admin reseller)],
},
},
);
has_field 'package_before_id' => (
type => 'PosInteger',
element_attr => {
expand => {
class => 'NGCP::Panel::Role::API::ProfilePackages',
allowed_roles => [qw(admin reseller)],
},
},
);
has_field 'profile_after_id' => (
type => 'PosInteger',
element_attr => {
expand => {
class => 'NGCP::Panel::Role::API::SubscriberProfiles',
allowed_roles => [qw(admin reseller ccareadmin ccare subscriberadmin subscriber)],
},
},
);
has_field 'profile_before_id' => (
type => 'PosInteger',
element_attr => {
expand => {
class => 'NGCP::Panel::Role::API::SubscriberProfiles',
allowed_roles => [qw(admin reseller ccareadmin ccare subscriberadmin subscriber)],
},
},
);
has_field 'contract_balance_after_id' => (
type => 'PosInteger',
element_attr => {
expand => {
class => 'NGCP::Panel::Role::API::CustomerBalances',
allowed_roles => [qw(admin reseller ccareadmin ccare)],
},
},
);
has_field 'contract_balance_before_id' => (
type => 'PosInteger',
element_attr => {
expand => {
class => 'NGCP::Panel::Role::API::CustomerBalances',
allowed_roles => [qw(admin reseller ccareadmin ccare)],
},
},
);
has_field 'voucher_id' => (
type => 'PosInteger',
element_attr => {
expand => {
class => 'NGCP::Panel::Role::API::Vouchers',
allowed_roles => [qw(admin reseller)],
},
},
);
1;

@ -74,6 +74,16 @@ sub hal_from_item {
return $hal;
}
sub resource_from_item {
my($self, $c, $item) = @_;
if (ref $item eq 'HASH') {
return $item;
}
return { $item->to_hash };
}
sub item_by_id {
my ($self, $c, $id) = @_;
my $item_rs = $self->item_rs($c);

@ -1005,13 +1005,17 @@ sub update_preferences {
my $prov_subscriber = $params{prov_subscriber};
my $preferences = $params{preferences};
foreach my $k(keys %{ $preferences } ) {
foreach my $k (keys %{ $preferences } ) {
my $pref = NGCP::Panel::Utils::Preferences::get_usr_preference_rs(
c => $c, attribute => $k, prov_subscriber => $prov_subscriber);
if($pref->first && $pref->first->attribute->max_occur == 1) {
unless(defined $preferences->{$k}) {
$pref->first->delete;
} else {
# # contract_sound_set
# if ($k eq 'contract_sound_set') {
# next if $pref->first->value;
# }
$pref->first->update({
'value' => $preferences->{$k},
});

Loading…
Cancel
Save