Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision a3329b6b

Von Kivitendo Admin vor etwa 7 Jahren hinzugefügt

  • ID a3329b6b00c6c57ce0a50a688afb02b0bdfec6f7
  • Vorgänger 9f211141
  • Nachfolger 6cfaac93

Shopmodul: Shop Connecters ALL, Base and XTCommerce

Shop - 1. Version Shopware Connector

Conflicts:
SL/ShopConnector/Shopware.pm

Unterschiede anzeigen:

SL/ShopConnector/ALL.pm
1
package SL::ShopConnector::ALL;
2

  
3
use strict;
4
use SL::ShopConnector::XTCommerce;
5
use SL::ShopConnector::Shopware;
6
# use SL::ShopConnector::ideal;
7

  
8
my %shop_connector_by_name = (
9
  xtcommerce  => 'SL::ShopConnector::XTCommerce',
10
  shopware    => 'SL::ShopConnector::Shopware',
11
  ideal       => 'SL::ShopConnector::IDeal',
12
);
13

  
14
my %shop_connector_by_connector = (
15
  xtcommerce => 'SL::ShopConnector::XTCommerce',
16
  shopware   => 'SL::ShopConnector::Shopware',
17
  ideal      => 'SL::ShopConnector::IDeal',
18
);
19

  
20
my @shop_connector_order = qw(
21
  xtcommerce
22
  shopware
23
  ideal
24
);
25

  
26
sub all_enabled_shop_connectors {
27
  my %disabled = map { $_ => 1 } @{ $::instance_conf->get_disabled_shop_connectors || [] };
28

  
29
  map { $shop_connector_by_name{$_} } grep { !$disabled{$_} } @shop_connector_order;
30
}
31

  
32
sub all_shop_connectors {
33
  map { $shop_connector_by_name{$_} } @shop_connector_order;
34
}
35

  
36
sub shop_connector_class_by_name {
37
  $shop_connector_by_name{$_[1]};
38
}
39

  
40
sub shop_connector_class_by_connector {
41
  $shop_connector_by_connector{$_[1]};
42
}
43

  
44
1;
SL/ShopConnector/Base.pm
1
package SL::ShopConnector::Base;
2

  
3
use strict;
4

  
5
use parent qw(SL::DB::Object);
6
use Rose::Object::MakeMethods::Generic (
7
  scalar => [ qw(config) ],
8
);
9

  
10
sub get_order { die 'get_order needs to be implemented' }
11

  
12
sub get_new_orders { die 'get_order needs to be implemented' }
13

  
14
sub update_part { die 'update_part needs to be implemented' }
15

  
16
1;
17

  
18
__END__
19

  
20
=encoding utf-8
21

  
22
=head1 NAME
23

  
24
SL::ShopConnectorBase - this is the base class for shop connectors
25

  
26
=head1 SYNOPSIS
27

  
28

  
29
=head1 DESCRIPTION
30

  
31
=head1 AVAILABLE METHODS
32

  
33
=over 4
34

  
35
=item C<get_order>
36

  
37
=item C<get_orders>
38

  
39
=item C<update_part>
40

  
41
=back
42

  
43
=head1 SEE ALSO
44

  
45
L<SL::ShopConnector::ALL>
46

  
47
=head1 BUGS
48

  
49
None yet. :)
50

  
51
=head1 AUTHOR
52

  
53
G. Richardson <lt>information@kivitendo-premium.deE<gt>
54

  
55
=cut
SL/ShopConnector/XTCommerce.pm
1
package SL::ShopConnector::XTCommerce;
2

  
3
use strict;
4

  
5
use parent qw(SL::ShopConnector::Base);
6

  
7
use LWP::UserAgent;     
8
use LWP::Authen::Digest;
9
use Data::Dumper;
10

  
11
use Rose::Object::MakeMethods::Generic (
12
  'scalar --get_set_init' => [ qw(connector url) ],
13
);
14

  
15
sub get_order {
16
  my ($self, $id) = @_;
17
   
18
  my $url = $self->url;
19
  my $data = $self->connector->get("$url/order/$id");
20
  my $data_json = $data->content;
21
  my $import = SL::JSON::decode_json($data_json);
22

  
23
# need to check return here, only return well defined data
24

  
25
  return $import;
26

  
27
  # printf("loading %s:%s\n", $self->config->url, $self->config->port);
28
};
29

  
30
sub get_new_orders {
31
  my ($self) = @_;
32
   
33
  my $url = $self->url;
34
  my $data = $self->connector->get("$url/orders");
35
  my $data_json = $data->content;
36
  my $orders = SL::JSON::decode_json($data_json);
37

  
38
# need to check return here, only return well defined data
39

  
40
  return $orders;
41

  
42
  # printf("loading %s:%s\n", $self->config->url, $self->config->port);
43
};
44

  
45
sub update_part {
46
  my ($self, $part) = @_;
47

  
48
  my $url = $self->url;
49
  my $partnumber = $part->partnumber;
50
  my $data = $self->connector->get("$url/part/$partnumber");
51

  
52
};
53

  
54
sub init_url {
55
  my ($self) = @_;
56
  # TODO: validate url and port
57
  $self->url($self->config->url . ":" . $self->config->port);
58
};
59
  
60
sub init_connector {
61
  my ($self) = @_;
62
  my $ua = LWP::UserAgent->new;          
63
  $ua->credentials(                      
64
      $self->url,
65
      "XT Commerce SOAP 2.0",                
66
      "user" => "sdfsdfsdfsdfasdfsdf"     
67
      );                                     
68
  return $ua;                            
69
};
70

  
71
1;
72

  
73
__END__
74

  
75
=encoding utf-8
76

  
77
=head1 NAME
78

  
79
SL::ShopConnecter::XTCommerce - connector for XTCommerce with SOAP2.0 plugin
80

  
81
=head1 SYNOPSIS
82

  
83
=head1 DESCRIPTION
84

  
85
=head1 BUGS
86

  
87
None yet. :)
88

  
89
=head1 AUTHOR
90

  
91
=cut

Auch abrufbar als: Unified diff