API

FnapyManager

class fnapy_manager.FnapyManager(connection)

A class to manage the different services provided by the FNAC API

authenticate()

Authenticate to the FNAC API and return a token

Usage:

token = manager.authenticate()
Returns:token
Return type:str
delete_offers(offer_references)

Delete the offers with the given offer_references (sku)

Usage:

response = manager.delete_offers(offer_references)
Parameters:offer_references – the list of SKUs corresponding to the offers you want to delete from your catalog
Returns:Response object
get_batch_status(batch_id=None)

Return the status for the given batch id

Usage:

response = manager.get_batch_status(batch_id=batch_id)
..note:: FnapyManager stores the last batch_id
but you can provide a new one if needed.
Parameters:batch_id – the batch id (optional)
Returns:Response object
query_batch()

Return information about your currently processing import batches

Usage:

response = manager.query_batch()
Returns:Response object
query_carriers()

Return the available carriers managed on FNAC Marketplace platform

Usage:

response = manager.query_carriers()
Returns:Response object
query_client_order_comments(results_count='', **elements)

Query your catalog and return the client_order_comments response

Usage:

response = manager.query_client_order_comments(results_count=results_count,
                                **elements)

The available XML elements are the following parameters:

Parameters:
  • paging – Page number to fetch
  • date – Date filter
  • rate – Order rate filter
  • client_order_comment_id – Order unique identifier filter from fnac
  • order_fnac_id – Order unique identifier filter
Returns:

Response object

Examples: Find the 2 first items of the catalog:

response = manager.query_client_order_comments(results_count=2, paging=1)

Find the client_order_comments created between 2 dates:

>>> from fnapy.utils import Query
>>> date = Query('date', type='Modified')
    .between(min="2016-08-23T17:00:00+00:00",
             max="2016-08-26T17:00:00+00:00")
>>> response = manager.query_client_order_comments(date=date)
query_incidents(results_count='', **elements)

Query your catalog and return the incidents response

Usage:

response = manager.query_incidents(results_count=results_count,
                                **elements)

The available XML elements are the following parameters:

Parameters:
  • paging – Page number to fetch
  • date – Date filter
  • status – Status of the incident
  • type – Incident order detail opening reason
  • types – Define the opening reasons of the incidents to be retrieved.
  • incident_id – A unique incident id
  • incidents_id – Can contain multiple incident_id node (up to 50 max)
  • closed_statuses – Can contain multiple closed_status node (up to 50 max)
  • closed_status – Incident closing reason
  • waiting_for_seller_answer – Fnac customer service can ask the seller to deal specifically with an incident.
  • opened_by – Who opened the incident
  • closed_by – Who closed the incident
  • sort_by – Quantity filter
  • order – A unique order id
  • orders – Can contains multiple order node (up to 50 max)
Returns:

Response object

Examples: Find the 2 first items of the catalog:

response = manager.query_incidents(results_count=2, paging=1)

Find the incidents created between 2 dates:

>>> from fnapy.utils import Query
>>> date = Query('date', type='Modified')
    .between(min="2016-08-23T17:00:00+00:00",
             max="2016-08-26T17:00:00+00:00")
>>> response = manager.query_incidents(date=date)
query_messages(results_count='', **elements)

Query your catalog and return the messages response

Usage:

response = manager.query_messages(results_count=results_count,
                                **elements)

The available XML elements are the following parameters:

Parameters:
  • paging – Page number to fetch
  • date – Date filter
  • message_type – Message type filter
  • message_archived – Message is archived or not filter
  • message_state – Message state
  • message_id – Message unique identifier from fnac filter
  • order_fnac_id – Order unique identifier filter
  • offer_fnac_id – Offer unique identifier from fnac
  • offer_seller_id – Offer unique identifier from seller (SKU)
  • sort_by – Quantity filter
  • message_from_types – Messages author filter
Returns:

Response object

Examples: Find the 2 first items of the catalog:

response = manager.query_messages(results_count=2, paging=1)

Find the messages created between 2 dates:

>>> from fnapy.utils import Query
>>> date = Query('date', type='Modified')
    .between(min="2016-08-23T17:00:00+00:00",
             max="2016-08-26T17:00:00+00:00")
>>> response = manager.query_messages(date=date)
query_offers(results_count='', **elements)

Query your catalog and return the offers response

Usage:

response = manager.query_offers(results_count=results_count,
                                **elements)

The available XML elements are the following parameters:

Parameters:
  • paging – Page number to fetch
  • date – Date filter
  • quantity – Quantity filter
  • product_fnac_id – Product’s unique identifier from fnac
  • offer_fnac_id – Offer unique identifier from fnac
  • offer_seller_id – Offer unique identifier from seller (SKU)
Returns:

Response object

Examples: Find the 2 first items of the catalog:

response = manager.query_offers(results_count=2, paging=1)

Find the offers created between 2 dates:

>>> from fnapy.utils import Query
>>> date = Query('date', type='Modified')
    .between(min="2016-08-23T17:00:00+00:00",
             max="2016-08-26T17:00:00+00:00")
>>> response = manager.query_offers(date=date)
query_orders(results_count='', **elements)

Query your catalog and return the orders response

Usage:

response = manager.query_orders(results_count=results_count,
                                **elements)

The available XML elements are the following parameters:

Parameters:
  • paging – Page number to fetch
  • date – Date filter
  • sort_by – Quantity filter
  • product_fnac_id – Product’s unique identifier from fnac
  • offer_fnac_id – Offer unique identifier from fnac
  • offer_seller_id – Offer unique identifier from seller (SKU)
  • state – Order state filter
  • states – Multiple order state filter
  • order_fnac_id – Order unique identifier filter
  • orders_fnac_id – Multiple order unique identifier filter
Returns:

Response object

Examples: Find the 2 first items of the catalog:

response = manager.query_orders(results_count=2, paging=1)

Find the orders created between 2 dates:

>>> from fnapy.utils import Query
>>> date = Query('date', type='Modified')
    .between(min="2016-08-23T17:00:00+00:00",
             max="2016-08-26T17:00:00+00:00")
>>> response = manager.query_orders(date=date)
query_pricing(eans)

Retrieve the best prices applied to a given product within all Fnac marketplace sellers (Fnac included)

Usage:

response = manager.query_pricing(eans)
Parameters:eans (list or tuple) – a list of EANs
Returns:response
query_shop_invoices(results_count='', **elements)

Query your catalog and return the shop_invoices response

Usage:

response = manager.query_shop_invoices(results_count=results_count,
                                **elements)

The available XML elements are the following parameters:

Parameters:
  • paging – Page number to fetch
  • date – Date filter
Returns:

Response object

Examples: Find the 2 first items of the catalog:

response = manager.query_shop_invoices(results_count=2, paging=1)

Find the shop_invoices created between 2 dates:

>>> from fnapy.utils import Query
>>> date = Query('date', type='Modified')
    .between(min="2016-08-23T17:00:00+00:00",
             max="2016-08-26T17:00:00+00:00")
>>> response = manager.query_shop_invoices(date=date)
update_client_order_comments(seller_comment, order_fnac_id)

Reply to client order comments

Usage:

response = manager.update_client_order_comments(seller_comment,
                                                order_fnac_id)
Parameters:
  • seller_comment (str) – The seller comment
  • order_fnac_id (str) – Order unique identifier filter from FNAC
Returns:

Response object

update_incidents(order_id, incident_update_action, reasons)

Handle incidents created on orders

Usage:

response = manager.update_incidents(order_id,
                                    incident_update_action,
                                    reasons)
Parameters:
  • order_id (str) – the unique FNAC identified for an order
  • incident_update_action (str) – the action to perform (‘refund’ is the only available action for the moment)
  • reasons (list) – the reasons of the incident for this order

Example:

reason = {"order_detail_id": 1, "refund_reason": 'no_stock'}
response = manager.update_incidents('07LWQ6278YJUI', 'refund', [reason])
Returns:Response object
update_messages(messages)

Update message sent on your offers or orders : reply, set as read, …

Usage:

response = manager.update_messages(messages)
Parameters:messages (Message) – the specified messages we want to update
Returns:Response object

Example:

>>> m1 = Message(action='mark_as_read', id='12345')
>>> m2 = Message(action='reply', id='12345')
>>> m2.description = 'Your order has been shipped'
>>> m2.subject = 'order_information'
>>> m2.type = 'ORDER'
>>> response = manager.update_messages([m1, m2])
update_offers(offers_data)

Post the update offers and return the response

Usage:

response = manager.update_offers(offers_data)
Parameters:offers_data (list) – the list of data to create the offers where data is dictionary with the keys:
  • offer_reference : the SKU (mandatory)
  • product_reference: the EAN (optional)
  • price : the price of the offer (optional)
  • product_state : an integer representing the state of the product
    (documentation needed) (optional)
  • quantity : the quantity (optional)
  • description : a description of the offer (optional)

The exception FnapyUpdateOfferError is raised if: - offer_reference and at least one of the optional parameters (except product_reference) are not provided - offers_data is empty

Returns:Response object
update_orders(order_id, order_update_action, actions)

Update the selected order with an order_update_action

Usage:

response = manager.update_orders(order_id, order_update_action, actions)
Parameters:
  • order_id (str) – Order unique identifier from FNAC
  • order_update_action (str) – Group action type for order detail action
  • actions (list) – a list of dictionaries with 2 keys: ‘order_detail_id’ and ‘action’
Returns:

Response object

Available order_update_action:

  • accept_order : The action for the order is accepting orders by the
    seller
  • confirm_to_send : The action for the order is confirming sending
    orders by the seller
  • update : The action for the order is updating orders by the seller
  • accept_all_orders : The action for the order is accepting or refusing
    all order_details of the order by the seller
  • confirm_all_to_send: The action for the order is confirming sending
    all order_details by the seller
  • update_all : The action for the order is to update tracking
    information for all order_details

Example: For this order (whose order_id is ‘LDJEDEAS123’), we have 2 items. We decide to accept the first item and refuse the second:

action1 = {"order_detail_id": 1, "action": "Accepted"}
action2 = {"order_detail_id": 2, "action": "Refused"}
response = manager.update_orders('LDJEDEAS123', 'accept_order', [action1, action2])

FnapyConnection

class connection.FnapyConnection(credentials={}, sandbox=None)

The connection class of fnapy

Usage::
connection = FnapyConnection(credentials=credentials, sandbox=sandbox)

Example:

  • Create a connection with a credentials dictionary:

    credentials = {'partner_id': 'my_partner_id', 'shop_id': 'my_shop_id',
                   'key': 'my_key', 'sandbox': False}
    
  • Create a connection using the environment variables for a given account type (the sandbox account is used if sandbox True. If sandbox is False, the real account is used):

    connection = FnapyConnection(sandbox=True)
    

Note

You must have previously defined the following environment variables:

  • for the sandbox: FNAC_SANDBOX_PARTNER_ID, FNAC_SANDBOX_SHOP_ID,
    FNAC_SANDBOX_KEY
  • for the real account: FNAC_PARTNER_ID, FNAC_SHOP_ID, FNAC_KEY

Request

class utils.Request(content)

A handy class to handle the request

Response

class utils.Response(content)

A handy class to handle the response

Message

class utils.Message(action, id, to='ALL', description='', subject='', type='ORDER')
to_dict()

Return the a dictionary in the xmltodict format