GithubHelp home page GithubHelp logo

siyet / tetris Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 20.06 MB

Узкоспециализированное SPA для наведения порядка на складе

HTML 6.05% CSS 37.70% PHP 6.83% JavaScript 48.17% Python 1.25%

tetris's People

Contributors

siyet avatar

Watchers

 avatar  avatar

tetris's Issues

Написать одноразовый скрипт

Необходимо написать скрипт, который подключиться к API SureDone, переберет все товары у которых поле storagelocation не пустое.
В данном поле вписаны данные вида:

056302 053621/1 32321

Для каждого набора цифр состоящего из 5 штук нужно добавить префикс "0", т. е.

implode( " ", array_map(
     function ($item) { return preg_match("/[0-9]{5}/", $item) ? "0" + $item : $item; },
     preg_split("/[\s,]+/", $row['storagelocation'])
) );

разделителями могут быть не только пробелы, разделители нужно сохранить, если в данном поле вписано что либо отличное от "/[0-9]{5|6}*/", то пишем в лог значение поля sku и напротив значение поля storagelocation.

В config.php есть токен для подключения к api.
Описание API: https://www.suredone.com/guides/api/

  • есть еще не описанный тут метод bulk, который позволяет взять все в виде csv, вот пример как дергать на python:
API_URL_BASE = 'https://api.suredone.com/v1/'
HEADERS = {
    'x-auth-token': '[тута токен]',
    'x-auth-user': '[тута имя пользователя]'
}
response = requests.get('{0}bulk/exports/?type=items&mode=include&fields=sku'.format(API_URL_BASE), headers=HEADERS)
    if response.status_code == 200:
        data = json.loads(response.content.decode('utf-8'))
        if data['result'] != 'success':
            print(data['message'])
            raise
        time.sleep(8)
        _response = requests.get('{0}bulk/exports/{1}'.format(API_URL_BASE, data['export_file']), headers=HEADERS)
        if _response.status_code == 200:
            _data = json.loads(_response.content.decode('utf-8'))
            __response = requests.get(_data['url'])
            if __response.status_code == 200:
                _updatable = csv.DictReader(__response.content.decode('utf-8').split('\n')[:-1], delimiter=',', quotechar='"')
                for row in _updatable:
                    skus_SD.append(row['sku'])

Пример, как вносить изменения в БД SureDone есть в файле edit.php, и в описании API.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.