1+ import requests
2+ from . import utils
3+ from codat .models import operations
4+ from typing import Optional
5+
6+ class Configuration :
7+ _client : requests .Session
8+ _security_client : requests .Session
9+ _server_url : str
10+ _language : str
11+ _sdk_version : str
12+ _gen_version : str
13+
14+ def __init__ (self , client : requests .Session , security_client : requests .Session , server_url : str , language : str , sdk_version : str , gen_version : str ) -> None :
15+ self ._client = client
16+ self ._security_client = security_client
17+ self ._server_url = server_url
18+ self ._language = language
19+ self ._sdk_version = sdk_version
20+ self ._gen_version = gen_version
21+
22+
23+ def get_company_configuration (self , request : operations .GetCompanyConfigurationRequest ) -> operations .GetCompanyConfigurationResponse :
24+ r"""Get Company configuration
25+ Gets a companies expense sync configuration
26+ """
27+
28+ base_url = self ._server_url
29+
30+ url = utils .generate_url (base_url , "/companies/{companyId}/config" , request .path_params )
31+
32+
33+ client = self ._security_client
34+
35+ r = client .request ("GET" , url )
36+ content_type = r .headers .get ("Content-Type" )
37+
38+ res = operations .GetCompanyConfigurationResponse (status_code = r .status_code , content_type = content_type )
39+
40+ if r .status_code == 200 :
41+ if utils .match_content_type (content_type , "application/json" ):
42+ out = utils .unmarshal_json (r .text , Optional [operations .GetCompanyConfiguration200ApplicationJSON ])
43+ res .get_company_configuration_200_application_json_object = out
44+
45+ return res
46+
47+
48+ def save_company_configuration (self , request : operations .SaveCompanyConfigurationRequest ) -> operations .SaveCompanyConfigurationResponse :
49+ r"""Set Company configuration
50+ Sets a companies expense sync configuration
51+ """
52+
53+ base_url = self ._server_url
54+
55+ url = utils .generate_url (base_url , "/companies/{companyId}/config" , request .path_params )
56+
57+ headers = {}
58+ req_content_type , data , form = utils .serialize_request_body (request )
59+ if req_content_type != "multipart/form-data" and req_content_type != "multipart/mixed" :
60+ headers ["content-type" ] = req_content_type
61+
62+ client = self ._security_client
63+
64+ r = client .request ("POST" , url , data = data , files = form , headers = headers )
65+ content_type = r .headers .get ("Content-Type" )
66+
67+ res = operations .SaveCompanyConfigurationResponse (status_code = r .status_code , content_type = content_type )
68+
69+ if r .status_code == 200 :
70+ if utils .match_content_type (content_type , "application/json" ):
71+ out = utils .unmarshal_json (r .text , Optional [operations .SaveCompanyConfiguration200ApplicationJSON ])
72+ res .save_company_configuration_200_application_json_object = out
73+ elif r .status_code == 400 :
74+ if utils .match_content_type (content_type , "application/json" ):
75+ out = utils .unmarshal_json (r .text , Optional [operations .SaveCompanyConfiguration400ApplicationJSON ])
76+ res .save_company_configuration_400_application_json_object = out
77+
78+ return res
79+
80+
0 commit comments