TT#7453 Add readonly time fields to the customers api

Change-Id: I46e2c5d6def84b2cb5bab99d15838671274ce44b
changes/06/10506/6
Irina Peshinskaya 8 years ago
parent 99ee7da751
commit 63958c3edb

@ -110,4 +110,44 @@ has_field 'add_vat' => (
default => 0,
);
has_field 'create_timestamp' => (
type => '+NGCP::Panel::Field::DateTime',
required => 0,
readonly => 1,
element_attr => {
rel => ['tooltip'],
title => ['Readonly. The datetime (YYYY-MM-DD HH:mm:ss) of the creation.']
},
);
has_field 'activate_timestamp' => (
type => '+NGCP::Panel::Field::DateTime',
required => 0,
readonly => 1,
element_attr => {
rel => ['tooltip'],
title => ['Readonly. The datetime (YYYY-MM-DD HH:mm:ss) of the activation.']
},
);
has_field 'modify_timestamp' => (
type => '+NGCP::Panel::Field::DateTime',
required => 0,
readonly => 1,
element_attr => {
rel => ['tooltip'],
title => ['Readonly. The datetime (YYYY-MM-DD HH:mm:ss) of the modification.']
},
);
has_field 'terminate_timestamp' => (
type => '+NGCP::Panel::Field::DateTime',
required => 0,
readonly => 1,
element_attr => {
rel => ['tooltip'],
title => ['Readonly. The datetime (YYYY-MM-DD HH:mm:ss) of the termination.']
},
);
1;

@ -119,6 +119,9 @@ sub hal_from_customer {
exceptions => [ "contact_id", "billing_profile_id", "profile_package_id", "invoice_template_id", "invoice_email_template_id", "passreset_email_template_id", "subscriber_email_template_id" ],
);
foreach my $field (qw/create_timestamp activate_timestamp modify_timestamp terminate_timestamp/){
$resource{$field} = defined $resource{$field} ? NGCP::Panel::Utils::DateTime::to_string(NGCP::Panel::Utils::DateTime::from_string($resource{$field})) : undef ;
}
# return the virtual "type" instead of the actual product id
$resource{type} = $billing_mapping->product->class;
$resource{billing_profiles} = $future_billing_profiles;

@ -39,19 +39,22 @@ SKIP:{
my $invoicetemplate = $test_machine->get_item_hal('invoicetemplates','/api/invoicetemplates/?name=api_test');
if(!$invoicetemplate->{total_count} ){
skip("Testing requires at least one present callforward. No creation is available.",1);
skip("Testing requires at least one present invoice template with name "api_test". No creation is available.",1);
}
$fake_data->data->{customers}->{data}->{invoice_template_id} = $invoicetemplate->{content}->{id};
#for item creation test purposes /post request data/
$test_machine->DATA_ITEM_STORE($fake_data->process('customers'));
$test_machine->form_data_item( );
# create 3 new sound sets from DATA_ITEM
# create new customer from DATA_ITEM
my $customer = $test_machine->check_create_correct( 1, sub{ $_[0]->{external_id} .= $_[1]->{i}; } )->[0];
is($customer->{content}->{invoice_template_id}, $invoicetemplate->{content}->{id}, "Check invoice template id of the created customer.");
for my $template_id (qw/subscriber_email_template_id passreset_email_template_id invoice_email_template_id/){
is($customer->{content}->{$template_id}, $test_machine->DATA_ITEM->{$template_id}, "Check $template_id of the created customer.");
}
#modify_timestamp - differs exactly because of the put.
#todo: create_timestamp - strange, it is different to the value of the time zone
$test_machine->check_get2put({ignore_fields => [qw/modify_timestamp create_timestamp/]});
$test_machine->check_bundle();
}

@ -1079,6 +1079,8 @@ sub check_get2put{
$get_in //= {};
$put_in //= {};
$get_in->{ignore_fields} //= [];
$put_in->{ignore_fields} //= [];
$get_in->{uri} //= $put_in->{uri};
$put_in->{uri} //= $get_in->{uri};
@ -1089,6 +1091,10 @@ sub check_get2put{
# check if put is ok
(defined $put_in->{data_cb}) and $put_in->{data_cb}->($put_out->{content_in});
@{$put_out}{qw/response content request/} = $self->request_put( $put_out->{content_in}, $put_in->{uri} );
foreach my $field (@{$get_in->{ignore_fields}}, @{$put_in->{ignore_fields}}){
delete $get_out->{content}->{$field};
delete $put_out->{content}->{$field};
}
$self->http_code_msg(200, "check_get2put: check put successful", $put_out->{response}, $put_out->{content} );
is_deeply($get_out->{content}, $put_out->{content}, "$self->{name}: check_get2put: check put if unmodified put returns the same");
return ($put_out,$get_out);

Loading…
Cancel
Save