From 98d0f52efec9515aed3dc8efa39b3e5683400d02 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20B=C3=BCren?= Date: Mon, 8 Nov 2021 10:00:16 +0100 Subject: [PATCH] =?utf8?q?Shop:=20Base=20Class=20get=5Fone=5Forder=20etwas?= =?utf8?q?=20ausf=C3=BChrlicher=20dokumentiert?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/ShopConnector/Base.pm | 41 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/SL/ShopConnector/Base.pm b/SL/ShopConnector/Base.pm index 68c39d15f..cf2f9f636 100644 --- a/SL/ShopConnector/Base.pm +++ b/SL/ShopConnector/Base.pm @@ -7,7 +7,30 @@ use Rose::Object::MakeMethods::Generic ( scalar => [ qw(config) ], ); -sub get_one_order { die 'get_one_order needs to be implemented' } +sub get_one_order { + die 'get_one_order needs to be implemented'; + + my ($self, $ordnumber) = @_; + my %fetched_order; + + # 1. fetch the order and import it as a kivi order + # 2. update the order state for report + # 3. return a hash with either success or error state + my $one_order; # REST call + + my $error = $self->import_data_to_shop_order($one_order); + + $self->set_orderstatus($one_order->{id}, "fetched") unless $error; + + return \( + shop_id => $self->config->id, + shop_description => $self->config->description, + number_of_orders => $error ? 0 : 1, + message => $error ? "Error: $error->{msg}" : '', + error => $error ? 1 : 0, + ); +} + sub get_new_orders { die 'get_order needs to be implemented' } @@ -49,7 +72,16 @@ __END__ =over 4 -=item C +=item C + +Needs a order number and fetch (one or more) orders +which are returned by the Shop system. The function +has to take care of getting the order including customer +and item information to kivi. +It has to return a hash with either the number of succesful +imported order or within the same hash structure a error message. + + =item C @@ -73,6 +105,11 @@ the same data structure. Details of the returning hashref: =item C +Sets the state of the order in the Shop. +Valid values are dependant on the Shop API, common states +are delivered, fetched, paid, in progress ... + + =back =head1 SEE ALSO -- 2.20.1