Skip to main content

Python bindings to efidgy services.

Project description

efidgy

Python bindings to efidgy services.

Overview

Environment

Environment in terms of efidgy package is a set of settings to work with efidgy backend. Theese settings includes customer code and access token that will be used to communicate with backend.

Unit System.

If you will not set the unit system directly, efidgy will use current user settings: console.efidgy.com/profile

Anyway, it is a good practice to define the unit system in your code:

efidgy.env = efidgy.env.override(
    unit_system=efidgy.models.UnitSystem.IMPERIAL,
)

Credentials

efidgy.env is initialized with settings fetched from the shell environment. The following environment variables are used:

You can always override code and/or token with the code like this:

efidgy.env = efidgy.env.override(
    code='hardcoded customer code',
)

API documentation

Find out more at: efidgy.com/docs

Sample usage

export EFIDGY_CUSTOMER_CODE=code  # https://console.efidgy.com/profile/company
export EFIDGY_ACCESS_TOKEN=token  # https://console.efidgy.com/profile/tokens
import datetime
import efidgy


project = efidgy.models.Project.service.create(
    name='Demo',
    currency='USD',
    project_type=efidgy.models.ProjectType(
        code=efidgy.models.ProjectTypeCode.IDD_OR,
    ),
    shared_mode=efidgy.models.SharedMode.PRIVATE,
)

store_address = '6133 Broadway Terr., Oakland, CA 94618, USA'
lat, lon = efidgy.tools.geocode(store_address)
store = efidgy.models.idd_or.Store.service.create(
    project=project,
    address=store_address,
    lat=lat,
    lon=lon,
    name='Delivery Inc.',
    open_time=datetime.time(8, 0),
    close_time=datetime.time(18, 0),
)

vehicle = efidgy.models.idd_or.Vehicle.service.create(
    project=project,
    store=store,
    name='Gary Bailey',
    fuel_consumption=11.76,
    fuel_price=3.25,
    salary_per_duration=21,
    duration_limit=datetime.timedelta(hours=9),
)

order_address = '1 Downey Pl, Oakland, CA 94610, USA'
lat, lon = efidgy.tools.geocode(order_address)
order = efidgy.models.idd_or.Order.service.create(
    project=project,
    store=store,
    name='#00001',
    address=order_address,
    lat=lat,
    lon=lon,
    ready_time=datetime.time(8, 0),
    delivery_time_from=datetime.time(12, 0),
    delivery_time_to=datetime.time(16, 0),
    load_duration=datetime.timedelta(minutes=1),
    unload_duration=datetime.timedelta(minutes=5),
    boxes=1,
    volume=3.53,
    weight=22.05,
)

project.computate()

solutions = efidgy.models.Solution.service.all(
    project=project,
)

if solutions:
    solution = solutions[0]

    vehicle = efidgy.models.idd_or.Vehicle.service.get(
        pk=vehicle.pk,
        project=project,
        solution=solution,
    )

    print(vehicle.name)
    if vehicle.route is not None:
        prev_schedule = None
        for schedule in vehicle.route.schedule:
            print('{at}\t{arr}\t{dep}'.format(
                at=schedule.start_point.name,
                arr=prev_schedule.arrival_time if prev_schedule else vehicle.route.start_time,
                dep=schedule.departure_time,
            ))
            prev_schedule = schedule
        if prev_schedule:
            print('{at}\t{arr}\t{dep}'.format(
                at=prev_schedule.end_point.name,
                arr=prev_schedule.arrival_time,
                dep='',
            ))

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

efidgy-0.12.1.post1.tar.gz (26.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

efidgy-0.12.1.post1-py3-none-any.whl (28.8 kB view details)

Uploaded Python 3

File details

Details for the file efidgy-0.12.1.post1.tar.gz.

File metadata

  • Download URL: efidgy-0.12.1.post1.tar.gz
  • Upload date:
  • Size: 26.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.4

File hashes

Hashes for efidgy-0.12.1.post1.tar.gz
Algorithm Hash digest
SHA256 d11f9819313b72f41fa36bdecd4b53cb5076b3a76bcf13675eaedab3bd73033b
MD5 a56a0f7d230e0ecb6804202467054259
BLAKE2b-256 bc211fae7ba5087f452ba6c80dcf307098cc6df8366ce9d2b24002ecd4c99254

See more details on using hashes here.

File details

Details for the file efidgy-0.12.1.post1-py3-none-any.whl.

File metadata

  • Download URL: efidgy-0.12.1.post1-py3-none-any.whl
  • Upload date:
  • Size: 28.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.4

File hashes

Hashes for efidgy-0.12.1.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 44da7b0114e87a11483d829bb29efc9b1af88d48d9fadb480c5c0925d1ecac62
MD5 e867ffe918336ebddabeb3eac8203f39
BLAKE2b-256 0353d8354c7a0621e897e88051523d74ad816c49dbccc7eaec4de721829f98f2

See more details on using hashes here.

Supported by

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