huntrecht-sdk 0.1.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.
- huntrecht_sdk-0.1.0/PKG-INFO +307 -0
- huntrecht_sdk-0.1.0/README.md +279 -0
- huntrecht_sdk-0.1.0/huntrecht/__init__.py +96 -0
- huntrecht_sdk-0.1.0/huntrecht/app_proxy.py +65 -0
- huntrecht_sdk-0.1.0/huntrecht/auth.py +42 -0
- huntrecht_sdk-0.1.0/huntrecht/base.py +19 -0
- huntrecht_sdk-0.1.0/huntrecht/client.py +291 -0
- huntrecht_sdk-0.1.0/huntrecht/clients.py +48 -0
- huntrecht_sdk-0.1.0/huntrecht/credit.py +24 -0
- huntrecht_sdk-0.1.0/huntrecht/credit_risk.py +104 -0
- huntrecht_sdk-0.1.0/huntrecht/exceptions.py +44 -0
- huntrecht_sdk-0.1.0/huntrecht/kyc.py +38 -0
- huntrecht_sdk-0.1.0/huntrecht/linked_payments.py +54 -0
- huntrecht_sdk-0.1.0/huntrecht/orders.py +40 -0
- huntrecht_sdk-0.1.0/huntrecht/payments.py +39 -0
- huntrecht_sdk-0.1.0/huntrecht/price_drops.py +35 -0
- huntrecht_sdk-0.1.0/huntrecht/quotes.py +30 -0
- huntrecht_sdk-0.1.0/huntrecht/storefront.py +61 -0
- huntrecht_sdk-0.1.0/huntrecht/subscriptions.py +28 -0
- huntrecht_sdk-0.1.0/huntrecht/types_.py +358 -0
- huntrecht_sdk-0.1.0/huntrecht/users.py +15 -0
- huntrecht_sdk-0.1.0/huntrecht_sdk.egg-info/PKG-INFO +307 -0
- huntrecht_sdk-0.1.0/huntrecht_sdk.egg-info/SOURCES.txt +26 -0
- huntrecht_sdk-0.1.0/huntrecht_sdk.egg-info/dependency_links.txt +1 -0
- huntrecht_sdk-0.1.0/huntrecht_sdk.egg-info/requires.txt +9 -0
- huntrecht_sdk-0.1.0/huntrecht_sdk.egg-info/top_level.txt +1 -0
- huntrecht_sdk-0.1.0/pyproject.toml +53 -0
- huntrecht_sdk-0.1.0/setup.cfg +4 -0
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: huntrecht-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official Python SDK for the Huntrecht Platform API v1
|
|
5
|
+
Author-email: Huntrecht <dev@huntrecht.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/huntrecht/sdk-python
|
|
8
|
+
Project-URL: Documentation, https://docs.huntrecht.com/guide/
|
|
9
|
+
Project-URL: Repository, https://github.com/huntrecht/sdk-python
|
|
10
|
+
Keywords: huntrecht,api,sdk,b2b,ecommerce,trading
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Typing :: Typed
|
|
18
|
+
Requires-Python: >=3.10
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
Requires-Dist: httpx>=0.25.0
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
23
|
+
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
24
|
+
Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
|
|
25
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
26
|
+
Requires-Dist: mypy>=1.0; extra == "dev"
|
|
27
|
+
Requires-Dist: responses>=0.23; extra == "dev"
|
|
28
|
+
|
|
29
|
+
# GraphQL Data Connect SDK - Python Implementation
|
|
30
|
+
|
|
31
|
+
Complete GraphQL server for ingesting customer credit history from external data providers and feeding it to the RAG pipeline with automatic Shopify B2B company mapping.
|
|
32
|
+
|
|
33
|
+
## Features
|
|
34
|
+
|
|
35
|
+
✅ **GraphQL Server** with Strawberry GraphQL
|
|
36
|
+
✅ **Data Provider Connectors** for external GraphQL APIs
|
|
37
|
+
✅ **Shopify B2B Company Registry** with auto-creation
|
|
38
|
+
✅ **RAG Pipeline Integration** with LangChain documents
|
|
39
|
+
✅ **PostgreSQL Storage** with optimized indexes
|
|
40
|
+
✅ **Credit History Analytics** with aggregated views
|
|
41
|
+
✅ **Multi-Provider Support** with connector framework
|
|
42
|
+
|
|
43
|
+
## Quick Start
|
|
44
|
+
|
|
45
|
+
### 1. Access GraphiQL IDE
|
|
46
|
+
|
|
47
|
+
Navigate to http://localhost:5000/graphql/credit-history in your browser to access the interactive GraphQL playground.
|
|
48
|
+
|
|
49
|
+
### 2. Example Queries
|
|
50
|
+
|
|
51
|
+
#### Fetch Credit History
|
|
52
|
+
```graphql
|
|
53
|
+
query GetCreditHistory {
|
|
54
|
+
creditHistory(
|
|
55
|
+
companyId: "ext_company_123"
|
|
56
|
+
startDate: "2025-01-01T00:00:00Z"
|
|
57
|
+
limit: 50
|
|
58
|
+
) {
|
|
59
|
+
totalCount
|
|
60
|
+
edges {
|
|
61
|
+
node {
|
|
62
|
+
id
|
|
63
|
+
companyId
|
|
64
|
+
shopifyCompanyId
|
|
65
|
+
email
|
|
66
|
+
date
|
|
67
|
+
inflow
|
|
68
|
+
outflow
|
|
69
|
+
reference
|
|
70
|
+
bank
|
|
71
|
+
currency
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
pageInfo {
|
|
75
|
+
hasNextPage
|
|
76
|
+
endCursor
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
#### Get Company Summary
|
|
83
|
+
```graphql
|
|
84
|
+
query GetCompanySummary {
|
|
85
|
+
companyCreditSummary(
|
|
86
|
+
shopifyCompanyId: "gid://shopify/Company/12345"
|
|
87
|
+
)
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### 3. Example Mutations
|
|
92
|
+
|
|
93
|
+
#### Ingest Credit History
|
|
94
|
+
```graphql
|
|
95
|
+
mutation IngestCreditHistory {
|
|
96
|
+
ingestCreditHistory(
|
|
97
|
+
providerId: "provider_1"
|
|
98
|
+
companyId: "ext_company_123"
|
|
99
|
+
enrichShopify: true
|
|
100
|
+
records: [
|
|
101
|
+
{
|
|
102
|
+
companyId: "ext_company_123"
|
|
103
|
+
email: "finance@acmecorp.com"
|
|
104
|
+
date: "2025-01-15T10:30:00Z"
|
|
105
|
+
reference: "Invoice payment - INV-2025-001"
|
|
106
|
+
inflow: 50000.00
|
|
107
|
+
outflow: 0.00
|
|
108
|
+
accountName: "Acme Corporation Ltd"
|
|
109
|
+
accountNumber: "****1234"
|
|
110
|
+
bank: "First National Bank"
|
|
111
|
+
currency: "USD"
|
|
112
|
+
}
|
|
113
|
+
]
|
|
114
|
+
) {
|
|
115
|
+
success
|
|
116
|
+
recordsProcessed
|
|
117
|
+
recordsEnriched
|
|
118
|
+
shopifyCompaniesCreated
|
|
119
|
+
errors
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
#### Trigger Provider Sync
|
|
125
|
+
```graphql
|
|
126
|
+
mutation TriggerSync {
|
|
127
|
+
triggerProviderSync(
|
|
128
|
+
providerId: "provider_1"
|
|
129
|
+
companyId: "ext_company_123"
|
|
130
|
+
startDate: "2025-01-01T00:00:00Z"
|
|
131
|
+
) {
|
|
132
|
+
success
|
|
133
|
+
recordsProcessed
|
|
134
|
+
recordsEnriched
|
|
135
|
+
shopifyCompaniesCreated
|
|
136
|
+
errors
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Architecture
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
┌──────────────────────┐
|
|
145
|
+
│ External Provider │
|
|
146
|
+
│ GraphQL API │
|
|
147
|
+
└──────────┬───────────┘
|
|
148
|
+
│
|
|
149
|
+
▼
|
|
150
|
+
┌──────────────────────┐
|
|
151
|
+
│ Data Provider │
|
|
152
|
+
│ Connector │
|
|
153
|
+
│ (Extract & Transform)
|
|
154
|
+
└──────────┬───────────┘
|
|
155
|
+
│
|
|
156
|
+
▼
|
|
157
|
+
┌──────────────────────┐
|
|
158
|
+
│ Shopify Company │
|
|
159
|
+
│ Registry │
|
|
160
|
+
│ (Map/Create) │
|
|
161
|
+
└──────────┬───────────┘
|
|
162
|
+
│
|
|
163
|
+
▼
|
|
164
|
+
┌──────────────────────┐
|
|
165
|
+
│ Credit History │
|
|
166
|
+
│ RAG Loader │
|
|
167
|
+
│ (LangChain Docs) │
|
|
168
|
+
└──────────┬───────────┘
|
|
169
|
+
│
|
|
170
|
+
▼
|
|
171
|
+
┌──────────────────────┐
|
|
172
|
+
│ Analytics RAG │
|
|
173
|
+
│ Pipeline │
|
|
174
|
+
│ (Groq LLM) │
|
|
175
|
+
└──────────────────────┘
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Components
|
|
179
|
+
|
|
180
|
+
### 1. GraphQL Schema (`credit_history_schema.py`)
|
|
181
|
+
- Strawberry GraphQL types and schema
|
|
182
|
+
- Queries: `creditHistory`, `companyCreditSummary`
|
|
183
|
+
- Mutations: `ingestCreditHistory`, `triggerProviderSync`
|
|
184
|
+
|
|
185
|
+
### 2. Data Provider Connector (`data_provider_connector.py`)
|
|
186
|
+
- Abstract connector framework
|
|
187
|
+
- Generic GraphQL provider implementation
|
|
188
|
+
- Provider registry for multi-source support
|
|
189
|
+
|
|
190
|
+
### 3. Shopify Company Registry (`shopify_company_registry.py`)
|
|
191
|
+
- External ID → Shopify B2B company ID mapping
|
|
192
|
+
- Auto-creation of missing companies
|
|
193
|
+
- Database caching with 1-hour TTL
|
|
194
|
+
|
|
195
|
+
### 4. RAG Loader (`credit_history_rag_loader.py`)
|
|
196
|
+
- PostgreSQL storage with deduplication
|
|
197
|
+
- LangChain document creation
|
|
198
|
+
- Credit history analytics summaries
|
|
199
|
+
|
|
200
|
+
### 5. GraphQL Resolvers (`credit_history_resolvers.py`)
|
|
201
|
+
- Query and mutation resolvers
|
|
202
|
+
- ETL pipeline orchestration
|
|
203
|
+
- Error handling and validation
|
|
204
|
+
|
|
205
|
+
## Database Schema
|
|
206
|
+
|
|
207
|
+
### Tables
|
|
208
|
+
|
|
209
|
+
**company_id_mappings**
|
|
210
|
+
- Maps external company IDs to Shopify B2B company GIDs
|
|
211
|
+
- Prevents duplicate company creation
|
|
212
|
+
|
|
213
|
+
**credit_history**
|
|
214
|
+
- Stores all credit transactions
|
|
215
|
+
- Indexed by company, date, provider
|
|
216
|
+
- JSONB metadata for provider-specific fields
|
|
217
|
+
|
|
218
|
+
**data_provider_configs**
|
|
219
|
+
- Registry of configured data providers
|
|
220
|
+
- Encrypted API keys
|
|
221
|
+
- Active/inactive status
|
|
222
|
+
|
|
223
|
+
### Views
|
|
224
|
+
|
|
225
|
+
**credit_history_summary**
|
|
226
|
+
- Aggregated metrics by company and currency
|
|
227
|
+
- Total inflow, outflow, net position
|
|
228
|
+
- Transaction counts and date ranges
|
|
229
|
+
|
|
230
|
+
## API Endpoints
|
|
231
|
+
|
|
232
|
+
| Endpoint | Method | Description |
|
|
233
|
+
|----------|--------|-------------|
|
|
234
|
+
| `/graphql/credit-history` | POST | GraphQL API endpoint |
|
|
235
|
+
| `/graphql/credit-history` | GET | GraphiQL IDE |
|
|
236
|
+
|
|
237
|
+
## Security
|
|
238
|
+
|
|
239
|
+
🔒 **Data Protection**
|
|
240
|
+
- TLS 1.2+ for all API connections
|
|
241
|
+
- Encrypted API keys in database
|
|
242
|
+
- Field-level encryption for account numbers
|
|
243
|
+
- Audit logs for data access
|
|
244
|
+
|
|
245
|
+
🔐 **Authentication**
|
|
246
|
+
- API key authentication for data providers
|
|
247
|
+
- OAuth client credentials support
|
|
248
|
+
- Session-based auth for GraphiQL
|
|
249
|
+
|
|
250
|
+
## Environment Variables
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
# Database
|
|
254
|
+
DATABASE_URL=postgresql://user:pass@host:5432/db
|
|
255
|
+
|
|
256
|
+
# Shopify
|
|
257
|
+
SHOPIFY_ADMIN_API_KEY=your_admin_api_key
|
|
258
|
+
SHOPIFY_SHOP_NAME=your-shop.myshopify.com
|
|
259
|
+
|
|
260
|
+
# Data Provider (example)
|
|
261
|
+
PROVIDER_API_URL=https://provider.example.com/graphql
|
|
262
|
+
PROVIDER_API_KEY=your_provider_api_key
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
## Next Steps
|
|
266
|
+
|
|
267
|
+
1. **Register Data Provider**
|
|
268
|
+
```python
|
|
269
|
+
from sdk.python.data_provider_connector import DataProviderRegistry
|
|
270
|
+
|
|
271
|
+
registry = DataProviderRegistry()
|
|
272
|
+
registry.register_provider(
|
|
273
|
+
provider_id="my_provider",
|
|
274
|
+
api_url="https://provider.example.com/graphql",
|
|
275
|
+
api_key="your_api_key"
|
|
276
|
+
)
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
2. **Query Credit History via GraphQL**
|
|
280
|
+
- Use GraphiQL IDE or POST to `/graphql/credit-history`
|
|
281
|
+
|
|
282
|
+
3. **Integrate with Analytics Agent**
|
|
283
|
+
- Credit history automatically available in RAG pipeline
|
|
284
|
+
- Query via analytics_agent for AI-powered insights
|
|
285
|
+
|
|
286
|
+
## Troubleshooting
|
|
287
|
+
|
|
288
|
+
**Issue**: GraphQL queries return empty results
|
|
289
|
+
**Solution**: Check that records have been ingested and `shopify_company_id` is enriched
|
|
290
|
+
|
|
291
|
+
**Issue**: Company auto-creation fails
|
|
292
|
+
**Solution**: Verify Shopify Admin API credentials and `write_companies` scope
|
|
293
|
+
|
|
294
|
+
**Issue**: Provider sync fails
|
|
295
|
+
**Solution**: Validate provider GraphQL schema matches expected structure
|
|
296
|
+
|
|
297
|
+
## Support
|
|
298
|
+
|
|
299
|
+
For issues or questions:
|
|
300
|
+
1. Check GraphiQL IDE error messages
|
|
301
|
+
2. Review database logs in PostgreSQL
|
|
302
|
+
3. Verify provider API connectivity
|
|
303
|
+
4. Ensure Shopify B2B company exists
|
|
304
|
+
|
|
305
|
+
---
|
|
306
|
+
|
|
307
|
+
Built with ❤️ using Strawberry GraphQL, LangChain, and FastAPI
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
# GraphQL Data Connect SDK - Python Implementation
|
|
2
|
+
|
|
3
|
+
Complete GraphQL server for ingesting customer credit history from external data providers and feeding it to the RAG pipeline with automatic Shopify B2B company mapping.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
✅ **GraphQL Server** with Strawberry GraphQL
|
|
8
|
+
✅ **Data Provider Connectors** for external GraphQL APIs
|
|
9
|
+
✅ **Shopify B2B Company Registry** with auto-creation
|
|
10
|
+
✅ **RAG Pipeline Integration** with LangChain documents
|
|
11
|
+
✅ **PostgreSQL Storage** with optimized indexes
|
|
12
|
+
✅ **Credit History Analytics** with aggregated views
|
|
13
|
+
✅ **Multi-Provider Support** with connector framework
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
### 1. Access GraphiQL IDE
|
|
18
|
+
|
|
19
|
+
Navigate to http://localhost:5000/graphql/credit-history in your browser to access the interactive GraphQL playground.
|
|
20
|
+
|
|
21
|
+
### 2. Example Queries
|
|
22
|
+
|
|
23
|
+
#### Fetch Credit History
|
|
24
|
+
```graphql
|
|
25
|
+
query GetCreditHistory {
|
|
26
|
+
creditHistory(
|
|
27
|
+
companyId: "ext_company_123"
|
|
28
|
+
startDate: "2025-01-01T00:00:00Z"
|
|
29
|
+
limit: 50
|
|
30
|
+
) {
|
|
31
|
+
totalCount
|
|
32
|
+
edges {
|
|
33
|
+
node {
|
|
34
|
+
id
|
|
35
|
+
companyId
|
|
36
|
+
shopifyCompanyId
|
|
37
|
+
email
|
|
38
|
+
date
|
|
39
|
+
inflow
|
|
40
|
+
outflow
|
|
41
|
+
reference
|
|
42
|
+
bank
|
|
43
|
+
currency
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
pageInfo {
|
|
47
|
+
hasNextPage
|
|
48
|
+
endCursor
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
#### Get Company Summary
|
|
55
|
+
```graphql
|
|
56
|
+
query GetCompanySummary {
|
|
57
|
+
companyCreditSummary(
|
|
58
|
+
shopifyCompanyId: "gid://shopify/Company/12345"
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### 3. Example Mutations
|
|
64
|
+
|
|
65
|
+
#### Ingest Credit History
|
|
66
|
+
```graphql
|
|
67
|
+
mutation IngestCreditHistory {
|
|
68
|
+
ingestCreditHistory(
|
|
69
|
+
providerId: "provider_1"
|
|
70
|
+
companyId: "ext_company_123"
|
|
71
|
+
enrichShopify: true
|
|
72
|
+
records: [
|
|
73
|
+
{
|
|
74
|
+
companyId: "ext_company_123"
|
|
75
|
+
email: "finance@acmecorp.com"
|
|
76
|
+
date: "2025-01-15T10:30:00Z"
|
|
77
|
+
reference: "Invoice payment - INV-2025-001"
|
|
78
|
+
inflow: 50000.00
|
|
79
|
+
outflow: 0.00
|
|
80
|
+
accountName: "Acme Corporation Ltd"
|
|
81
|
+
accountNumber: "****1234"
|
|
82
|
+
bank: "First National Bank"
|
|
83
|
+
currency: "USD"
|
|
84
|
+
}
|
|
85
|
+
]
|
|
86
|
+
) {
|
|
87
|
+
success
|
|
88
|
+
recordsProcessed
|
|
89
|
+
recordsEnriched
|
|
90
|
+
shopifyCompaniesCreated
|
|
91
|
+
errors
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
#### Trigger Provider Sync
|
|
97
|
+
```graphql
|
|
98
|
+
mutation TriggerSync {
|
|
99
|
+
triggerProviderSync(
|
|
100
|
+
providerId: "provider_1"
|
|
101
|
+
companyId: "ext_company_123"
|
|
102
|
+
startDate: "2025-01-01T00:00:00Z"
|
|
103
|
+
) {
|
|
104
|
+
success
|
|
105
|
+
recordsProcessed
|
|
106
|
+
recordsEnriched
|
|
107
|
+
shopifyCompaniesCreated
|
|
108
|
+
errors
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Architecture
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
┌──────────────────────┐
|
|
117
|
+
│ External Provider │
|
|
118
|
+
│ GraphQL API │
|
|
119
|
+
└──────────┬───────────┘
|
|
120
|
+
│
|
|
121
|
+
▼
|
|
122
|
+
┌──────────────────────┐
|
|
123
|
+
│ Data Provider │
|
|
124
|
+
│ Connector │
|
|
125
|
+
│ (Extract & Transform)
|
|
126
|
+
└──────────┬───────────┘
|
|
127
|
+
│
|
|
128
|
+
▼
|
|
129
|
+
┌──────────────────────┐
|
|
130
|
+
│ Shopify Company │
|
|
131
|
+
│ Registry │
|
|
132
|
+
│ (Map/Create) │
|
|
133
|
+
└──────────┬───────────┘
|
|
134
|
+
│
|
|
135
|
+
▼
|
|
136
|
+
┌──────────────────────┐
|
|
137
|
+
│ Credit History │
|
|
138
|
+
│ RAG Loader │
|
|
139
|
+
│ (LangChain Docs) │
|
|
140
|
+
└──────────┬───────────┘
|
|
141
|
+
│
|
|
142
|
+
▼
|
|
143
|
+
┌──────────────────────┐
|
|
144
|
+
│ Analytics RAG │
|
|
145
|
+
│ Pipeline │
|
|
146
|
+
│ (Groq LLM) │
|
|
147
|
+
└──────────────────────┘
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Components
|
|
151
|
+
|
|
152
|
+
### 1. GraphQL Schema (`credit_history_schema.py`)
|
|
153
|
+
- Strawberry GraphQL types and schema
|
|
154
|
+
- Queries: `creditHistory`, `companyCreditSummary`
|
|
155
|
+
- Mutations: `ingestCreditHistory`, `triggerProviderSync`
|
|
156
|
+
|
|
157
|
+
### 2. Data Provider Connector (`data_provider_connector.py`)
|
|
158
|
+
- Abstract connector framework
|
|
159
|
+
- Generic GraphQL provider implementation
|
|
160
|
+
- Provider registry for multi-source support
|
|
161
|
+
|
|
162
|
+
### 3. Shopify Company Registry (`shopify_company_registry.py`)
|
|
163
|
+
- External ID → Shopify B2B company ID mapping
|
|
164
|
+
- Auto-creation of missing companies
|
|
165
|
+
- Database caching with 1-hour TTL
|
|
166
|
+
|
|
167
|
+
### 4. RAG Loader (`credit_history_rag_loader.py`)
|
|
168
|
+
- PostgreSQL storage with deduplication
|
|
169
|
+
- LangChain document creation
|
|
170
|
+
- Credit history analytics summaries
|
|
171
|
+
|
|
172
|
+
### 5. GraphQL Resolvers (`credit_history_resolvers.py`)
|
|
173
|
+
- Query and mutation resolvers
|
|
174
|
+
- ETL pipeline orchestration
|
|
175
|
+
- Error handling and validation
|
|
176
|
+
|
|
177
|
+
## Database Schema
|
|
178
|
+
|
|
179
|
+
### Tables
|
|
180
|
+
|
|
181
|
+
**company_id_mappings**
|
|
182
|
+
- Maps external company IDs to Shopify B2B company GIDs
|
|
183
|
+
- Prevents duplicate company creation
|
|
184
|
+
|
|
185
|
+
**credit_history**
|
|
186
|
+
- Stores all credit transactions
|
|
187
|
+
- Indexed by company, date, provider
|
|
188
|
+
- JSONB metadata for provider-specific fields
|
|
189
|
+
|
|
190
|
+
**data_provider_configs**
|
|
191
|
+
- Registry of configured data providers
|
|
192
|
+
- Encrypted API keys
|
|
193
|
+
- Active/inactive status
|
|
194
|
+
|
|
195
|
+
### Views
|
|
196
|
+
|
|
197
|
+
**credit_history_summary**
|
|
198
|
+
- Aggregated metrics by company and currency
|
|
199
|
+
- Total inflow, outflow, net position
|
|
200
|
+
- Transaction counts and date ranges
|
|
201
|
+
|
|
202
|
+
## API Endpoints
|
|
203
|
+
|
|
204
|
+
| Endpoint | Method | Description |
|
|
205
|
+
|----------|--------|-------------|
|
|
206
|
+
| `/graphql/credit-history` | POST | GraphQL API endpoint |
|
|
207
|
+
| `/graphql/credit-history` | GET | GraphiQL IDE |
|
|
208
|
+
|
|
209
|
+
## Security
|
|
210
|
+
|
|
211
|
+
🔒 **Data Protection**
|
|
212
|
+
- TLS 1.2+ for all API connections
|
|
213
|
+
- Encrypted API keys in database
|
|
214
|
+
- Field-level encryption for account numbers
|
|
215
|
+
- Audit logs for data access
|
|
216
|
+
|
|
217
|
+
🔐 **Authentication**
|
|
218
|
+
- API key authentication for data providers
|
|
219
|
+
- OAuth client credentials support
|
|
220
|
+
- Session-based auth for GraphiQL
|
|
221
|
+
|
|
222
|
+
## Environment Variables
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
# Database
|
|
226
|
+
DATABASE_URL=postgresql://user:pass@host:5432/db
|
|
227
|
+
|
|
228
|
+
# Shopify
|
|
229
|
+
SHOPIFY_ADMIN_API_KEY=your_admin_api_key
|
|
230
|
+
SHOPIFY_SHOP_NAME=your-shop.myshopify.com
|
|
231
|
+
|
|
232
|
+
# Data Provider (example)
|
|
233
|
+
PROVIDER_API_URL=https://provider.example.com/graphql
|
|
234
|
+
PROVIDER_API_KEY=your_provider_api_key
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## Next Steps
|
|
238
|
+
|
|
239
|
+
1. **Register Data Provider**
|
|
240
|
+
```python
|
|
241
|
+
from sdk.python.data_provider_connector import DataProviderRegistry
|
|
242
|
+
|
|
243
|
+
registry = DataProviderRegistry()
|
|
244
|
+
registry.register_provider(
|
|
245
|
+
provider_id="my_provider",
|
|
246
|
+
api_url="https://provider.example.com/graphql",
|
|
247
|
+
api_key="your_api_key"
|
|
248
|
+
)
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
2. **Query Credit History via GraphQL**
|
|
252
|
+
- Use GraphiQL IDE or POST to `/graphql/credit-history`
|
|
253
|
+
|
|
254
|
+
3. **Integrate with Analytics Agent**
|
|
255
|
+
- Credit history automatically available in RAG pipeline
|
|
256
|
+
- Query via analytics_agent for AI-powered insights
|
|
257
|
+
|
|
258
|
+
## Troubleshooting
|
|
259
|
+
|
|
260
|
+
**Issue**: GraphQL queries return empty results
|
|
261
|
+
**Solution**: Check that records have been ingested and `shopify_company_id` is enriched
|
|
262
|
+
|
|
263
|
+
**Issue**: Company auto-creation fails
|
|
264
|
+
**Solution**: Verify Shopify Admin API credentials and `write_companies` scope
|
|
265
|
+
|
|
266
|
+
**Issue**: Provider sync fails
|
|
267
|
+
**Solution**: Validate provider GraphQL schema matches expected structure
|
|
268
|
+
|
|
269
|
+
## Support
|
|
270
|
+
|
|
271
|
+
For issues or questions:
|
|
272
|
+
1. Check GraphiQL IDE error messages
|
|
273
|
+
2. Review database logs in PostgreSQL
|
|
274
|
+
3. Verify provider API connectivity
|
|
275
|
+
4. Ensure Shopify B2B company exists
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
279
|
+
Built with ❤️ using Strawberry GraphQL, LangChain, and FastAPI
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Huntrecht Platform SDK for Python
|
|
3
|
+
|
|
4
|
+
Official Python client for the Huntrecht Platform API v1.
|
|
5
|
+
Provides typed access to authentication, orders, subscriptions,
|
|
6
|
+
credit risk, KYC, quotes, storefront, and payments.
|
|
7
|
+
|
|
8
|
+
Usage:
|
|
9
|
+
from huntrecht import HuntrechtClient
|
|
10
|
+
|
|
11
|
+
client = HuntrechtClient(
|
|
12
|
+
base_url="https://api.huntrecht.com",
|
|
13
|
+
client_id="hnt_your_client_id",
|
|
14
|
+
client_secret="your_secret"
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
# Authenticate
|
|
18
|
+
tokens = client.auth.token()
|
|
19
|
+
print(f"Access token expires in {tokens.expires_in}s")
|
|
20
|
+
|
|
21
|
+
# List orders
|
|
22
|
+
orders = client.orders.list()
|
|
23
|
+
for order in orders.data:
|
|
24
|
+
print(f"Order {order.id}: {order.commodity}")
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
from huntrecht.client import HuntrechtClient
|
|
28
|
+
from huntrecht.exceptions import (
|
|
29
|
+
HuntrechtError,
|
|
30
|
+
AuthenticationError,
|
|
31
|
+
RateLimitError,
|
|
32
|
+
NotFoundError,
|
|
33
|
+
ValidationError,
|
|
34
|
+
PermissionError,
|
|
35
|
+
)
|
|
36
|
+
from huntrecht.types_ import (
|
|
37
|
+
TokenResponse,
|
|
38
|
+
ApiClientResponse,
|
|
39
|
+
ApiClientWithSecret,
|
|
40
|
+
UserProfile,
|
|
41
|
+
Order,
|
|
42
|
+
OrderListResponse,
|
|
43
|
+
Payment,
|
|
44
|
+
PaymentListResponse,
|
|
45
|
+
Subscription,
|
|
46
|
+
SubscriptionListResponse,
|
|
47
|
+
CreditScoreData,
|
|
48
|
+
CreditAssessmentData,
|
|
49
|
+
KycSubmission,
|
|
50
|
+
KycListResponse,
|
|
51
|
+
CommodityQuote,
|
|
52
|
+
QuoteListResponse,
|
|
53
|
+
CollectionResponse,
|
|
54
|
+
ProductResponse,
|
|
55
|
+
PriceDropEvent,
|
|
56
|
+
PriceDropListResponse,
|
|
57
|
+
PaymentEligibilityResponse,
|
|
58
|
+
LinkedWallet,
|
|
59
|
+
LinkedBank,
|
|
60
|
+
LinkedAccountsResponse,
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
__version__ = "0.1.0"
|
|
64
|
+
__all__ = [
|
|
65
|
+
"HuntrechtClient",
|
|
66
|
+
"HuntrechtError",
|
|
67
|
+
"AuthenticationError",
|
|
68
|
+
"RateLimitError",
|
|
69
|
+
"NotFoundError",
|
|
70
|
+
"ValidationError",
|
|
71
|
+
"PermissionError",
|
|
72
|
+
"TokenResponse",
|
|
73
|
+
"ApiClientResponse",
|
|
74
|
+
"ApiClientWithSecret",
|
|
75
|
+
"UserProfile",
|
|
76
|
+
"Order",
|
|
77
|
+
"OrderListResponse",
|
|
78
|
+
"Payment",
|
|
79
|
+
"PaymentListResponse",
|
|
80
|
+
"Subscription",
|
|
81
|
+
"SubscriptionListResponse",
|
|
82
|
+
"CreditScoreData",
|
|
83
|
+
"CreditAssessmentData",
|
|
84
|
+
"KycSubmission",
|
|
85
|
+
"KycListResponse",
|
|
86
|
+
"CommodityQuote",
|
|
87
|
+
"QuoteListResponse",
|
|
88
|
+
"CollectionResponse",
|
|
89
|
+
"ProductResponse",
|
|
90
|
+
"PriceDropEvent",
|
|
91
|
+
"PriceDropListResponse",
|
|
92
|
+
"PaymentEligibilityResponse",
|
|
93
|
+
"LinkedWallet",
|
|
94
|
+
"LinkedBank",
|
|
95
|
+
"LinkedAccountsResponse",
|
|
96
|
+
]
|