Skip to main content

GiftReaper เป็นแพ็กเกจสำหรับช่วยในการทำธุรกรรมจากการส่งซองทรูมันนี่

Project description

GiftReaper

GiftReaper เป็นแพ็กเกจสำหรับช่วยในการทำธุรกรรมจากการส่งซองทรูมันนี่

ความสามารถของแพ็กเกจ

  • ตรวจสอบข้อมูลจากซองทรูมันนี่
  • รับเงินจากซองทรูมันนี่
  • เปรียบเทียบจำนวนเงินจากซองทรูมันนี่กับราคาสินค้าที่สนใจ
  • ตรวจสอบจำนวนเงินจากซองทรูมันนี่

วิธีติดตั้ง

pip install GiftReaper

วิธีตรวจสอบข้อมูลจากซองทรูมันนี่

verify_voucher(${ิงก์บัตรกำนัลหรือรหัสบัตรกำนัล}, ${หมายเลขโทรศัพท์ของบัญชีรับเงิน})

วิธีรับเงินจากซองทรูมันนี่

redeem_voucher(${ิงก์บัตรกำนัลหรือรหัสบัตรกำนัล}, ${หมายเลขโทรศัพท์ของบัญชีรับเงิน})

วิธีเปรียบเทียบจำนวนเงินจากซองทรูมันนี่กับราคาสินค้าที่สนใจ

is_voucher_balance_sufficient(${ิงก์บัตรกำนัลหรือรหัสบัตรกำนัล}, ${หมายเลขโทรศัพท์ของบัญชีรับเงิน}, ${ราคาสินค้าที่สนใจ})

วิธีตรวจสอบจำนวนเงินจากซองทรูมันนี่

check_voucher_amount_baht(${ิงก์บัตรกำนัลหรือรหัสบัตรกำนัล}, ${หมายเลขโทรศัพท์ของบัญชีรับเงิน})

ตัวอย่างรูปแบบข้อมูลต่าง ๆ

# รูปแบบลิงก์หรือรหัสบัตรกำนัล
voucher_url_first_format: str = 'https://gift.truemoney.com/campaign/?v={รหัสบัตรกำนัล}'
voucher_url_second_format: str = '{รหัสบัตรกำนัล}'

# รูปแบบหมายเลขโทรศัพท์
mobile_number_first_format: str = '08x-xxx-xxxx'
mobile_number_second_format: str = '08xxxxxxxx'

# รูปแบบราคาสินค้า
product_price_500: int = 500
product_price_500_0: float = 500.0

ตัวอย่าง

from GiftReaper import verify_voucher, redeem_voucher, is_voucher_balance_sufficient, check_voucher_amount_baht

voucher_url_10_baht: str = '{รหัสบัตรกำนัล}'
mobile_number: str = '08x-xxx-xxxx'

product_price_9_50: float = 9.50
product_price_10: int = 10
product_price_10_50: float = 10.50

if __name__ == '__main__':
    # check_voucher_amount_baht()
    print(check_voucher_amount_baht(voucher_url_10_baht, mobile_number)) # ผลลัพธ์ 10.0

    # is_voucher_balance_sufficient()
    print(is_voucher_balance_sufficient(voucher_url_10_baht, mobile_number, product_price_9_50)) # ผลลัพธ์ False
    print(is_voucher_balance_sufficient(voucher_url_10_baht, mobile_number, product_price_10)) # ผลลัพธ์ True
    print(is_voucher_balance_sufficient(voucher_url_10_baht, mobile_number, product_price_10_50)) # ผลลัพธ์ False

    # verify_voucher()
    response = verify_voucher(voucher_url_10_baht, mobile_number)
    status_code = response['status']['code']
    if status_code == 'SUCCESS':
        print(response)
    elif status_code == 'INVALID_MOBILE_NUMBER':
        print('รูปแบบหมายเลขโทรศัพท์ไม่ถูกต้อง')
    elif status_code == 'CANNOT_GET_OWN_VOUCHER':
        print('เจ้าของซองทรูมันนี่ไม่สามารถรับเงินจากซองของตนเองได้')
    elif status_code == 'TARGET_USER_NOT_FOUND':
        print('ไม่พบหมายเลขโทรศัพท์นี้ในระบบ')
    elif status_code == 'INTERNAL_ERROR':
        print('ระบบของทรูมันนี่นี้ขัดข้อง')
    elif status_code == 'VOUCHER_OUT_OF_STOCK':
        print('เงินจากซองทรูมันนี่นี้มีคนก่อนหน้ารับไปหมดแล้ว')
    elif status_code == 'VOUCHER_NOT_FOUND':
        print('ไม่พบซองทรูมันนี่นี้ในระบบ')
    elif status_code == 'VOUCHER_EXPIRED':
        print('ซองทรูมันนี่นี้หมดอายุ')
    
    # redeem_voucher()
    response = redeem_voucher(voucher_url_10_baht, mobile_number)
    status_code = response['status']['code']
    if status_code == 'SUCCESS':
        print(response)
    elif status_code == 'INVALID_MOBILE_NUMBER':
        print('รูปแบบหมายเลขโทรศัพท์ไม่ถูกต้อง')
    elif status_code == 'CANNOT_GET_OWN_VOUCHER':
        print('เจ้าของซองทรูมันนี่ไม่สามารถรับเงินจากซองของตนเองได้')
    elif status_code == 'TARGET_USER_NOT_FOUND':
        print('ไม่พบหมายเลขโทรศัพท์นี้ในระบบ')
    elif status_code == 'INTERNAL_ERROR':
        print('ระบบของทรูมันนี่นี้ขัดข้อง')
    elif status_code == 'VOUCHER_OUT_OF_STOCK':
        print('เงินจากซองทรูมันนี่นี้มีคนก่อนหน้ารับไปหมดแล้ว')
    elif status_code == 'VOUCHER_NOT_FOUND':
        print('ไม่พบซองทรูมันนี่นี้ในระบบ')
    elif status_code == 'VOUCHER_EXPIRED':
        print('ซองทรูมันนี่นี้หมดอายุ')

คำเตือน

เนื่องจาก GiftReaper อาจมีการคืนค่าเป็น UTF-8 หากเกิดปัญหาด้านการแสดงผลอักขระ (เช่น ภาษาไทยไม่แสดงผล) ให้ลองเพิ่มโค้ดนี้ที่ต้นไฟล์ของคุณ:

import sys
import io

# ตั้งค่า stdout ให้รองรับ UTF-8
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')

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

giftreaper-0.0.2.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

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

GiftReaper-0.0.2-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file giftreaper-0.0.2.tar.gz.

File metadata

  • Download URL: giftreaper-0.0.2.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.0

File hashes

Hashes for giftreaper-0.0.2.tar.gz
Algorithm Hash digest
SHA256 135cb0e2593335206f22257f8ad179de2410277467e2e3d8b8b731aa945940e4
MD5 11643eadee51481afab1cc42e5efd8ee
BLAKE2b-256 66da9f5ca3e5efaab4596033524d0a67aea0b84376e290945289c8de73b01c53

See more details on using hashes here.

File details

Details for the file GiftReaper-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: GiftReaper-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.0

File hashes

Hashes for GiftReaper-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3cd8d0652897ff985770c70dbd2558bfbbccdcbbba37aaee773807fe0c723e49
MD5 939536d3b75e9dbcd49565f5bb638115
BLAKE2b-256 3645fd346c1d4e720b83077ee0aef36637914564336092276c8967f59e6b560a

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