bookalimo 0.1.1__py3-none-any.whl → 0.1.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
bookalimo/_client.py CHANGED
@@ -10,6 +10,7 @@ from typing import Any, Optional, cast
10
10
  import httpx
11
11
  from pydantic import BaseModel
12
12
 
13
+ from .exceptions import BookALimoError
13
14
  from .models import (
14
15
  BookRequest,
15
16
  BookResponse,
@@ -37,20 +38,6 @@ def get_version() -> str:
37
38
  return __version__
38
39
 
39
40
 
40
- class BookALimoError(Exception):
41
- """Base exception for Book-A-Limo API errors."""
42
-
43
- def __init__(
44
- self,
45
- message: str,
46
- status_code: Optional[int] = None,
47
- response_data: Optional[dict[str, Any]] = None,
48
- ):
49
- super().__init__(message)
50
- self.status_code = status_code
51
- self.response_data = response_data or {}
52
-
53
-
54
41
  class BookALimoClient:
55
42
  """
56
43
  Base HTTP client for Book-A-Limo API.
@@ -63,9 +50,7 @@ class BookALimoClient:
63
50
  credentials: Credentials,
64
51
  user_agent: str = "bookalimo-python",
65
52
  version: Optional[str] = None,
66
- sandbox: bool = False,
67
53
  base_url: str = "https://api.bookalimo.com",
68
- base_url_sandbox: str = "https://sandbox.bookalimo.com",
69
54
  http_timeout: float = 5.0,
70
55
  ):
71
56
  """Initialize the client with an HTTP client."""
@@ -76,9 +61,7 @@ class BookALimoClient:
76
61
  "content-type": "application/json",
77
62
  "user-agent": f"{user_agent}/{version}",
78
63
  }
79
- self.sandbox = sandbox
80
64
  self.base_url = base_url
81
- self.base_url_sandbox = base_url_sandbox
82
65
  self.http_timeout = http_timeout
83
66
 
84
67
  def _convert_model_to_api_dict(self, data: dict[str, Any]) -> dict[str, Any]:
@@ -175,10 +158,6 @@ class BookALimoClient:
175
158
  result.append(char.lower())
176
159
  return "".join(result)
177
160
 
178
- def get_base_url(self) -> str:
179
- """Get the base URL for the API."""
180
- return self.base_url_sandbox if self.sandbox else self.base_url
181
-
182
161
  async def _make_request(
183
162
  self,
184
163
  endpoint: str,
@@ -201,7 +180,7 @@ class BookALimoClient:
201
180
  Raises:
202
181
  BookALimoError: On API errors or HTTP errors
203
182
  """
204
- url = f"{self.get_base_url()}{endpoint}"
183
+ url = f"{self.base_url}{endpoint}"
205
184
 
206
185
  # Convert model data to API format
207
186
  api_data = self._convert_model_to_api_dict(data.model_dump())
@@ -0,0 +1,15 @@
1
+ from typing import Any, Optional
2
+
3
+
4
+ class BookALimoError(Exception):
5
+ """Base exception for Book-A-Limo API errors."""
6
+
7
+ def __init__(
8
+ self,
9
+ message: str,
10
+ status_code: Optional[int] = None,
11
+ response_data: Optional[dict[str, Any]] = None,
12
+ ):
13
+ super().__init__(message)
14
+ self.status_code = status_code
15
+ self.response_data = response_data or {}
bookalimo/wrapper.py CHANGED
@@ -8,7 +8,8 @@ from typing import Any, Optional
8
8
 
9
9
  from httpx import AsyncClient
10
10
 
11
- from ._client import BookALimoClient, BookALimoError
11
+ from ._client import BookALimoClient
12
+ from .exceptions import BookALimoError
12
13
  from .models import (
13
14
  Address,
14
15
  Airport,
@@ -44,7 +45,8 @@ class BookALimo:
44
45
  self,
45
46
  credentials: Credentials,
46
47
  http_client: Optional[AsyncClient] = None,
47
- sandbox: bool = False,
48
+ base_url: str = "https://api.bookalimo.com",
49
+ http_timeout: float = 5.0,
48
50
  **kwargs: Any,
49
51
  ):
50
52
  """
@@ -52,7 +54,6 @@ class BookALimo:
52
54
 
53
55
  Args:
54
56
  credentials: User ID and password hash for authentication.
55
- sandbox: Set to True to use the sandbox environment.
56
57
  http_client: Optional custom httpx.AsyncClient instance.
57
58
  **kwargs: Additional options passed to the BookALimoClient.
58
59
  """
@@ -60,8 +61,9 @@ class BookALimo:
60
61
  self.http_client = http_client or AsyncClient()
61
62
  self.client = BookALimoClient(
62
63
  credentials=credentials,
63
- sandbox=sandbox,
64
64
  client=self.http_client,
65
+ base_url=base_url,
66
+ http_timeout=http_timeout,
65
67
  **kwargs,
66
68
  )
67
69
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bookalimo
3
- Version: 0.1.1
3
+ Version: 0.1.3
4
4
  Summary: Python wrapper for the Book-A-Limo API
5
5
  Author-email: Jonathan Oren <jonathan@bookalimo.com>
6
6
  Maintainer-email: Jonathan Oren <jonathan@bookalimo.com>
@@ -63,13 +63,13 @@ Dynamic: license-file
63
63
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
64
64
  [![Code style: ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
65
65
 
66
- A modern, async Python wrapper for the Book-A-Limo API with full type support.
66
+ A modern, async Python wrapper for the Book-A-Limo API with full type support. Built on top of `httpx` and `pydantic`.
67
67
 
68
68
  ## Features
69
69
 
70
- * **Async/await** (built on `httpx`)
71
- * **Typed Pydantic models** for requests & responses
72
- * **Input validation**
70
+ * **Asynchronous**
71
+ * **Fully Typed** for requests & responses
72
+ * **Input validation** including airports and addresses.
73
73
  * **Clean, minimal interface** for each API operation
74
74
  * **Custom exceptions & error handling**
75
75
  * **Tests and examples**
@@ -104,37 +104,26 @@ async def main():
104
104
  # For Travel Agents (customers: pass is_customer=True)
105
105
  credentials = create_credentials("TA10007", "your_password")
106
106
 
107
- async with AsyncClient() as http_client:
108
- async with BookALimo(credentials, http_client=http_client) as client:
109
- # Build locations
110
- pickup = create_airport_location("JFK", "New York")
111
- dropoff = create_address_location("53 East 34th Street, Manhattan")
112
-
113
- prices = await client.get_prices(
114
- rate_type=RateType.P2P,
115
- date_time="09/05/2025 12:44 AM",
116
- pickup=pickup,
117
- dropoff=dropoff,
118
- passengers=2,
119
- luggage=3,
120
- )
121
-
122
- print(f"Available cars: {len(prices.prices)}")
123
- for price in prices.prices:
124
- print(f"- {price.car_description}: ${price.price}")
107
+ async with BookALimo(credentials) as client:
108
+ # Build locations
109
+ pickup = create_airport_location("JFK", "New York")
110
+ dropoff = create_address_location("53 East 34th Street, Manhattan")
125
111
 
126
- if __name__ == "__main__":
127
- asyncio.run(main())
128
- ```
112
+ prices = await client.get_prices(
113
+ rate_type=RateType.P2P,
114
+ date_time="09/05/2025 12:44 AM",
115
+ pickup=pickup,
116
+ dropoff=dropoff,
117
+ passengers=2,
118
+ luggage=3,
119
+ )
129
120
 
130
- ### Using the Sandbox
121
+ print(f"Available cars: {len(prices.prices)}")
122
+ for price in prices.prices:
123
+ print(f"- {price.car_description}: ${price.price}")
131
124
 
132
- ```python
133
- async with AsyncClient() as http_client:
134
- async with BookALimo(
135
- credentials, http_client=http_client, sandbox=True
136
- ) as client:
137
- ...
125
+ if __name__ == "__main__":
126
+ asyncio.run(main())
138
127
  ```
139
128
 
140
129
  ## Authentication
@@ -251,7 +240,7 @@ stops = [
251
240
  ### Using Account Info (Travel Agents)
252
241
 
253
242
  ```python
254
- from bookalimo.models import Account # models (not re-exported at top-level)
243
+ from bookalimo.models import Account
255
244
 
256
245
  account = Account(
257
246
  id="TA10007",
@@ -289,7 +278,7 @@ cancel_result = await client.edit_reservation(
289
278
  ## Error Handling
290
279
 
291
280
  ```python
292
- from bookalimo._client import BookALimoError # currently defined here
281
+ from bookalimo.exceptions import BookALimoError
293
282
 
294
283
  try:
295
284
  reservations = await client.list_reservations()
@@ -320,7 +309,6 @@ mkdocs serve
320
309
 
321
310
  * Never log raw passwords or credit card numbers.
322
311
  * Store credentials securely (e.g., environment variables, secrets managers).
323
- * Use sandbox for testing.
324
312
 
325
313
  ## License
326
314
 
@@ -0,0 +1,11 @@
1
+ bookalimo/__init__.py,sha256=ch1t7uvw_F3zNpqb-IfH0n2sDwFLnAQDgm2lpwtvpj4,568
2
+ bookalimo/_client.py,sha256=vju39534nm-6TVBZ7H74VTZIKdYOAnQiN1nFUqifRTM,11166
3
+ bookalimo/exceptions.py,sha256=ubOUZiXGEOWZvXyz2D5f5zwxBlQZVDBv1uOPmokAQ6Q,404
4
+ bookalimo/models.py,sha256=-gvxrT7llrYLxSHWn3vpmvkQqnk2ejSd97Sw8BxgBLw,16420
5
+ bookalimo/py.typed,sha256=8PjyZ1aVoQpRVvt71muvuq5qE-jTFZkK-GLHkhdebmc,26
6
+ bookalimo/wrapper.py,sha256=tlhfGR6jQqnx33GO6d3fQZ8a5294UkftC1ORcvbhDww,11896
7
+ bookalimo-0.1.3.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ bookalimo-0.1.3.dist-info/METADATA,sha256=9CXiMDcKrhLe_2pHpVlYA7UTo8twYGmMOsl933V4vXo,8857
9
+ bookalimo-0.1.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
10
+ bookalimo-0.1.3.dist-info/top_level.txt,sha256=ZgYiDX2GfZCp4pevWn4X2qyEr-Dh7-cq5Y1j2jMhB1s,10
11
+ bookalimo-0.1.3.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- bookalimo/__init__.py,sha256=ch1t7uvw_F3zNpqb-IfH0n2sDwFLnAQDgm2lpwtvpj4,568
2
- bookalimo/_client.py,sha256=sGkTevqSi0PU8UbU4E2JBnstIuzLIq0R9N5cENy_fPg,11832
3
- bookalimo/models.py,sha256=-gvxrT7llrYLxSHWn3vpmvkQqnk2ejSd97Sw8BxgBLw,16420
4
- bookalimo/py.typed,sha256=8PjyZ1aVoQpRVvt71muvuq5qE-jTFZkK-GLHkhdebmc,26
5
- bookalimo/wrapper.py,sha256=ABs8ORdGnCeJoWH2YIM5VlC4ZioZSNg880ev-MySiTM,11840
6
- bookalimo-0.1.1.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- bookalimo-0.1.1.dist-info/METADATA,sha256=Yo2NZ-cwIU1ekDpeT5M3IF779xqY4vVtbxoVSIiuTvA,9225
8
- bookalimo-0.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
- bookalimo-0.1.1.dist-info/top_level.txt,sha256=ZgYiDX2GfZCp4pevWn4X2qyEr-Dh7-cq5Y1j2jMhB1s,10
10
- bookalimo-0.1.1.dist-info/RECORD,,