From: Jan Büren <jan@kivitendo.de>
Date: Mon, 8 Nov 2021 09:00:16 +0000 (+0100)
Subject: Shop: Base Class get_one_order etwas ausführlicher dokumentiert
X-Git-Tag: kivitendo-mebil_0.1-0~10^2~2^2~218^2~35
X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=98d0f52efec9515aed3dc8efa39b3e5683400d02;p=kivitendo-erp.git

Shop: Base Class get_one_order etwas ausführlicher dokumentiert
---

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<get_one_order>
+=item C<get_one_order $ordnumber>
+
+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<get_new_orders>
 
@@ -73,6 +105,11 @@ the same data structure. Details of the returning hashref:
 
 =item C<set_orderstatus>
 
+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