From fc4bdaf75052ca2edc0aa04ef687f8abaaf93068 Mon Sep 17 00:00:00 2001 From: Gerhard Jungwirth Date: Wed, 9 Jul 2014 09:41:56 +0200 Subject: [PATCH] MT#7959 update contracts api doc --- lib/NGCP/Panel/Controller/API/BillingFees.pm | 2 +- lib/NGCP/Panel/Controller/API/Contracts.pm | 14 ++++------ .../Panel/Form/Contract/PeeringResellerAPI.pm | 26 +++++++++++++++++++ lib/NGCP/Panel/Role/API/Contracts.pm | 4 +-- 4 files changed, 34 insertions(+), 12 deletions(-) create mode 100644 lib/NGCP/Panel/Form/Contract/PeeringResellerAPI.pm diff --git a/lib/NGCP/Panel/Controller/API/BillingFees.pm b/lib/NGCP/Panel/Controller/API/BillingFees.pm index e291418edd..00a89924c3 100644 --- a/lib/NGCP/Panel/Controller/API/BillingFees.pm +++ b/lib/NGCP/Panel/Controller/API/BillingFees.pm @@ -20,7 +20,7 @@ class_has 'api_description' => ( is => 'ro', isa => 'Str', default => - 'Specifies the fees to be applied for a call if it matches the source or destination number of the call. You can POST fees individually one-by-one using json. To bulk-upload fees, specify the Content-Type as "text/csv" and POST the CSV in the request body to the collection while specifying the the billing profile via URI parameters, like "/api/billingfees/?billing_profile_id=xx&purge_existing=true"' + 'Specifies the fees to be applied for a call if it matches the source or destination number of the call. You can POST fees individually one-by-one using json. To bulk-upload fees, specify the Content-Type as "text/csv" and POST the CSV in the request body to the collection while specifying the the billing profile via URI parameters, like "/api/billingfees/?billing_profile_id=xx&purge_existing=true"' ); class_has 'query_params' => ( diff --git a/lib/NGCP/Panel/Controller/API/Contracts.pm b/lib/NGCP/Panel/Controller/API/Contracts.pm index 3603a05c42..5ea23cde1e 100644 --- a/lib/NGCP/Panel/Controller/API/Contracts.pm +++ b/lib/NGCP/Panel/Controller/API/Contracts.pm @@ -20,7 +20,7 @@ class_has 'api_description' => ( is => 'ro', isa => 'Str', default => - 'Defines a billing container for peerings and resellers. A Billing Profile is assigned to a contract, and it has Contract Balances indicating the saldo of the contract for current and past billing intervals.' + 'Defines a billing container for peerings and resellers. A Billing Profile is assigned to a contract, and it has Contract Balances indicating the saldo of the contract for current and past billing intervals.', ); class_has 'query_params' => ( @@ -67,7 +67,7 @@ __PACKAGE__->config( Does => [qw(ACL CheckTrailingSlash RequireSSL)], Method => $_, Path => __PACKAGE__->dispatch_path, - } } @{ __PACKAGE__->allowed_methods } + } } @{ __PACKAGE__->allowed_methods }, }, action_roles => [qw(HTTPMethods)], ); @@ -77,6 +77,7 @@ sub auto :Private { $self->set_body($c); $self->log_request($c); + return 1; } sub GET :Allow { @@ -159,13 +160,6 @@ sub POST :Allow { ); last unless $resource; - # TODO: check type - my $product_class = delete $resource->{type}; - unless($product_class eq "sippeering" || $product_class eq "reseller") { - $self->error($c, HTTP_UNPROCESSABLE_ENTITY, "Invalid 'type', must be 'sippeering' or 'reseller'."); - last; - } - unless(defined $resource->{billing_profile_id}) { $self->error($c, HTTP_UNPROCESSABLE_ENTITY, "Invalid 'billing_profile_id', not defined."); last; @@ -191,6 +185,7 @@ sub POST :Allow { $self->error($c, HTTP_UNPROCESSABLE_ENTITY, "Invalid 'billing_profile_id'."); last; } + my $product_class = delete $resource->{type}; my $product = $schema->resultset('products')->find({ class => $product_class }); unless($product) { $self->error($c, HTTP_UNPROCESSABLE_ENTITY, "Invalid 'type'."); @@ -238,6 +233,7 @@ sub end : Private { my ($self, $c) = @_; $self->log_response($c); + return; } # vim: set tabstop=4 expandtab: diff --git a/lib/NGCP/Panel/Form/Contract/PeeringResellerAPI.pm b/lib/NGCP/Panel/Form/Contract/PeeringResellerAPI.pm new file mode 100644 index 0000000000..c31f8a1f8f --- /dev/null +++ b/lib/NGCP/Panel/Form/Contract/PeeringResellerAPI.pm @@ -0,0 +1,26 @@ +package NGCP::Panel::Form::Contract::PeeringResellerAPI; + +use HTML::FormHandler::Moose; +extends 'NGCP::Panel::Form::Contract::PeeringReseller'; + +has_field 'type' => ( + type => 'Select', + options => [ + { value => 'sippeering', label => 'Peering'}, + { value => 'reseller', label => 'Reseller'}, + ], + required => 1, + element_attr => { + rel => ['tooltip'], + title => ['Either "sippeering" or "reseller".'] + }, +); + +has_block 'fields' => ( + tag => 'div', + class => [qw/modal-body/], + render_list => [qw/contact billing_profile status external_id type/], +); + +1; +# vim: set tabstop=4 expandtab: diff --git a/lib/NGCP/Panel/Role/API/Contracts.pm b/lib/NGCP/Panel/Role/API/Contracts.pm index fa724e4a67..e40cf3014c 100644 --- a/lib/NGCP/Panel/Role/API/Contracts.pm +++ b/lib/NGCP/Panel/Role/API/Contracts.pm @@ -13,7 +13,7 @@ use Data::HAL::Link qw(); use HTTP::Status qw(:constants); use NGCP::Panel::Utils::DateTime; use NGCP::Panel::Utils::Contract; -use NGCP::Panel::Form::Contract::PeeringReseller qw(); +use NGCP::Panel::Form::Contract::PeeringResellerAPI qw(); sub item_rs { my ($self, $c) = @_; @@ -34,7 +34,7 @@ sub item_rs { sub get_form { my ($self, $c) = @_; - return NGCP::Panel::Form::Contract::PeeringReseller->new; + return NGCP::Panel::Form::Contract::PeeringResellerAPI->new; } sub hal_from_contract {