
    7|h                     t    d dl Z d dlZd dlmZmZ d dlmZ d dlm	Z	m
Z
 d dlmZ dddd	d
ddZ G d de      Zy)    N)ListOptional)Document)get_from_envstringify_dict)
BaseLoaderz.https://api.stripe.com/v1/balance_transactionsz!https://api.stripe.com/v1/chargesz#https://api.stripe.com/v1/customersz https://api.stripe.com/v1/eventsz!https://api.stripe.com/v1/refundsz"https://api.stripe.com/v1/disputes)balance_transactionscharges	customerseventsrefundsdisputesc                   f    e Zd ZdZddedee   ddfdZdedee   fdZ	dee   fd	Z
dee   fd
Zy)StripeLoaderzLoad from `Stripe` API.Nresourceaccess_tokenreturnc                 J    || _         |xs t        dd      }dd| i| _        y)zInitialize with a resource and an access token.

        Args:
            resource: The resource.
            access_token: The access token.
        r   STRIPE_ACCESS_TOKENAuthorizationzBearer N)r   r   headers)selfr   r   s      j/var/www/html/test/engine/venv/lib/python3.12/site-packages/langchain_community/document_loaders/stripe.py__init__zStripeLoader.__init__   s7     !# 
|1(
 (7<.)AB    urlc                 ^   t         j                  j                  || j                        }t         j                  j	                  |      5 }t        j                  |j                         j                               }t        |      }d|i}t        ||      gcd d d        S # 1 sw Y   y xY w)N)r   source)page_contentmetadata)urllibrequestRequestr   urlopenjsonloadsreaddecoder   r   )r   r   r"   response	json_datatextr    s          r   _make_requestzStripeLoader._make_request$   s    ..((dll(C^^##G, 	D

8==?#9#9#;<I!),D #H$BC		D 	D 	Ds   AB##B,c                 j    t         j                  | j                        }|g S | j                  |      S N)STRIPE_ENDPOINTSgetr   r,   )r   endpoints     r   _get_resourcezStripeLoader._get_resource-   s2    #''6I!!(++r   c                 "    | j                         S r.   )r2   )r   s    r   loadzStripeLoader.load3   s    !!##r   r.   )__name__
__module____qualname____doc__strr   r   r   r   r,   r2   r4    r   r   r   r      sa    !C CHSM CT CD Dh D,tH~ ,$d8n $r   r   )r%   urllib.requestr!   typingr   r   langchain_core.documentsr   langchain_core.utilsr   r   )langchain_community.document_loaders.baser   r/   r   r:   r   r   <module>r@      s@      ! - = @ M26024  $:  $r   