Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Lotify: a python SDK for LINE Notify

Lotify: a python SDK for LINE Notify

COSCUP 2020 day2 (0802) main track session: https://coscup.org/2020/zh-TW/agenda/KNJDWQ

LINE Developers Taiwan

August 02, 2020
Tweet

More Decks by LINE Developers Taiwan

Other Decks in Technology

Transcript

  1. Lotify: a python SDK
    for LINE Notify
    LINE Developer Relations
    NiJia Lin
    2020.08

    View full-size slide

  2. NiJia Lin
    • Developer Rela*ons
    • External Evangelism
    • Internal Evangelism
    LINE Technology Evangelist

    View full-size slide

  3. • Introduction
    • Why I need to create Lotify
    • Doing SDK details
    Agenda

    View full-size slide

  4. LINE Notify & Lotify

    View full-size slide

  5. LINE Notify
    https://notify-bot.line.me/zh_TW/

    View full-size slide

  6. LINE No'fy
    h"ps://no)fy-bot.line.me/zh_TW/
    • Provided by LINE.
    • One way notify.
    • LINE official account.
    • LINE push message to user.
    • Via OAuth 2.0.

    View full-size slide

  7. LINE Notify
    https://notify-bot.line.me/zh_TW/
    • Provided by LINE.
    • One way notify.
    • LINE official account.
    • LINE push message to user.
    • Via OAuth 2.0.

    View full-size slide

  8. LINE Notify - example

    View full-size slide

  9. LINE No'fy - example

    View full-size slide

  10. LINE Notify - Type
    https://notify-bot.line.me/zh_TW/
    • Text
    • Sticker
    • Image url
    • Image file

    View full-size slide

  11. LINE Notify Authorize flow
    https://notify-bot.line.me/doc/en/

    View full-size slide

  12. Lotify workflow
    h"ps://github.com/louis70109/lo5fy

    View full-size slide

  13. Lotify workflow
    https://notify-bot.line.me/doc/en/

    View full-size slide

  14. Lo#fy need you star⭐!
    https://github.com/louis70109/lotify

    View full-size slide

  15. Why I need to
    create Lotify

    View full-size slide

  16. • Needed a SDK which can let me use it quickly.
    • Many Pypi packages just do half features.
    • If I used LINE Notify I need to call normal API again.
    • Learned good unit test from line-bot-sdk-python
    Why I need to create Lotify

    View full-size slide

  17. • Needed a SDK which can let me use it quickly.
    • Many Pypi packages just do half features.
    • If I used LINE Notify I need to call normal API again.
    • Learned good unit test from line-bot-sdk-python.
    Why I need to create Lo/fy

    View full-size slide

  18. Find most star LINE Notify SDK at Pypi & Github
    https://github.com/louis70109/lotify

    View full-size slide

  19. • It had many good code.
    • It could be better:
    • Unit test.
    • Functionalize send message type.
    • No authorization flow:
    • Link url
    • Change token
    • Get status
    Why I need to create Lotify

    View full-size slide

  20. • Needed a SDK which can let me use it quickly.
    • Many Pypi packages just do half features.
    • If I used LINE Notify I need to call normal API again.
    • Learned good unit test from line-bot-sdk-python.
    Why I need to create Lotify

    View full-size slide

  21. • Needed a SDK which can let me use it quickly
    • Many Pypi packages just do half features
    • If I used LINE No@fy I need to call normal API again
    • Learned good unit test from line-bot-sdk-python
    Why I need to create Lotify

    View full-size slide

  22. Why do I need to create Lotify?
    • Needed a SDK which can let me use it quickly
    • Many Pypi packages just do half features
    • If I used LINE No@fy I need to call normal API again
    • Learned good unit test from line-bot-sdk-python

    View full-size slide

  23. • Needed a SDK which can let me use it quickly.
    • Many Pypi packages just do half features.
    • If I used LINE Notify I need to call normal API again.
    • Learned good unit test by line-bot-sdk-python.
    Why I need to create Lotify

    View full-size slide

  24. https://github.com/getsentry/responses
    Mock response correctly

    View full-size slide

  25. • I referenced line-bot-sdk-python unit test.
    • Authoriza8on flow.
    • Documenta8on.
    • It had example :
    • h?ps://github.com/louis70109/flask-line-no8fy
    • One click deployment deploy to Heroku.
    Why I need to create Lotify

    View full-size slide

  26. Doing SDK Details

    View full-size slide

  27. Fully support

    View full-size slide

  28. Fully support

    View full-size slide

  29. Send sticker & image,
    revoke token,
    get status…

    View full-size slide

  30. Lo#fy need you star⭐!
    https://github.com/louis70109/lotify

    View full-size slide

  31. h"ps://github.com/miyakogi/m2r
    • Read Markdown file from absolute path and transform Markdown to reStructuredText
    in generate static file flow by m2r package.
    Package only can reStructuredText

    View full-size slide

  32. But it fixed and
    I can not restore…? !

    View full-size slide

  33. • Read Markdown file from absolute path and transform Markdown to reStructuredText
    in generate static file flow by m2r package
    Version control

    View full-size slide

  34. • Used a single file to control package version, it could be be5er to control.
    • Input bo5om code in setup.py:
    Version control

    View full-size slide

  35. • Input variable in setup() version column.
    • When you upload new version it would read __version__.py automa:cally.
    • Every modifica:on need to add version number.
    Version control

    View full-size slide

  36. Version control

    View full-size slide

  37. Version control

    View full-size slide

  38. Pypi upload config

    View full-size slide

  39. Pypi upload config

    View full-size slide

  40. Pypi upload config

    View full-size slide

  41. Pypi upload config

    View full-size slide

  42. h"ps://github.com/louis70109/lo5fy
    Split requirements environment

    View full-size slide

  43. • It can let contributor use requirements.txt
    correctly.
    • If your SDK had different environment
    pipline, this method would not pollute them.
    Split requirements environment

    View full-size slide

  44. • It need .travis.yml file to run.
    • The file can trigger Travis CI.
    • Nice to have auto test.
    • Choose your favorite CI platform.
    Travis

    View full-size slide

  45. • It need .travis.yml file to run
    • The file can trigger Travis CI
    • It’s nice to have auto test
    • Choose your favorite CI pla:orm
    Travis

    View full-size slide

  46. • It need .travis.yml file to run
    • The file can trigger Travis CI
    • It’s nice to have auto test
    • Choose your favorite CI pla:orm
    Travis - Badge
    GitHub Action could catch Travis result once

    View full-size slide

  47. Travis - Badge

    View full-size slide

  48. Travis - Badge

    View full-size slide

  49. Travis - Badge

    View full-size slide

  50. • It need tox.ini file to run.
    • Check mul3 python version.
    • Lo3fy was checked 3.5~3.8
    • Run Linter(flake8).
    • CI is suitable.
    Tox

    View full-size slide

  51. • “self” share between Class and
    Instance level.
    • Bot_orgin & api_origin can change url,
    if developer want to Stress testing.
    Variable level

    View full-size slide

  52. • Credibility & Protec.ve.
    • Very important !!
    License

    View full-size slide

  53. https://github.com/louis70109/flask-line-notify
    Try it!

    View full-size slide

  54. • LINE Notify & Lotify flow.
    • Why I implement Lotify.
    • What are Lotify have.
    • Version control.
    • Pypi upload config.
    • Requirement file.
    • Travis & Tox
    • Namespace & variable level.
    • Heroku – one click deployment.
    Arrangement

    View full-size slide

  55. LINE FRESH 2020 校園競賽
    https://linefresh.linecorp.com/ 61

    View full-size slide

  56. LINE TECH FRESH
    https://engineering.linecorp.com/zh-hant/blog/tech-fresh-2020/
    62

    View full-size slide