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
PRO

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 Slide

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

    View Slide

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

    View Slide

  4. LINE Notify & Lotify

    View Slide

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

    View 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 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 Slide

  8. LINE Notify - example

    View Slide

  9. LINE No'fy - example

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  15. Why I need to
    create Lotify

    View 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 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 Slide

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

    View Slide

  19. View Slide

  20. Hmmm…!

    View Slide

  21. • 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 Slide

  22. • 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 Slide

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

    View Slide

  24. 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 [email protected] I need to call normal API again
    • Learned good unit test from line-bot-sdk-python

    View Slide

  25. • 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 Slide

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

    View Slide

  27. • 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 Slide

  28. Doing SDK Details

    View Slide

  29. Fully support

    View Slide

  30. Fully support

    View Slide

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

    View Slide

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

    View Slide

  33. 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 Slide

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

    View Slide

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

    View Slide

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

    View Slide

  37. • 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 Slide

  38. Version control

    View Slide

  39. Version control

    View Slide

  40. Pypi upload config

    View Slide

  41. Pypi upload config

    View Slide

  42. Pypi upload config

    View Slide

  43. Pypi upload config

    View Slide

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

    View Slide

  45. • 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 Slide

  46. • 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 Slide

  47. • 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 Slide

  48. • 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 Slide

  49. Travis - Badge

    View Slide

  50. Travis - Badge

    View Slide

  51. Travis - Badge

    View Slide

  52. • 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 Slide

  53. Namespace

    View Slide

  54. Namespace

    View Slide

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

    View Slide

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

    View Slide

  57. Heroku

    View Slide

  58. Heroku

    View Slide

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

    View Slide

  60. • 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 Slide

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

    View Slide

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

    View Slide

  63. View Slide