Skip to content

Commit e90e83f

Browse files
Refactor file path handling and update coupon descriptions in BMS examples
- Replaced `os.path.abspath` with `pathlib.Path` for improved file path handling in multiple example scripts. - Shortened coupon descriptions in various BMS examples for better clarity and consistency.
1 parent 2a1e79f commit e90e83f

8 files changed

+22
-22
lines changed

examples/simple/send_bms_free_carousel_commerce.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
발신번호, 수신번호에 반드시 -, * 등 특수문자를 제거하여 기입하시기 바랍니다. 예) 01012345678
1111
"""
1212

13-
from os.path import abspath
13+
from pathlib import Path
1414

1515
from solapi import SolapiMessageService
1616
from solapi.model import Bms, KakaoOption, RequestMessage
@@ -33,7 +33,7 @@
3333

3434
try:
3535
file_response = message_service.upload_file(
36-
file_path=abspath("../images/example_wide.jpg"),
36+
file_path=str(Path(__file__).parent / "../images/example_wide.jpg"),
3737
upload_type=FileTypeEnum.BMS_CAROUSEL_COMMERCE_LIST,
3838
)
3939
image_id = file_response.file_id
@@ -83,7 +83,7 @@
8383
],
8484
coupon=BmsCoupon(
8585
title="10000원 할인 쿠폰",
86-
description="첫 구매 고객 전용 쿠폰입니다.",
86+
description="첫 구매 고객 전용",
8787
link_mobile="https://example.com/coupon",
8888
),
8989
),

examples/simple/send_bms_free_carousel_feed.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
발신번호, 수신번호에 반드시 -, * 등 특수문자를 제거하여 기입하시기 바랍니다. 예) 01012345678
99
"""
1010

11-
from os.path import abspath
11+
from pathlib import Path
1212

1313
from solapi import SolapiMessageService
1414
from solapi.model import Bms, KakaoOption, RequestMessage
@@ -29,7 +29,7 @@
2929

3030
try:
3131
file_response = message_service.upload_file(
32-
file_path=abspath("../images/example_wide.jpg"),
32+
file_path=str(Path(__file__).parent / "../images/example_wide.jpg"),
3333
upload_type=FileTypeEnum.BMS_CAROUSEL_FEED_LIST,
3434
)
3535
image_id = file_response.file_id
@@ -67,7 +67,7 @@
6767
],
6868
coupon=BmsCoupon(
6969
title="10% 할인 쿠폰",
70-
description="첫 등록 고객 전용 할인 쿠폰입니다.",
70+
description="첫 등록 고객 전용",
7171
link_mobile="https://example.com/coupon",
7272
),
7373
),

examples/simple/send_bms_free_commerce.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
발신번호, 수신번호에 반드시 -, * 등 특수문자를 제거하여 기입하시기 바랍니다. 예) 01012345678
99
"""
1010

11-
from os.path import abspath
11+
from pathlib import Path
1212

1313
from solapi import SolapiMessageService
1414
from solapi.model import Bms, KakaoOption, RequestMessage
@@ -27,7 +27,7 @@
2727

2828
try:
2929
file_response = message_service.upload_file(
30-
file_path=abspath("../images/example_wide.jpg"),
30+
file_path=str(Path(__file__).parent / "../images/example_wide.jpg"),
3131
upload_type=FileTypeEnum.BMS,
3232
)
3333
print(f"파일 업로드 성공! File ID: {file_response.file_id}")
@@ -65,7 +65,7 @@
6565
],
6666
coupon=BmsCoupon(
6767
title="포인트 UP 쿠폰",
68-
description="구매 시 2배 적립 쿠폰입니다.",
68+
description="구매 시 2배 적립",
6969
link_mobile="https://example.com/coupon",
7070
),
7171
),

examples/simple/send_bms_free_image.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
발신번호, 수신번호에 반드시 -, * 등 특수문자를 제거하여 기입하시기 바랍니다. 예) 01012345678
66
"""
77

8-
from os.path import abspath
8+
from pathlib import Path
99

1010
from solapi import SolapiMessageService
1111
from solapi.model import Bms, KakaoOption, RequestMessage
@@ -18,7 +18,7 @@
1818

1919
try:
2020
file_response = message_service.upload_file(
21-
file_path=abspath("../images/example.jpg"),
21+
file_path=str(Path(__file__).parent / "../images/example_square.jpg"),
2222
upload_type=FileTypeEnum.BMS,
2323
)
2424
print(f"파일 업로드 성공! File ID: {file_response.file_id}")

examples/simple/send_bms_free_image_with_buttons.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
발신번호, 수신번호에 반드시 -, * 등 특수문자를 제거하여 기입하시기 바랍니다. 예) 01012345678
88
"""
99

10-
from os.path import abspath
10+
from pathlib import Path
1111

1212
from solapi import SolapiMessageService
1313
from solapi.model import Bms, KakaoOption, RequestMessage
@@ -26,7 +26,7 @@
2626

2727
try:
2828
file_response = message_service.upload_file(
29-
file_path=abspath("../images/example.jpg"),
29+
file_path=str(Path(__file__).parent / "../images/example_square.jpg"),
3030
upload_type=FileTypeEnum.BMS,
3131
)
3232
print(f"파일 업로드 성공! File ID: {file_response.file_id}")
@@ -60,7 +60,7 @@
6060
],
6161
coupon=BmsCoupon(
6262
title="10000원 할인 쿠폰",
63-
description="연말 감사 할인 쿠폰입니다.",
63+
description="연말 감사 할인",
6464
link_mobile="https://example.com/coupon",
6565
),
6666
),

examples/simple/send_bms_free_premium_video.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
발신번호, 수신번호에 반드시 -, * 등 특수문자를 제거하여 기입하시기 바랍니다. 예) 01012345678
88
"""
99

10-
from os.path import abspath
10+
from pathlib import Path
1111

1212
from solapi import SolapiMessageService
1313
from solapi.model import Bms, KakaoOption, RequestMessage
@@ -47,7 +47,7 @@
4747

4848
try:
4949
file_response = message_service.upload_file(
50-
file_path=abspath("../images/example.jpg"),
50+
file_path=str(Path(__file__).parent / "../images/example_square.jpg"),
5151
upload_type=FileTypeEnum.KAKAO,
5252
)
5353

@@ -78,7 +78,7 @@
7878
],
7979
coupon=BmsCoupon(
8080
title="10% 할인 쿠폰",
81-
description="영화 예매 시 사용 가능한 할인 쿠폰입니다.",
81+
description="영화 예매 시 할인",
8282
link_mobile="https://example.com/coupon",
8383
),
8484
),

examples/simple/send_bms_free_wide.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
발신번호, 수신번호에 반드시 -, * 등 특수문자를 제거하여 기입하시기 바랍니다. 예) 01012345678
66
"""
77

8-
from os.path import abspath
8+
from pathlib import Path
99

1010
from solapi import SolapiMessageService
1111
from solapi.model import Bms, KakaoOption, RequestMessage
@@ -19,7 +19,7 @@
1919

2020
try:
2121
file_response = message_service.upload_file(
22-
file_path=abspath("../images/example_wide.jpg"),
22+
file_path=str(Path(__file__).parent / "../images/example_wide.jpg"),
2323
upload_type=FileTypeEnum.BMS_WIDE,
2424
)
2525
print(f"파일 업로드 성공! File ID: {file_response.file_id}")

examples/simple/send_bms_free_wide_item_list.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
발신번호, 수신번호에 반드시 -, * 등 특수문자를 제거하여 기입하시기 바랍니다. 예) 01012345678
77
"""
88

9-
from os.path import abspath
9+
from pathlib import Path
1010

1111
from solapi import SolapiMessageService
1212
from solapi.model import Bms, KakaoOption, RequestMessage
@@ -20,14 +20,14 @@
2020

2121
try:
2222
main_file_response = message_service.upload_file(
23-
file_path=abspath("../images/example_wide.jpg"),
23+
file_path=str(Path(__file__).parent / "../images/example_wide.jpg"),
2424
upload_type=FileTypeEnum.BMS_WIDE_MAIN_ITEM_LIST,
2525
)
2626
main_image_id = main_file_response.file_id
2727
print(f"메인 이미지 업로드 성공! File ID: {main_image_id}")
2828

2929
sub_file_response = message_service.upload_file(
30-
file_path=abspath("../images/example_square.jpg"),
30+
file_path=str(Path(__file__).parent / "../images/example_square.jpg"),
3131
upload_type=FileTypeEnum.BMS_WIDE_SUB_ITEM_LIST,
3232
)
3333
sub_image_id = sub_file_response.file_id

0 commit comments

Comments
 (0)