loyaltyvip 1.0.0__tar.gz

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.
@@ -0,0 +1,10 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ .eggs/
5
+ build/
6
+ dist/
7
+ .venv/
8
+ venv/
9
+ .env
10
+ .DS_Store
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 movaMedia (LoyaltyVIP)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,49 @@
1
+ Metadata-Version: 2.4
2
+ Name: loyaltyvip
3
+ Version: 1.0.0
4
+ Summary: Python client for the LoyaltyVIP API — casino player intelligence: directory, tiers, trips, offers, comps, tax.
5
+ Project-URL: Homepage, https://loyaltyvip.com/developers
6
+ Project-URL: Documentation, https://loyaltyvip.com/developers
7
+ Project-URL: Repository, https://github.com/movaMedia-Inc/loyaltyvip-python
8
+ Project-URL: OpenAPI Spec, https://loyaltyvip.com/openapi.json
9
+ Author: movaMedia
10
+ License: MIT
11
+ License-File: LICENSE
12
+ Keywords: api,casino,loyalty,loyaltyvip,rewards,sdk
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Requires-Python: >=3.8
18
+ Description-Content-Type: text/markdown
19
+
20
+ # loyaltyvip (Python)
21
+
22
+ Official Python client for the [LoyaltyVIP](https://loyaltyvip.com) API — the privacy-first casino player intelligence platform. Standard library only (no dependencies). Python 3.8+.
23
+
24
+ ```bash
25
+ pip install loyaltyvip
26
+ ```
27
+
28
+ ```python
29
+ from loyaltyvip import LoyaltyVIP
30
+
31
+ lv = LoyaltyVIP() # public directory needs no key
32
+ res = lv.search_casinos(state="NV", has_rewards=True, limit=5)
33
+ for c in res["data"]:
34
+ print(c["name"], "-", c.get("city"), c.get("state"))
35
+
36
+ # Your own data needs a key (https://loyaltyvip.com/dashboard/developer):
37
+ import os
38
+ me = LoyaltyVIP(api_key=os.environ["LOYALTYVIP_API_KEY"])
39
+ print(me.player("tier_status"))
40
+ print(me.tax_report("generate_summary", tax_year=2025)) # scope: tax
41
+ ```
42
+
43
+ Methods: `search_casinos`, `get_casino`, `list_rewards_programs`, `get_rewards_program` (public); `me`, `tiers`, `trips`, `offers`, `player`, `comp`, `predict`, `tier_match`, `tax_report` (API key). Errors raise `LoyaltyVIPError` (`status`, `code`, `message`, `docs`).
44
+
45
+ - Docs: https://loyaltyvip.com/developers
46
+ - OpenAPI 3.1: https://loyaltyvip.com/openapi.json
47
+ - Auth guide: https://loyaltyvip.com/auth.md
48
+
49
+ LoyaltyVIP is independent and not affiliated with any casino brand — a record-keeping and analytics tool, not a gambling product. MIT © movaMedia.
@@ -0,0 +1,30 @@
1
+ # loyaltyvip (Python)
2
+
3
+ Official Python client for the [LoyaltyVIP](https://loyaltyvip.com) API — the privacy-first casino player intelligence platform. Standard library only (no dependencies). Python 3.8+.
4
+
5
+ ```bash
6
+ pip install loyaltyvip
7
+ ```
8
+
9
+ ```python
10
+ from loyaltyvip import LoyaltyVIP
11
+
12
+ lv = LoyaltyVIP() # public directory needs no key
13
+ res = lv.search_casinos(state="NV", has_rewards=True, limit=5)
14
+ for c in res["data"]:
15
+ print(c["name"], "-", c.get("city"), c.get("state"))
16
+
17
+ # Your own data needs a key (https://loyaltyvip.com/dashboard/developer):
18
+ import os
19
+ me = LoyaltyVIP(api_key=os.environ["LOYALTYVIP_API_KEY"])
20
+ print(me.player("tier_status"))
21
+ print(me.tax_report("generate_summary", tax_year=2025)) # scope: tax
22
+ ```
23
+
24
+ Methods: `search_casinos`, `get_casino`, `list_rewards_programs`, `get_rewards_program` (public); `me`, `tiers`, `trips`, `offers`, `player`, `comp`, `predict`, `tier_match`, `tax_report` (API key). Errors raise `LoyaltyVIPError` (`status`, `code`, `message`, `docs`).
25
+
26
+ - Docs: https://loyaltyvip.com/developers
27
+ - OpenAPI 3.1: https://loyaltyvip.com/openapi.json
28
+ - Auth guide: https://loyaltyvip.com/auth.md
29
+
30
+ LoyaltyVIP is independent and not affiliated with any casino brand — a record-keeping and analytics tool, not a gambling product. MIT © movaMedia.
@@ -0,0 +1,16 @@
1
+ """Run: python examples/quickstart.py (no key needed for the directory)."""
2
+
3
+ import os
4
+
5
+ from loyaltyvip import LoyaltyVIP
6
+
7
+ lv = LoyaltyVIP(api_key=os.environ.get("LOYALTYVIP_API_KEY"))
8
+
9
+ res = lv.search_casinos(state="NV", has_rewards=True, limit=5)
10
+ print(f"Found {res.get('count', len(res['data']))} casinos; first 5:")
11
+ for c in res["data"]:
12
+ print(f" - {c['name']} ({c.get('city')}, {c.get('state')})")
13
+
14
+ if os.environ.get("LOYALTYVIP_API_KEY"):
15
+ print("\nYour tier status:")
16
+ print(lv.player("tier_status"))
@@ -0,0 +1,29 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "loyaltyvip"
7
+ version = "1.0.0"
8
+ description = "Python client for the LoyaltyVIP API — casino player intelligence: directory, tiers, trips, offers, comps, tax."
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ license = { text = "MIT" }
12
+ authors = [{ name = "movaMedia" }]
13
+ keywords = ["loyaltyvip", "casino", "loyalty", "rewards", "api", "sdk"]
14
+ dependencies = []
15
+ classifiers = [
16
+ "Programming Language :: Python :: 3",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Operating System :: OS Independent",
19
+ "Intended Audience :: Developers",
20
+ ]
21
+
22
+ [project.urls]
23
+ Homepage = "https://loyaltyvip.com/developers"
24
+ Documentation = "https://loyaltyvip.com/developers"
25
+ Repository = "https://github.com/movaMedia-Inc/loyaltyvip-python"
26
+ "OpenAPI Spec" = "https://loyaltyvip.com/openapi.json"
27
+
28
+ [tool.hatch.build.targets.wheel]
29
+ packages = ["src/loyaltyvip"]
@@ -0,0 +1,9 @@
1
+ """LoyaltyVIP Python SDK — casino player intelligence API client.
2
+
3
+ See https://loyaltyvip.com/developers for docs.
4
+ """
5
+
6
+ from .client import DEFAULT_BASE_URL, LoyaltyVIP, LoyaltyVIPError
7
+
8
+ __version__ = "1.0.0"
9
+ __all__ = ["LoyaltyVIP", "LoyaltyVIPError", "DEFAULT_BASE_URL", "__version__"]
@@ -0,0 +1,153 @@
1
+ """LoyaltyVIP API client (standard library only).
2
+
3
+ The public casino directory needs no key. A player's own data requires a
4
+ personal API key (``lvip_live_...``) minted at
5
+ https://loyaltyvip.com/dashboard/developer.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import json
11
+ import urllib.error
12
+ import urllib.parse
13
+ import urllib.request
14
+ from typing import Any, Optional
15
+
16
+ DEFAULT_BASE_URL = "https://nbhagdwegk.execute-api.us-east-1.amazonaws.com"
17
+
18
+ __all__ = ["LoyaltyVIP", "LoyaltyVIPError", "DEFAULT_BASE_URL"]
19
+
20
+
21
+ class LoyaltyVIPError(Exception):
22
+ """Raised on any non-2xx API response. Carries the typed error envelope."""
23
+
24
+ def __init__(self, status: int, code: str, message: str, docs: Optional[str] = None) -> None:
25
+ super().__init__(f"{status} ({code}): {message}")
26
+ self.status = status
27
+ self.code = code
28
+ self.message = message
29
+ self.docs = docs
30
+
31
+
32
+ class LoyaltyVIP:
33
+ """A thin, typed-ish client for the LoyaltyVIP REST API."""
34
+
35
+ def __init__(
36
+ self,
37
+ api_key: Optional[str] = None,
38
+ base_url: str = DEFAULT_BASE_URL,
39
+ timeout: float = 30.0,
40
+ ) -> None:
41
+ self.api_key = api_key
42
+ self.base_url = base_url.rstrip("/")
43
+ self.timeout = timeout
44
+
45
+ # ── Public directory (no key) ────────────────────────────────────────
46
+
47
+ def search_casinos(
48
+ self,
49
+ q: Optional[str] = None,
50
+ state: Optional[str] = None,
51
+ type: Optional[str] = None, # noqa: A002 - mirrors the API param name
52
+ has_rewards: Optional[bool] = None,
53
+ limit: Optional[int] = None,
54
+ offset: Optional[int] = None,
55
+ ) -> dict[str, Any]:
56
+ """Search the public U.S. casino directory."""
57
+ return self._get(
58
+ "/v1/casinos",
59
+ {"q": q, "state": state, "type": type, "has_rewards": has_rewards, "limit": limit, "offset": offset},
60
+ )
61
+
62
+ def get_casino(self, slug: str) -> dict[str, Any]:
63
+ """Casino detail including rewards program and full tier ladder."""
64
+ return self._get(f"/v1/casinos/{urllib.parse.quote(slug)}")
65
+
66
+ def list_rewards_programs(
67
+ self, search: Optional[str] = None, brand: Optional[str] = None, limit: Optional[int] = None
68
+ ) -> dict[str, Any]:
69
+ """List casino rewards / players-club programs."""
70
+ return self._get("/v1/rewards-programs", {"search": search, "brand": brand, "limit": limit})
71
+
72
+ def get_rewards_program(self, program_id: str) -> dict[str, Any]:
73
+ """A single rewards program with its tier ladder."""
74
+ return self._get(f"/v1/rewards-programs/{urllib.parse.quote(program_id)}")
75
+
76
+ # ── Account / actions (API key required) ─────────────────────────────
77
+
78
+ def me(self) -> dict[str, Any]:
79
+ return self._get("/v1/me", auth=True)
80
+
81
+ def tiers(self) -> dict[str, Any]:
82
+ return self._get("/v1/tiers", auth=True)
83
+
84
+ def trips(self) -> dict[str, Any]:
85
+ return self._get("/v1/trips", auth=True)
86
+
87
+ def offers(self) -> dict[str, Any]:
88
+ return self._get("/v1/offers", auth=True)
89
+
90
+ def player(self, action: str, **params: Any) -> dict[str, Any]:
91
+ """Invoke any /v1/player action (read/write/tax/host scopes apply)."""
92
+ return self._post("/v1/player", {"action": action, **params}, auth=True)
93
+
94
+ def comp(self, action: str, **params: Any) -> dict[str, Any]:
95
+ return self._post("/v1/comp/calculate", {"action": action, **params}, auth=True)
96
+
97
+ def predict(self, action: str, **params: Any) -> dict[str, Any]:
98
+ return self._post("/v1/comp/predict", {"action": action, **params}, auth=True)
99
+
100
+ def tier_match(self, action: str, **params: Any) -> dict[str, Any]:
101
+ return self._post("/v1/tier-match", {"action": action, **params}, auth=True)
102
+
103
+ def tax_report(self, action: str, **params: Any) -> dict[str, Any]:
104
+ """IRS gambling tax documents (scope: tax)."""
105
+ return self._post("/v1/tax-report", {"action": action, **params}, auth=True)
106
+
107
+ # ── Internals ─────────────────────────────────────────────────────────
108
+
109
+ def _headers(self, auth: bool) -> dict[str, str]:
110
+ headers = {"accept": "application/json"}
111
+ if auth and not self.api_key:
112
+ raise LoyaltyVIPError(401, "invalid_token", "This call requires an API key. Pass api_key=...")
113
+ if self.api_key:
114
+ headers["authorization"] = f"Bearer {self.api_key}"
115
+ return headers
116
+
117
+ def _get(self, path: str, query: Optional[dict[str, Any]] = None, auth: bool = False) -> dict[str, Any]:
118
+ url = self.base_url + path
119
+ if query:
120
+ clean = {k: v for k, v in query.items() if v is not None and v != ""}
121
+ if clean:
122
+ # Booleans must serialize as lowercase true/false.
123
+ for k, v in list(clean.items()):
124
+ if isinstance(v, bool):
125
+ clean[k] = "true" if v else "false"
126
+ url += "?" + urllib.parse.urlencode(clean)
127
+ return self._request("GET", url, None, auth)
128
+
129
+ def _post(self, path: str, body: dict[str, Any], auth: bool = False) -> dict[str, Any]:
130
+ return self._request("POST", self.base_url + path, body, auth)
131
+
132
+ def _request(self, method: str, url: str, body: Optional[dict[str, Any]], auth: bool) -> dict[str, Any]:
133
+ headers = self._headers(auth)
134
+ data = None
135
+ if body is not None:
136
+ headers["content-type"] = "application/json"
137
+ data = json.dumps(body).encode("utf-8")
138
+ req = urllib.request.Request(url, data=data, headers=headers, method=method)
139
+ try:
140
+ with urllib.request.urlopen(req, timeout=self.timeout) as resp:
141
+ return json.loads(resp.read().decode("utf-8") or "{}")
142
+ except urllib.error.HTTPError as exc:
143
+ raw = exc.read().decode("utf-8", "replace")
144
+ try:
145
+ err = json.loads(raw).get("error", {})
146
+ except json.JSONDecodeError:
147
+ err = {}
148
+ raise LoyaltyVIPError(
149
+ exc.code,
150
+ err.get("code", "error"),
151
+ err.get("message", f"Request failed with {exc.code}"),
152
+ err.get("docs"),
153
+ ) from None