Open ERP interface for Interchange · Shop Administration ERP Connect XMLRPC API Conclusion Open...

Post on 21-Jan-2020

4 views 0 download

Transcript of Open ERP interface for Interchange · Shop Administration ERP Connect XMLRPC API Conclusion Open...

Shop AdministrationERP ConnectXMLRPC API

Conclusion

Open ERP interface for Interchange

Stefan Hornburg (Racke)racke@linuxia.de

eCommerce Innovation 2013, Hancock NY, 10sth October 2013

racke Open ERP interface for Interchange

Shop AdministrationERP ConnectXMLRPC API

Conclusion

Shop Administration

I Admin

I ERP

racke Open ERP interface for Interchange

Shop AdministrationERP ConnectXMLRPC API

Conclusion

ERP Solutions

I Medical Business SolutionsNavision

I WegatradeLewia

I CalevoImpuls

racke Open ERP interface for Interchange

Shop AdministrationERP ConnectXMLRPC API

Conclusion

ERP Solutions

I Dataident

I AdvanceID

racke Open ERP interface for Interchange

Shop AdministrationERP ConnectXMLRPC API

Conclusion

OpenERP

I Ecoservice Interchange ERP Connect

I XMLRPC API for Interchange

racke Open ERP interface for Interchange

Shop AdministrationERP ConnectXMLRPC API

Conclusion

ExportImport

Export

I Categories

I Products and Inventory

I Product images

I Price lists

I Partners

racke Open ERP interface for Interchange

Shop AdministrationERP ConnectXMLRPC API

Conclusion

ExportImport

Import

I Orders

racke Open ERP interface for Interchange

Shop AdministrationERP ConnectXMLRPC API

Conclusion

WorkflowRPC::XMLDispatchFunctions and Mapping

XMLRPC API

I Magento API http://www.magentocommerce.com/wiki/doc/webservices-api/api/

I Dancer

I Nitesi Database Schemahttps://metacpan.org/module/Nitesi::Database::Schema

I RPC::XML

racke Open ERP interface for Interchange

Shop AdministrationERP ConnectXMLRPC API

Conclusion

WorkflowRPC::XMLDispatchFunctions and Mapping

Workflow

I Create instance of RPC::XML::Server

I Add functions for our API

I Dispatch requests

I Mapping values

I Return result

racke Open ERP interface for Interchange

Shop AdministrationERP ConnectXMLRPC API

Conclusion

WorkflowRPC::XMLDispatchFunctions and Mapping

RPC::XML

use RPC: : XML qw / : types / ;use RPC: : XML : : Server ;

# fo rce encoding to UTF−8$RPC : : XML : : ENCODING = ’ u t f−8 ’ ;

racke Open ERP interface for Interchange

Shop AdministrationERP ConnectXMLRPC API

Conclusion

WorkflowRPC::XMLDispatchFunctions and Mapping

RPC::XML::Server Object

my %f a u l t _ t a b l e = (2 => [2 => ’%s ’ ] ,100 => [100 => ’%s ’ ] ,. .107 => [107 => ’%s ’ ] ,

) ;

$rpc = RPC: : XML : : Server−>new( no_ht tp => 1 ,f a u l t _ t a b l e => \% f a u l t _ t a b l e ) ;

# l o g i n f u n c t i o n$rpc−>add_funct ion ( { name => ’ l o g i n ’ , code => \& l o g i n } ) ;

racke Open ERP interface for Interchange

Shop AdministrationERP ConnectXMLRPC API

Conclusion

WorkflowRPC::XMLDispatchFunctions and Mapping

RPC_STRING

sub l o g i n {my ( @args ) = @_;my ( $sess ion_id ) ;

i f ( account−>l o g i n ( username => $args [ 0 ] ,password => $args [ 1 ] ) ) {

$sess ion_id = session−>i d ;return RPC_STRING( $sess ion_id ) ;

}else {

return $rpc−>s e r v e r _ f a u l t (2 , ’ Access denied ’ ) ;}

}

racke Open ERP interface for Interchange

Shop AdministrationERP ConnectXMLRPC API

Conclusion

WorkflowRPC::XMLDispatchFunctions and Mapping

Dispatch

p r e f i x ’ / ap i / rpc /0 .001 ’ ;

any ’ / ’ => sub {$xml = request−>body ;$rpc | | = setup ( ) ;

eval {$resp = $rpc−>d ispatch ( $xml ) ;

} ;

. . .

racke Open ERP interface for Interchange

Shop AdministrationERP ConnectXMLRPC API

Conclusion

WorkflowRPC::XMLDispatchFunctions and Mapping

Dispatch

. . .

i f ( $resp && $resp−>i s _ f a u l t ) {content_type ’ t e x t / xml ’ ;return $resp−>as_s t r i ng ;

}i f ( re f ( $resp ) ) {

return $resp−>as_s t r i ng ;}return $@;s ta tus 400;

}

racke Open ERP interface for Interchange

Shop AdministrationERP ConnectXMLRPC API

Conclusion

WorkflowRPC::XMLDispatchFunctions and Mapping

Functions

I 51 functions

I product.list

I product.info

I product.create

I product.update

I product.delete

racke Open ERP interface for Interchange

Shop AdministrationERP ConnectXMLRPC API

Conclusion

WorkflowRPC::XMLDispatchFunctions and Mapping

Session Wrapper

sub a p i _ c a l l {my $api_sub = s h i f t ;

return sub {my ( $session_id , @args ) = @_;

i f ( session_check ( $sess ion_id ) ) {return $api_sub−>(@args ) ;

} ;

return $rpc−>s e r v e r _ f a u l t (2 , ’ Access denied ’ ) ;} ;

}

racke Open ERP interface for Interchange

Shop AdministrationERP ConnectXMLRPC API

Conclusion

WorkflowRPC::XMLDispatchFunctions and Mapping

Create Category

sub category_create {my ( $parent , $data ) = @_;my ( $cat , %inpu t ) ;

%inpu t = _reverse_map ( ’ category ’ , $data ) ;

i f ( $parent ) {$ inpu t { parent } = $parent ;

}

$cat = shop_navigat ion−>create(% inpu t ) ;

return $cat−>code ;}

racke Open ERP interface for Interchange

Shop AdministrationERP ConnectXMLRPC API

Conclusion

WorkflowRPC::XMLDispatchFunctions and Mapping

Update Category

sub category_update {my ( $code , $data ) = @_;my (%args ) ;

unless ( shop_navigat ion ( $code)−>load ) {return $rpc−>s e r v e r _ f a u l t (102 , ’ Category not e x i s t s ’ ) ;

}

%args = _reverse_map ( ’ category ’ , $data ) ;

my $p = shop_navigat ion ( $code)−>update(%args ) ;

return $p−>code ;}

racke Open ERP interface for Interchange

Shop AdministrationERP ConnectXMLRPC API

Conclusion

WorkflowRPC::XMLDispatchFunctions and Mapping

Mapping

category => { code => ’ ca tegory_ id ’ ,parent => ’ paren t_ id ’ ,u r i => ’ u r l _pa th ’ ,scope => undef ,p r i o r i t y => undef ,type => undef ,l e v e l => ’ l e v e l ’ ,entered => ’ created_at ’ ,i n a c t i v e => {name => ’ i s _ a c t i v e ’ ,

f i l t e r => ’ i n v e r t ’ ,} ,’ ’ => [qw / ava i l ab le_so r t_by de fau l t _so r t _by

include_in_menu / ] ,} ,

racke Open ERP interface for Interchange

Shop AdministrationERP ConnectXMLRPC API

Conclusion

Experiences

I Works

I Stable

I RPC::XML needs some love

racke Open ERP interface for Interchange

Shop AdministrationERP ConnectXMLRPC API

Conclusion

Moving to OpenERP

Falk Neubertecoservicewww.ecoservice.de

racke Open ERP interface for Interchange

Shop AdministrationERP ConnectXMLRPC API

Conclusion

The End

Slides: http://www.linuxia.de/talks/eic2013/nitesi-api-beamer.pdf

racke Open ERP interface for Interchange