
    i8
h	                     .    d dl Z d dlZd dlZd Z	 ddZdS )    Nc                 ^  K   t          |            t          |           ddd}d}ddi}	 t          j        |||          }n)# t          j        $ r}t	          d|           d }~ww xY w	 |                                }n)# t
          j        $ r}t	          d	|           d }~ww xY w|S )
Nemde-b2b.myshopify.comz,c4uiY9TEKt07cK0LuRkruq7eRX0+Xo6vIigtHzpEueg=)domain	accessKeyzIhttps://b2b-solution-public-api.bsscommerce.com/api/v1/rule/get-by-domainContent-Typeapplication/jsonheadersjsonzRequest error: u   Erreur de décodage JSON: )printrequestspostRequestException	Exceptionr   JSONDecodeError)	shop_name
apikey_bssdataurlr
   responseeresponse_decodeds           "/var/www/sites/EMDE/api/BSS/api.pyget_all_rulesr      s      	)	* +C D VC*G/=gDAAA$ / / /-!--.../:#==?? : : :8Q88999: s/   A A+A&&A+/B B*B%%B*   c                   K   i d|d| ddd|d|d|gd|gd	|gd
|
gdg d|gdddg dg dddg d||d d d}|||d<   d|	|d}d}dddd}t          j                    4 d {V }|                    |||          4 d {V }|                                 d {V }t	          |           |j        dk    r=t	          d|j                   t	          d |                                 d {V            d d d           d {V  n# 1 d {V swxY w Y   d d d           d {V  d S # 1 d {V swxY w Y   d S )!Nnameprioritystatus   apply_toproduct_condition_typecustomer_idscustomer_tagsproduct_idsvariant_idsproduct_collectionsproduct_tagsexclude_fromr   exc_customersexc_customer_tagsmarket_condition_type
market_idsdiscount_type)discount_value
start_dateend_dateidr   )r   r   rulez@https://b2b-solution-public-api.bsscommerce.com/api/v1/rule/saver   closeidentity)r   
ConnectionzAccept-Encodingr	      zErreur HTTP:z	Response:)aiohttpClientSessionr   r   r   r   text)r   r"   r!   r   customer_tagproduct_tagcustomer_idpricerule_idapi_key_bss
variant_idr.   
product_id	base_ruler   r   r
   sessionr   results                       r   create_or_update_rule_asyncrF      sB     H 	! 	H	
 	!"8 	 	, 	
| 	
| 	r 	 	 	 	R 	   	b!" 	#$  )  I. !	$ +  D MC*% G $&& : : : : : : :'<<W4<@@ 	: 	: 	: 	: 	: 	: 	:H#==??******F&MMM#%%nho666k#8#8#8#8#8#8999	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	:: : : : : : : : : : : : : : : : : : : : : : : : : : : : : :s7   1D8A2DD8
D	D8!D	"D88
EE)r   N)r   r   r8   r   rF        r   <module>rI      sT        4 z~/: /: /: /: /: /:rH   