o
    ÖtBh`  ã                   @   s:   d dl Z ddlmZ d dlmZ d dlZG dd„ dƒZdS )é    Né   )ÚShopifyResource)Úurllibc                   @   s&   e Zd Zdd„ Zdd„ Zddd„ZdS )	ÚGraphQLc                 C   s    t j ¡ d | _t j ¡ | _d S )Nz/graphql.json)Úshopifyr   Úget_siteÚendpointÚget_headersÚheaders)Úself© r   úp/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/shopify/resources/graphql.pyÚ__init__   s   zGraphQL.__init__c                 G   s   i }|D ]}|  |¡ q|S )N)Úupdate)r   r
   Úmerged_headersÚheaderr   r   r   Úmerge_headers   s   zGraphQL.merge_headersNc              
   C   sš   | j }dddœ}|  || j¡}|||dœ}tj | j t |¡ d¡|¡}ztj 	|¡}	|	 
¡  d¡W S  tjjyL }
 zt|
 
¡ ƒ tdƒ |
‚d }
~
ww )Nzapplication/json)ÚAcceptzContent-Type)ÚqueryÚ	variablesÚoperationNamezutf-8Ú )r   r   r
   r   ÚrequestÚRequestÚjsonÚdumpsÚencodeÚurlopenÚreadÚdecodeÚerrorÚ	HTTPErrorÚprint)r   r   r   Úoperation_namer   Údefault_headersr
   ÚdataÚreqÚresponseÚer   r   r   Úexecute   s   
€ýzGraphQL.execute)NN)Ú__name__Ú
__module__Ú__qualname__r   r   r)   r   r   r   r   r      s    r   )r   Úbaser   Ú	six.movesr   r   r   r   r   r   r   Ú<module>   s
    