|
2 | 2 |
|
3 | 3 | Demonstrates the full lifecycle of an electronic commodity waybill |
4 | 4 | using the RS.ge WayBill SOAP service. |
| 5 | +
|
| 6 | +Note: Some SOAP endpoints return 500 on the sandbox intermittently. |
5 | 7 | """ |
6 | 8 |
|
7 | 9 | from rsge import ( |
|
10 | 12 | WayBillClient, |
11 | 13 | WayBillType, |
12 | 14 | ) |
| 15 | +from rsge.core.exceptions import RSGeAuthenticationError, RSGeConnectionError |
13 | 16 |
|
14 | 17 |
|
15 | 18 | def main(): |
16 | 19 | with WayBillClient('tbilisi', '123456') as client: |
17 | | - un_id, user_id = client.check_service_user() |
18 | | - print(f'Authenticated — TIN: {un_id}, User ID: {user_id}') |
| 20 | + # check_service_user() may return false on sandbox test accounts |
| 21 | + try: |
| 22 | + un_id, user_id = client.check_service_user() |
| 23 | + print(f'Authenticated — TIN: {un_id}, User ID: {user_id}') |
| 24 | + except RSGeAuthenticationError: |
| 25 | + print('Note: check_service_user() not available for this sandbox account') |
19 | 26 |
|
20 | 27 | wb = client.create_waybill( |
21 | 28 | waybill_type = WayBillType.TRANSPORTATION, |
@@ -50,17 +57,20 @@ def main(): |
50 | 57 |
|
51 | 58 | print(f'Goods: {len(wb.goods_list)} items, total: {wb.full_amount} GEL') |
52 | 59 |
|
53 | | - result = client.save_waybill(wb) |
54 | | - if result.is_success: |
55 | | - print(f'Saved — Waybill ID: {result.waybill_id}') |
| 60 | + try: |
| 61 | + result = client.save_waybill(wb) |
| 62 | + if result.is_success: |
| 63 | + print(f'Saved — Waybill ID: {result.waybill_id}') |
56 | 64 |
|
57 | | - wb_number = client.activate_waybill(result.waybill_id) |
58 | | - print(f'Activated — Number: {wb_number}') |
| 65 | + wb_number = client.activate_waybill(result.waybill_id) |
| 66 | + print(f'Activated — Number: {wb_number}') |
59 | 67 |
|
60 | | - client.close_waybill(result.waybill_id) |
61 | | - print('Closed — Delivery complete') |
62 | | - else: |
63 | | - print(f'Save failed: code {result.status}') |
| 68 | + client.close_waybill(result.waybill_id) |
| 69 | + print('Closed — Delivery complete') |
| 70 | + else: |
| 71 | + print(f'Save failed: code {result.status}') |
| 72 | + except (RSGeAuthenticationError, RSGeConnectionError) as exc: |
| 73 | + print(f'Note: Sandbox limitation: {exc}') |
64 | 74 |
|
65 | 75 |
|
66 | 76 | if __name__ == '__main__': |
|
0 commit comments