Package: python-copaco-connections
python-copaco-connectionsEasy python integrations for the Copaco Customer ConnectionsPackage useThis package has three main functions:Retrieve the pricelist of CopacoSend orders to CopacoRetrieve order responsesThese three functions will be explained seperately below.You need to requests a connection with Copaco first before you can use this package.
More info here:https://www.copaco.com/en-be/customer-service-e-commerce-fulfillmentGetting startedInstallInstall with pip.pipinstallpython-copaco-connectionsPricelistLimitationsThe pricelist is limited to the Copaco BE - Dutch Productlist in CSV format via FTP. Might be extended in the future.ImportImport the package and the CopacoConnectionBE object.fromcopaco.connectionimportCopacoConnectionBESetup connectionMake the connection with your provided FTP credentials.conn=CopacoConnectionBE(FTP_HOST,FTP_LOGIN,FTP_PASSWD)Retrieve the pricelistYou can retrieve the pricelist as follows:priceList=conn.priceList.get()This will return an ordinary list which contains PriceListItem objects.You can find the attributes of this object and their use below:PriceListItem objectAttributeContainsTypearticleArticle numberstringvendorCodeUnique vendor codestringdescriptionShort descriptionstringpricePrice, excluding leviesfloatpriceWithLeviesPrice, including leviesfloatstockAmount of stock availableintegerhierarchyProduct hierarchystringunspscCodeUNSPSC codestringEANEAN codestringstatusCodeStatus code (0 - 12). Refer to docs.integerstatusHuman-readable statusstringauvibelPrice of AuvibelfloatreprobelPrice of ReprobelfloatrecupelPrice of RecupelfloatbebatPrice of BebatfloatnextDeliveryNext delivery date of this productdatenextDeliveryAmountAmount that will be delivered on next deliveryintegerinventoryStatusCodeATP codestringinventoryStatusHuman-readable ATP codestringSample scriptYou can find a sample script at examples/get-pricelist.pyOrdersLimitationsFields that are not supported at this moment:end-user_informationorderline_inforegistration_infonotificationImportImport the package and the CopacoOrders object.fromcopaco.ordersimportCopacoOrdersSetup connectionMake the connection with your Customer ID and provided Sender ID for orders.orders=CopacoOrders(CUSTOMER_ID,SENDER_ID)Create a new orderBefore creating an order you have to understand that creating an order does not equal sending the order to Copaco for processing.
You need to create the order internally first, and then send the order over to Copaco.orders=CopacoOrders(CUSTOMER_ID,SENDER_ID)order=orders.create(external_document_id,supplier,customer_ordernumber,completedelivery,requested_deliverydate=None,recipientsreference=None)The above function is a simplified function that allows you to create a basic Order object, with no lines attached to it.ParamRequired?TypeFormatRemarksexternal_document_idXstringFree text fieldContains an unique number or token from your systemsupplierXstring'COPACO'/'6010''COPACO' = Copaco NL, '6010' = Copaco BEcustomer_ordernumberXstringFree text fieldContains an unique purchase order number from your systemcompletedeliveryXstring'Y'/'N''Y' = Complete delivery, 'N' = Partial delivery allowedrequested_deliverydatestring'DD-MM-YYYY'Date you would like the order to be deliveredrecipientsreferencestringFree text fieldReference for the goods receiverAttach lines to an existing orderYou can attach lines to an existing order.order.addOrderLine(item_id,tag,quantity,price=None,currency=None,deliverydate=None,textqualifier=None,text=None)ParamRequired?TypeFormatRemarksitem_idXstringFree text fieldContains the part numbertagXstring'PN'/'MF'/'CU''PN' = Supplier part number, 'MF' = Manufacturer part number, 'CU' = Customer part numberquantityXintegerintegerOnly full numbers allowedpricefloatfloatMust match with the price in ERP system or within agreed marginscurrencystring'EUR'At this moment only 'EUR' is allowed, might be extended laterdeliverydatestring'DD-MM-YYYY'Date you would like the line to be delivered. Overrules delivery date on the order.textqualifierstring'0001'/'BID''0001' = Instruction line, 'BID' = Line contains special BIDtextstringFree text fieldIf qualifier '0001' = Free text field, If qualifier 'BID' = Special BID numberSet shipping addressYou can set the shipping address of an order if you would like to ship to another address that is not your default.
If no shipping address is supplied, your default address will be used.order.setShippingAdress(firstname,lastname,street,postalcode,city,country)Country has to be the country code.Send order to CopacoOnce the full order has been created, you can send the order to Copaco for processing.orders=CopacoOrders(CUSTOMER_ID,SENDER_ID)order=orders.create(external_document_id,supplier,customer_ordernumber,completedelivery)orders.sendToCopaco(order)Sample scriptYou can find a sample script at examples/create-order.pyOrder responsesLimitationsNot all fields are supported at this moment. List of unsupported fields is not available at this moment.ImportImport the package and the CopacoOrders object.fromcopaco.ordersimportCopacoOrdersSetup connectionMake the connection with your Customer ID and provided Sender ID for orders.orders=CopacoOrders(CUSTOMER_ID,SENDER_ID)Retrieve responsesCopaco has four different responses.Response typeContainsINTInitial response. Indicates that the order is received.OBVOrder confirmation. Contains information on how the order is processed.FACInvoice in XML format.PAKDispatch advice response. Generated after the goods are picked and ready for shipment.You can retrieve these responses seperately or all at once.orders=CopacoOrders(CUSTOMER_ID,SENDER_ID)intResponses=orders.getResponses(type='INT')obvResponses=orders.getResponses(type='OBV')pakResponses=orders.getResponses(type='PAK')facResponses=orders.getResponses(type='FAC')allResponses=orders.getResponses(type='ALL')Requesting a specific type will return an array that contains objects of the XML returned.
Requesting all types will return a dictionary with the following format:{'INT':[intResponses],'OBV':[obvResponses],'FAC':[facResponses],'PAK':[pakResponses]}StructureThe structure of these responses are the same as the XML that is returned, and thus is defined by Copaco.
Be aware that there are a lot of inconsistencies in the XML format: camelCase, snake_case, PascalCase are all used.Refer to the XML documentation to know the structure.Sample scriptYou can find example responses for each type at examples/xml-responsesYou can find a sample script for each response at examples/get-response-XXX.py where XXX is the type.