ebanutsya
This commit is contained in:
		@@ -19,10 +19,13 @@ class SiproClient:
 | 
			
		||||
            self.initialized = True
 | 
			
		||||
            logger_instance.info('SiproClient successfully initialized')
 | 
			
		||||
 | 
			
		||||
    def method(self, http_method: str, method: str, data: dict = None):
 | 
			
		||||
    def method(self, http_method: str, method: str, data: dict = None, raw=False):
 | 
			
		||||
        url = self.api_url + '/assemblr' + method
 | 
			
		||||
        headers = {'Authorization': self.token}
 | 
			
		||||
        return requests.request(http_method, url, headers=headers, json=data).json()
 | 
			
		||||
        response = requests.request(http_method, url, headers=headers, json=data)
 | 
			
		||||
        if raw:
 | 
			
		||||
            return response
 | 
			
		||||
        return response.json()
 | 
			
		||||
 | 
			
		||||
    def ping(self) -> str:
 | 
			
		||||
        return self.method('GET', '/ping').get('response')
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										16
									
								
								sipro/api/printing.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								sipro/api/printing.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,16 @@
 | 
			
		||||
from io import BytesIO
 | 
			
		||||
 | 
			
		||||
from flask import send_file
 | 
			
		||||
from requests import Response
 | 
			
		||||
 | 
			
		||||
from sipro.api.client import get_client
 | 
			
		||||
 | 
			
		||||
client = get_client()
 | 
			
		||||
router = '/printing'
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def get_label(order_product_id: str) -> BytesIO:
 | 
			
		||||
    method = f'{router}/getLabel?orderId={order_product_id}'
 | 
			
		||||
    response: Response = client.method('GET', method, raw=True)
 | 
			
		||||
    data = BytesIO(response.content)
 | 
			
		||||
    return data
 | 
			
		||||
		Reference in New Issue
	
	Block a user