Skip to main content

Connector for connecting via api to DKC. Allows you to easily retrieve product and news data.

Project description

DKC API v1

Status License


Connector to DKC API v1 (dkc.ru)

📚 Table of Contents

💬 About

Connector for connecting via api to DKC. Allows you to easily retrieve product and news data.

🧵 Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Pip or poetry

The project uses Poetry instead of pip. But if you do not want to install the Poetry, for this case, create a file "requirements.txt".

Init

To get started, you need to import the main class DkcAPI.

from dkc_api.v1.dkc_api import DkcAPI

Next, we pass the initialization parameters to the class. If you want to use environment variables, then the file .env.example is prepared for this.

dkc_api = DkcAPI(
    master_key=os.getenv("TOKEN"),
    debug=True,
    storage=storage.FileTokenStorage(),
    logger=logger
)

📌 Available models

So far, only five DkcAPI models are available for work:

  1. Catalog
  2. Content
  3. Delivery
  4. News
  5. Project (In developing)

🧰 Usage

🪑 Methods Catalog

Catalog object name:

>>> dkc_api.Catalog.*

GetMaterialStock

This method retrieves data on stock balances.

Args:

  • code (list[str], str, int, None): Material code list. If present, ‘Material ID’ is not taken into account. Defaults to [].
  • id (list[str], str, int, None): Material id list. Defaults to [].
>>> resolve = dkc_api.Catalog.getMaterialStock()
>>> resolve
GetMaterialStock({create: datetime, materials: [{ id: 81, status: true, code: 1200, warehouse: [{code: 2765, ...]}, ...]}, ...] })

GetMaterial

This method returns all data for the specified material.

Args:

  • code (str): Material code.
>>> resolve = dkc_api.Catalog.getMaterial(code=1200)
>>> resolve
GetMaterial({material: {id: 81, node_id: 1234, etim_class_id: "ETIM", name: "Product name", type: "Type", ...})

getMaterialAnalogs

This method returns a list of product analogues.

Args:

  • code (str, None): Material code.
>>> resolve = dkc_api.Catalog.getMaterialAnalogs(code=1200)
>>> resolve
GetMaterialAnalogs({analogs: { "1200": [ *product_analogue_codes* ]}})

You can get a list of all analogs for all products, for this you need to leave the "code" parameter empty.

>>> resolve = dkc_api.Catalog.getMaterialAnalogs()
>>> resolve
GetMaterialAnalogs({analogs: { *product_codes*: [ *product_analogue_codes* ]}})

getMaterialAccessories

This method returns a list of product accessories.

Args:

  • code (str, None): Material code.
>>> resolve = dkc_api.Catalog.getMaterialAccessories(code=1200)
>>> resolve
GetMaterialAccessories({accessories: { "1200": [ *product_analogue_codes* ]}})

You can get a list of all accessories for all products, for this you need to leave the "code" parameter empty.

>>> resolve = dkc_api.Catalog.getMaterialAccessories()
>>> resolve
GetMaterialAccessories({accessories: { *product_codes*: [ *product_analogue_codes* ]}})

getMaterialCertificates

This method returns a list of product certificates.

Args:

  • code (str): Material code.
>>> resolve = dkc_api.Catalog.getMaterialCertificates(code=1200)
>>> resolve
GetMaterialCertificates({certificates: { "1200": [ *product_analogue_codes* ]}})

List other methods

  • getMaterialRelated
  • getMaterialVideo
  • getMaterialDrawingsSketch
  • getMaterialDescription
  • getMaterialSpecification

🏢 Methods Content

Content object name:

>>> dkc_api.Content.*

getRevisionDrawings

The method allows you to get editorial drawings by product code

Args:

  • last_updated (datetime, None): if specified, only processes changes from the specified date. Timestamp format.
>>> resolve = dkc_api.Content.getRevisionDrawings(code=1200)
>>> resolve
GetRevisionDrawings({revision: { delta: bool, drawings: { updated: [id: 1200, name: "Name", links: { type: "Type", ...}], removed: [...]}})

getRevisionMaterials

The method allows you to get editorial materials by product code

Args:

  • last_updated (datetime, optional): if specified, only processes changes from the specified date. Timestamp format.
>>> resolve = dkc_api.Content.getRevisionMaterials(code=1200)
>>> resolve
GetRevisionMaterials({revision: { delta: bool, materials: { updated: [id: 1200, name: "Name", links: { type: "Type", ...}], removed: [...]}})

postFile

This method allows you to upload files to the dkc api repository

Args:

  • file_content (PostFileContent): file content
>>> post_file_content = PostFileContent(name="name_file", value="value_file")
>>> resolve = dkc_api.Content.postFile(file_content=post_file_content)
>>> resolve
PostFile({revision: { id: 872} })

getFile

This method allows you to get files from the dkc api repository

Args:

  • file_id (int): file id
>>> resolve = dkc_api.Content.getFile(file_id=872)
>>> resolve
PostFile({revision: { name: "name_file", value: "value_file" } })

List other methods

  • getRevisionCertificates
  • getRevisionsLastSize
  • getRevisionsLast

🏃 Methods Delivery

Delivery object name:

>>> dkc_api.Delivery.*

getDeliveryTime

The method returns the date of shipment of goods

Args:

  • delivery_time_content (DeliveryTimeContent): delivery time content. Work how filter.
>>> delivery_time_content = DeliveryTimeContent(company_warehouse="test", items=[])
>>> resolve = dkc_api.Delivery.getDeliveryTime(delivery_time_content=delivery_time_content)
>>> resolve
GetDeliveryTime({items: [{ code: 172, status: true, date_last: {date: *datetime*, amount: 1689030}, date_detail: [...]}, ...] })

📰 Methods News

News object name:

>>> dkc_api.News.*

getNewsCompany

The method returns company news.

Args:

  • page_index (int): Page index how need load. Default first (0) page.
  • length (int): Count news on page. Default 10 news.
>>> resolve = dkc_api.News.getNewsCompany()
>>> resolve
GetNewsCompany({news: [{title: "Title", text: "Text", thumbnail_url: "Url", images: ["URL", ...], timestamp: *datetime*}, ...]})

getNewsProducts

The method returns products news.

Args:

  • page_index (int): Page index how need load. Default first (0) page.
  • length (int): Count news on page. Default 10 news.
>>> resolve = dkc_api.News.getNewsProducts()
>>> resolve
GetNewsProducts({news: [{title: "Title", text: "Text", thumbnail_url: "Url", images: ["URL", ...], timestamp: *datetime*}, ...]})

getNewsCommunity

The method returns community news.

Args:

  • page_index (int): Page index how need load. Default first (0) page.
  • length (int): Count news on page. Default 10 news.
>>> resolve = dkc_api.News.getNewsCommunity()
>>> resolve
GetNewsCommunity({news: [{text: "Text", timestamp: "08.08.2021"}, ...]})

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dkc-api-0.1.0.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

dkc_api-0.1.0-py2.py3-none-any.whl (8.2 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file dkc-api-0.1.0.tar.gz.

File metadata

  • Download URL: dkc-api-0.1.0.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.5

File hashes

Hashes for dkc-api-0.1.0.tar.gz
Algorithm Hash digest
SHA256 155758b99f3f7407df9315f9d821b8f695adfd13b8d0db6f5102dde60aee8592
MD5 8866b7a414b5b7315770411c6591406f
BLAKE2b-256 6c68a1c13c7050cf68ad90b61e73b8910d80a888fccfa84e884179a2936d8591

See more details on using hashes here.

File details

Details for the file dkc_api-0.1.0-py2.py3-none-any.whl.

File metadata

  • Download URL: dkc_api-0.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.5

File hashes

Hashes for dkc_api-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 4e461715c103e8ddcb9082ef89e88dc4b4ac98201163516c0c2224b9565e19c0
MD5 c551ac14c01b69fa90470fb46eddc3b1
BLAKE2b-256 7e143725b608574405c0b314ba55c50495e5e7859e0a5c55abfb885a311bfc7a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page