channel-app 0.0.131__py3-none-any.whl → 0.0.135__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. channel_app/app/product/service.py +16 -0
  2. channel_app/core/commands.py +3 -1
  3. channel_app/core/tests.py +15 -164
  4. channel_app/omnitron/commands/tests/test_products.py +494 -0
  5. {channel_app-0.0.131.dist-info → channel_app-0.0.135.dist-info}/METADATA +1 -1
  6. channel_app-0.0.135.dist-info/RECORD +60 -0
  7. {channel_app-0.0.131.dist-info → channel_app-0.0.135.dist-info}/WHEEL +1 -1
  8. channel_app/channel_app/app/__init__.py +0 -0
  9. channel_app/channel_app/app/order/__init__.py +0 -0
  10. channel_app/channel_app/app/order/service.py +0 -230
  11. channel_app/channel_app/app/product/__init__.py +0 -0
  12. channel_app/channel_app/app/product/service.py +0 -237
  13. channel_app/channel_app/app/product_price/__init__.py +0 -0
  14. channel_app/channel_app/app/product_price/service.py +0 -254
  15. channel_app/channel_app/app/product_stock/__init__.py +0 -0
  16. channel_app/channel_app/app/product_stock/service.py +0 -258
  17. channel_app/channel_app/app/setup/__init__.py +0 -0
  18. channel_app/channel_app/app/setup/service.py +0 -61
  19. channel_app/channel_app/channel/__init__.py +0 -0
  20. channel_app/channel_app/channel/commands/__init__.py +0 -0
  21. channel_app/channel_app/channel/commands/orders/__init__.py +0 -0
  22. channel_app/channel_app/channel/commands/orders/orders.py +0 -329
  23. channel_app/channel_app/channel/commands/product_categories.py +0 -1
  24. channel_app/channel_app/channel/commands/product_images.py +0 -1
  25. channel_app/channel_app/channel/commands/product_prices.py +0 -148
  26. channel_app/channel_app/channel/commands/product_stocks.py +0 -220
  27. channel_app/channel_app/channel/commands/products.py +0 -161
  28. channel_app/channel_app/channel/commands/setup.py +0 -948
  29. channel_app/channel_app/channel/integration.py +0 -84
  30. channel_app/channel_app/core/__init__.py +0 -0
  31. channel_app/channel_app/core/clients.py +0 -12
  32. channel_app/channel_app/core/commands.py +0 -364
  33. channel_app/channel_app/core/data.py +0 -227
  34. channel_app/channel_app/core/integration.py +0 -74
  35. channel_app/channel_app/core/products.py +0 -64
  36. channel_app/channel_app/core/settings.py +0 -28
  37. channel_app/channel_app/core/utilities.py +0 -99
  38. channel_app/channel_app/omnitron/__init__.py +0 -0
  39. channel_app/channel_app/omnitron/batch_request.py +0 -82
  40. channel_app/channel_app/omnitron/commands/__init__.py +0 -0
  41. channel_app/channel_app/omnitron/commands/batch_requests.py +0 -281
  42. channel_app/channel_app/omnitron/commands/error_reports.py +0 -86
  43. channel_app/channel_app/omnitron/commands/integration_actions.py +0 -200
  44. channel_app/channel_app/omnitron/commands/orders/__init__.py +0 -0
  45. channel_app/channel_app/omnitron/commands/orders/addresses.py +0 -242
  46. channel_app/channel_app/omnitron/commands/orders/cargo_companies.py +0 -40
  47. channel_app/channel_app/omnitron/commands/orders/customers.py +0 -72
  48. channel_app/channel_app/omnitron/commands/orders/orders.py +0 -450
  49. channel_app/channel_app/omnitron/commands/product_categories.py +0 -1
  50. channel_app/channel_app/omnitron/commands/product_images.py +0 -1
  51. channel_app/channel_app/omnitron/commands/product_prices.py +0 -192
  52. channel_app/channel_app/omnitron/commands/product_stocks.py +0 -229
  53. channel_app/channel_app/omnitron/commands/products.py +0 -735
  54. channel_app/channel_app/omnitron/commands/setup.py +0 -839
  55. channel_app/channel_app/omnitron/constants.py +0 -98
  56. channel_app/channel_app/omnitron/exceptions.py +0 -42
  57. channel_app/channel_app/omnitron/integration.py +0 -159
  58. channel_app/setup.py +0 -21
  59. channel_app-0.0.131.dist-info/RECORD +0 -110
  60. /channel_app/{channel_app → omnitron/commands/tests}/__init__.py +0 -0
  61. {channel_app-0.0.131.dist-info → channel_app-0.0.135.dist-info}/top_level.txt +0 -0
@@ -1,84 +0,0 @@
1
- import requests
2
-
3
- from channel_app.channel.commands.orders.orders import GetOrders, CheckOrders, \
4
- SendUpdatedOrders, GetCancelledOrders
5
- from channel_app.channel.commands.product_prices import (CheckPrices,
6
- SendInsertedPrices,
7
- SendUpdatedPrices)
8
- from channel_app.channel.commands.product_stocks import (SendUpdatedStocks,
9
- CheckStocks,
10
- SendInsertedStocks)
11
- from channel_app.channel.commands.products import (SendInsertedProducts,
12
- CheckProducts,
13
- CheckDeletedProducts,
14
- SendUpdatedProducts,
15
- SendDeletedProducts)
16
- from channel_app.channel.commands.setup import (GetCategoryTreeAndNodes,
17
- GetCategoryAttributes,
18
- GetChannelConfSchema)
19
- from channel_app.core.integration import BaseIntegration
20
-
21
-
22
- class ChannelIntegration(BaseIntegration):
23
- """
24
- Communicates with the Channel Api services through the commands defined.
25
-
26
- If an Api Client class is developed, initialization and deletion should be handled in
27
- ChannelIntegration class so that commands have easier access to the api object.
28
- """
29
- _sent_data = {}
30
- actions = {
31
- "send_inserted_products": SendInsertedProducts,
32
- "send_updated_products": SendUpdatedProducts,
33
- "send_deleted_products": SendDeletedProducts,
34
- "check_products": CheckProducts,
35
- "check_deleted_products": CheckDeletedProducts,
36
- "send_updated_stocks": SendUpdatedStocks,
37
- "send_inserted_stocks": SendInsertedStocks,
38
- "send_updated_prices": SendUpdatedPrices,
39
- "send_inserted_prices": SendInsertedPrices,
40
- "check_stocks": CheckStocks,
41
- "check_prices": CheckPrices,
42
- "get_category_tree_and_nodes": GetCategoryTreeAndNodes,
43
- "get_channel_conf_schema": GetChannelConfSchema,
44
- "get_category_attributes": GetCategoryAttributes,
45
- "get_orders": GetOrders,
46
- "send_updated_orders": SendUpdatedOrders,
47
- "check_orders": CheckOrders,
48
- "get_cancelled_orders": GetCancelledOrders
49
- }
50
-
51
- def __init__(self):
52
- from channel_app.core import settings
53
- self.channel_id = settings.OMNITRON_CHANNEL_ID
54
- self.catalog_id = settings.OMNITRON_CATALOG_ID
55
-
56
- def create_session(self):
57
- from channel_app.core import settings
58
-
59
- session = requests.Session()
60
- connections = self.channel.conf.get(
61
- 'connection_pool_count', settings.DEFAULT_CONNECTION_POOL_COUNT)
62
- max_size = self.channel.conf.get(
63
- 'connection_pool_max_size', settings.DEFAULT_CONNECTION_POOL_MAX_SIZE)
64
- retry = self.channel.conf.get(
65
- 'connection_pool_retry', settings.DEFAULT_CONNECTION_POOL_RETRY)
66
-
67
- adapter = requests.adapters.HTTPAdapter(pool_connections=connections,
68
- pool_maxsize=max_size,
69
- max_retries=retry)
70
- session.mount('http://', adapter)
71
- session.mount('https://', adapter)
72
- return session
73
-
74
- @property
75
- def _session(self):
76
- __session = getattr(self, "__session", None)
77
- if __session:
78
- return __session
79
-
80
- session = self.create_session()
81
- setattr(self, "__session", session)
82
- return session
83
-
84
-
File without changes
@@ -1,12 +0,0 @@
1
- from redis import Redis
2
-
3
-
4
- class RedisClient(Redis):
5
- def __init__(self):
6
- from channel_app.core import settings
7
- self.broker_database_index = int(settings.CACHE_DATABASE_INDEX)
8
- self.broker_port = settings.CACHE_PORT
9
- self.broker_host = settings.CACHE_HOST
10
- super(RedisClient, self).__init__(host=self.broker_host,
11
- port=self.broker_port,
12
- db=self.broker_database_index)
@@ -1,364 +0,0 @@
1
- import logging
2
- import traceback
3
- from datetime import datetime
4
- from io import StringIO
5
- from typing import List, Any
6
-
7
- from omnisdk.omnitron.models import BatchRequest
8
- from requests import HTTPError, Request, Response
9
-
10
- from channel_app.core.data import ErrorReportDto
11
- from channel_app.core.integration import BaseIntegration
12
- from channel_app.omnitron.batch_request import ClientBatchRequest
13
- from channel_app.omnitron.constants import BatchRequestStatus, ContentType
14
- from channel_app.omnitron.exceptions import (CountryException, CityException,
15
- TownshipException,
16
- DistrictException)
17
-
18
- logger = logging.getLogger(__name__)
19
-
20
-
21
- class LogService(object):
22
- pass
23
-
24
-
25
- class CommandInterface(object):
26
- def get_data(self) -> object:
27
- """
28
- This method fetches the input data for the command.
29
- """
30
- raise NotImplementedError()
31
-
32
- def transform_data(self, data) -> object:
33
- """
34
- This method can be used to format the input data before it is executed on the run method.
35
- """
36
- raise NotImplementedError()
37
-
38
- def validated_data(self, data) -> dict:
39
- """
40
- If the input data needs to satisfy some conditions or contain required a parameter, the
41
- validation is done here.
42
- """
43
- return data
44
-
45
- def send(self, validated_data) -> object:
46
- """
47
- If the command sends a request using input data to achieve the main object of the
48
- command, it is recommended to place those operations in this method.
49
-
50
- :param validated_data:
51
- """
52
- raise NotImplementedError()
53
-
54
-
55
- class ChannelCommandInterface(CommandInterface):
56
- def __init__(self, integration, objects=None, batch_request=None, **kwargs):
57
- self.objects = objects
58
- self.integration = integration
59
- self.batch_request = batch_request
60
- self.failed_object_list = []
61
- self.session = integration._session
62
- self.CHUNK_SIZE = 50
63
- self.BATCH_SIZE = 100
64
-
65
- for key, value in kwargs.items():
66
- setattr(self, "param_{}".format(key), value)
67
-
68
- def get_data(self) -> object:
69
- raise NotImplementedError
70
-
71
- def validated_data(self, data) -> object:
72
- raise NotImplementedError
73
-
74
- def transform_data(self, data) -> object:
75
- raise NotImplementedError
76
-
77
- def send_request(self, transformed_data) -> object:
78
- """
79
- If the command sends a request using input data to achieve the main object of the
80
- command, it is recommended to place those operations in this method.
81
- """
82
- raise NotImplementedError()
83
-
84
- def normalize_response(self, data, validated_data, transformed_data,
85
- response):
86
- raise NotImplementedError
87
-
88
- def run(self):
89
- """
90
- Main flow of the command. `do_action` method of the integration class executes this method.
91
- This method must also call necessary command interface methods.
92
- :return: returns to response of the command if it has one.
93
- """
94
- data = self.get_data()
95
- validated_data = self.validated_data(data)
96
- transformed_data = self.transform_data(validated_data)
97
- response = self.send_request(transformed_data=transformed_data)
98
- normalize_data = self.normalize_response(
99
- data=data,
100
- validated_data=validated_data,
101
- transformed_data=transformed_data,
102
- response=response)
103
- return normalize_data
104
-
105
- def create_report(self, response):
106
- if not self.is_batch_request:
107
- return
108
- name = self.__class__.__name__
109
- report_list = []
110
- report = ErrorReportDto(
111
- action_content_type=ContentType.batch_request.value,
112
- action_object_id=self.batch_request.pk,
113
- modified_date=datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
114
- error_code=f"{self.batch_request.local_batch_id}-{name}",
115
- error_description=f"{self.batch_request.local_batch_id}-{name}",
116
- raw_request=f"{response.request.method}-"
117
- f"{response.request.url}-"
118
- f"{response.request.body}",
119
- raw_response=f"{response.text}"
120
- )
121
- is_ok = self.check_response_is_ok(response=response)
122
- if is_ok:
123
- report.is_ok = True
124
- else:
125
- report.is_ok = False
126
- report_list.append(report)
127
- for failed_obj in self.failed_object_list:
128
- raw_report = ErrorReportDto(
129
- action_content_type=failed_obj[1],
130
- action_object_id=failed_obj[0].pk,
131
- modified_date=failed_obj[0].modified_date,
132
- error_code=f"{self.batch_request.local_batch_id}-{name}",
133
- error_description=f"{self.batch_request.local_batch_id}-{name}",
134
- raw_request="",
135
- raw_response=f"{failed_obj[0].failed_reason_type}-{failed_obj[2]}",
136
- is_ok=False
137
- )
138
- report_list.append(raw_report)
139
- return report_list
140
-
141
- def check_response_is_ok(self, response):
142
- if str(response.status_code).startswith("2"):
143
- return True
144
- return False
145
-
146
- @property
147
- def is_batch_request(self) -> bool:
148
- is_object = getattr(
149
- self, 'batch_request', None)
150
- return bool(is_object)
151
-
152
-
153
- class OmnitronCommandInterface(CommandInterface):
154
- """
155
- Commands implement list of steps to achieve a task. A command can contain a simple get request
156
- or a complicated business logic with lots of validation.
157
-
158
- """
159
- batch_service = ClientBatchRequest
160
- content_type = None
161
-
162
- def __init__(self, integration: BaseIntegration, objects: Any = None,
163
- batch_request: BatchRequest = None, **kwargs):
164
- """
165
- :param integration: Integration object
166
- :param objects: Input to the command
167
- :param batch_request: Related batch request to keep track of the whole task
168
-
169
- """
170
- self.objects = objects
171
- self.batch_request = batch_request
172
- self.integration = integration
173
- self.failed_object_list = []
174
- for key, value in kwargs.items():
175
- setattr(self, "param_{}".format(key), value)
176
-
177
- def get_data(self) -> object:
178
- return self.objects
179
-
180
- def send(self, validated_data) -> object:
181
- return validated_data
182
-
183
- def normalize_response(self, data, response) -> List[object]:
184
- return response
185
-
186
- def run(self) -> Any:
187
- """
188
- Main flow of the command. `do_action` method of the integration class executes this method.
189
- This method must also call necessary command interface methods.
190
- :return: Response of the command or None
191
- """
192
- is_ok = True
193
- formatted_data = None
194
- raw_request, raw_response = None, None
195
- try:
196
- model_items = self.validated_data(self.get_data())
197
- response = self.send(validated_data=model_items)
198
- normalize_data = self.normalize_response(data=model_items,
199
- response=response)
200
- if isinstance(normalize_data, list):
201
- formatted_data = [model_obj for model_obj in normalize_data
202
- if
203
- not getattr(model_obj, "failed_reason_type",
204
- None)]
205
- self.row_send_error_report()
206
- except HTTPError as e:
207
- request = e.request
208
- raw_request = f"{request.method} - {request.url} - {request.body}"
209
- raw_response = e.response.text
210
- is_ok = False
211
- logger.error(f"{raw_request}-/-{raw_response}")
212
- except CountryException as e:
213
- is_ok = False
214
- raw_response = str(e.params)
215
- except (CityException, TownshipException, DistrictException) as e:
216
- is_ok = False
217
- self.integration.do_action(
218
- key='create_address_error_report',
219
- objects=e.params)
220
- raw_response = str(e.params)
221
- except Exception as e:
222
- is_ok = False
223
- raw_response = f"{str(e)} - {traceback.format_exc()}"
224
- request = getattr(e, "request", "")
225
- if request:
226
- raw_request = f"{request.method} - {request.url} - {request.body}"
227
- logger.error(f"{raw_request}-/-{raw_response}")
228
-
229
- finally:
230
- if not is_ok:
231
- self.send_error_report(raw_request, raw_response)
232
-
233
- is_check_and_update_batch_service = self.check_run(
234
- is_ok=is_ok, formatted_data=formatted_data)
235
- if not is_check_and_update_batch_service:
236
- return []
237
-
238
- return formatted_data
239
-
240
- def check_run(self, is_ok, formatted_data):
241
- if is_ok and not formatted_data and self.is_batch_request:
242
- self.batch_service(self.integration.channel_id).to_done(
243
- self.integration.batch_request)
244
- return False
245
- elif not is_ok and self.is_batch_request:
246
- self.integration.batch_request.objects = None
247
- self.batch_service(self.integration.channel_id).to_fail(
248
- self.integration.batch_request)
249
- return False
250
- return True
251
-
252
- def row_send_error_report(self):
253
- name = self.__class__.__name__
254
- for failed_obj in self.failed_object_list:
255
- report = ErrorReportDto(
256
- action_content_type=failed_obj[1],
257
- action_object_id=failed_obj[0].pk,
258
- modified_date=failed_obj[0].modified_date,
259
- error_code=f"{self.integration.batch_request.local_batch_id}-{name}",
260
- error_description=f"{self.integration.batch_request.local_batch_id}-{name}",
261
- raw_request="",
262
- raw_response=f"{failed_obj[0].failed_reason_type}-{failed_obj[2]}",
263
- is_ok=False
264
- )
265
- self.integration.do_action(key='create_error_report',
266
- objects=report)
267
-
268
- def send_error_report(self, raw_request, raw_response):
269
- if not self.is_batch_request:
270
- return
271
-
272
- name = self.__class__.__name__
273
-
274
- report = ErrorReportDto(
275
- action_content_type=ContentType.batch_request.value,
276
- action_object_id=self.integration.batch_request.pk,
277
- modified_date=datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
278
- error_code=f"{self.integration.batch_request.local_batch_id}-{name}",
279
- error_description=f"{self.integration.batch_request.local_batch_id}-{name}",
280
- raw_request=raw_request,
281
- raw_response=raw_response
282
- )
283
- self.integration.do_action(
284
- key='create_error_report',
285
- objects=report)
286
-
287
- @property
288
- def is_batch_request(self) -> bool:
289
- is_object = getattr(
290
- self.integration, 'batch_request', None)
291
- return bool(is_object)
292
-
293
- def create_log_file(self, message: str = None, raw_request: Request = None,
294
- raw_response: Response = None, **kwargs):
295
- """
296
- Log files are attached to batch requests. If you need to attach logs
297
- to a problematic command or want to see detailed logs for standard a
298
- command, you can use this method. However, if you do not use a batch request
299
- for a command and still want to see the logs, You will need to manage the command
300
- with a batch request.
301
-
302
- :param message: Reason of the exception/entry logged
303
- :param raw_request:
304
- :param raw_response:
305
- """
306
- bytes_io = StringIO()
307
- if raw_request and raw_response:
308
- context = f"""
309
- "message": {message},
310
- "url": {raw_request.url},
311
- "request_body": {raw_request.body},
312
- "response_text": {raw_response.text},
313
- "response_reason": {raw_response.reason},
314
- "response_status_code": {raw_response.status_code}
315
- """
316
- else:
317
- context = f"""
318
- "message": {message}
319
- """
320
- bytes_io.write(context)
321
- bytes_io.seek(0)
322
- return bytes_io
323
-
324
- @property
325
- def update_state(self, *args, **kwargs) -> BatchRequestStatus:
326
- return BatchRequestStatus.commit
327
-
328
- def update_batch_request(self, objects_data: list):
329
- """
330
- Batch requests are used to track state of long-running processes across multiple
331
- systems. State of those requests can be managed through this method.
332
-
333
- :param content_type: String values of the ContentType enum model
334
- :param remote_batch_id: Batch request id of the
335
- :param objects_data:
336
-
337
- """
338
- self.integration.batch_request.objects = objects_data
339
- service = self.batch_service(self.integration.channel_id)
340
- state = getattr(service, f'to_{self.update_state.value}')(
341
- self.integration.batch_request)
342
- return state
343
-
344
- def create_batch_objects(self, data: list, content_type: str) -> List[dict]:
345
- """
346
- In batch requests, you can attach Omnitron objects that are being processed in that batch
347
- so that they are excluded from further calls until that batch is finalized with done or
348
- fail statuses.
349
-
350
- :param data: List of objects which are being processed for this batch request
351
- :param content_type: String values of the ContentType enum model
352
-
353
- """
354
- objects = []
355
- for item in data:
356
- object = {
357
- "pk": item.pk,
358
- "failed_reason_type": getattr(item, "failed_reason_type", None),
359
- "remote_id": getattr(item, "remote_id", None),
360
- "version_date": item.modified_date,
361
- "content_type": content_type
362
- }
363
- objects.append(object)
364
- return objects
@@ -1,227 +0,0 @@
1
- import datetime
2
- from dataclasses import dataclass
3
- from decimal import Decimal
4
- from typing import List, Optional
5
-
6
- from channel_app.omnitron.constants import ResponseStatus, \
7
- ChannelConfSchemaDataTypes
8
-
9
-
10
- @dataclass
11
- class CategoryNodeDto:
12
- name: str
13
- children: List['CategoryNodeDto']
14
- remote_id: Optional[str] = ''
15
- parent: Optional['CategoryNodeDto'] = None
16
-
17
-
18
- @dataclass
19
- class CategoryTreeDto:
20
- root: CategoryNodeDto
21
-
22
-
23
- @dataclass
24
- class CategoryAttributeValueDto:
25
- remote_id: str
26
- name: str
27
-
28
-
29
- @dataclass
30
- class CategoryAttributeDto:
31
- remote_id: str
32
- name: str
33
- required: bool
34
- variant: bool
35
- allow_custom_value: bool
36
- values: List[CategoryAttributeValueDto]
37
-
38
-
39
- @dataclass
40
- class CategoryDto:
41
- remote_id: str
42
- name: str
43
- attributes: List[CategoryAttributeDto]
44
-
45
-
46
- @dataclass
47
- class ChannelConfSchemaField:
48
- required: bool
49
- data_type: ChannelConfSchemaDataTypes
50
- key: str
51
- label: str
52
- schema: Optional[dict] = None
53
-
54
-
55
- @dataclass
56
- class ErrorReportDto:
57
- action_content_type: str
58
- action_object_id: int
59
- modified_date: str
60
- raw_request: str = ""
61
- raw_response: str = ""
62
- error_code: str = "custom"
63
- error_description: str = "custom"
64
- is_ok: bool = False
65
- target_content_type: Optional[str] = ''
66
- target_object_id: Optional[str] = ''
67
-
68
-
69
- @dataclass
70
- class BatchRequestObjectsDto:
71
- pk: int
72
- version_date: str
73
- content_type: str
74
- failed_reason_type: Optional[str] = ''
75
- remote_id: Optional[int] = 0
76
-
77
-
78
- class BatchRequestDto:
79
- channel: int
80
- local_batch_id: str
81
- content_type: str
82
- pk: Optional[int] = 0
83
- remote_batch_id: Optional[str] = ''
84
- status: Optional[str] = ''
85
- objects: Optional[List[BatchRequestObjectsDto]] = []
86
-
87
-
88
- @dataclass
89
- class ProductBatchRequestResponseDto:
90
- status: ResponseStatus
91
- sku: str
92
- remote_id: Optional[str] = ''
93
- message: Optional[str] = ''
94
-
95
-
96
- @dataclass
97
- class BatchRequestResponseDto:
98
- status: ResponseStatus
99
- remote_id: Optional[str] = ''
100
- sku: Optional[str] = ''
101
- message: Optional[str] = ''
102
-
103
-
104
- @dataclass
105
- class OrderBatchRequestResponseDto:
106
- status: ResponseStatus
107
- remote_id: str
108
- number: str
109
- message: Optional[str] = ''
110
-
111
-
112
- @dataclass
113
- class OmnitronOrderDto:
114
- remote_id: str
115
- number: str
116
- channel: int
117
- customer: int
118
- shipping_address: int
119
- billing_address: int
120
- currency: str
121
- amount: Decimal
122
- shipping_amount: Decimal
123
- shipping_tax_rate: Decimal
124
- extra_field: dict
125
- cargo_company: int
126
- created_at: datetime.datetime
127
- delivery_type: Optional[str] = ""
128
- discount_amount: Optional[Decimal] = "0.0"
129
- net_shipping_amount: Optional[Decimal] = "0.0"
130
- tracking_number: Optional[str] = None
131
- carrier_shipping_code: Optional[str] = ""
132
- remote_addr: Optional[str] = None
133
- has_gift_box: Optional[bool] = False
134
- gift_box_note: Optional[str] = ""
135
- client_type: Optional[str] = ""
136
- language_code: Optional[str] = ""
137
- notes: Optional[str] = ""
138
- delivery_range: Optional[str] = ""
139
- shipping_option_slug: Optional[str] = ""
140
- status: Optional[str] = ""
141
-
142
-
143
- @dataclass
144
- class OrderItemDto:
145
- remote_id: str
146
- product: str
147
- price_currency: str
148
- price: Decimal
149
- tax_rate: Decimal
150
- extra_field: dict
151
- status: Optional[str] = None
152
- price_list: Optional[int] = None
153
- stock_list: Optional[int] = None
154
- tracking_number: Optional[str] = None
155
- carrier_shipping_code: Optional[str] = ""
156
- discount_amount: Optional[Decimal] = 0.0
157
- retail_price: Optional[Decimal] = 0.0
158
- attributes: Optional[dict] = None
159
- attributes_kwargs: Optional[dict] = None
160
- parent: Optional[str] = None
161
- delivered_date: Optional[str] = None
162
- estimated_delivery_date: Optional[str] = None
163
-
164
-
165
- # dataclass used for omnitron.commands.orders.orders.CreateOrders
166
- @dataclass
167
- class OmnitronCreateOrderDto:
168
- order: OmnitronOrderDto
169
- order_item: List[OrderItemDto]
170
-
171
-
172
- @dataclass
173
- class CancelOrderDto:
174
- order: str # remote order number
175
- cancel_items: List[str] # order_item_remote_id list
176
- reasons: dict # order_item_remote_id : reason code
177
- is_cargo_refund: Optional[bool] = False # default False
178
- refund_invoice_number: Optional[str] = None
179
-
180
-
181
- @dataclass
182
- class CustomerDto:
183
- email: str # "john.doe@akinon.com"
184
- first_name: str # "John"
185
- last_name: str # "Doe"
186
- channel_code: str # will be unique
187
- extra_field: Optional[dict] = None
188
- phone_number: Optional[str] = None # "05556667788"
189
- is_active: Optional[bool] = True
190
-
191
-
192
- @dataclass
193
- class AddressDto:
194
- email: str # "john.doe@akinon.com"
195
- phone_number: str # "05556667788"
196
- first_name: str # "John"
197
- last_name: str # "Doe"
198
- country: str # 1
199
- city: str # 80
200
- line: str # "Hemen sahil kenarı"
201
- title: Optional[str] = None # "COMM-876"
202
- township: Optional[str] = None # 933
203
- district: Optional[str] = None # 71387
204
- postcode: Optional[str] = None # ""
205
- notes: Optional[str] = None # null
206
- company_name: Optional[str] = None # ""
207
- tax_office: Optional[str] = None # ""
208
- tax_no: Optional[str] = None # ""
209
- e_bill_taxpayer: Optional[bool] = False
210
- remote_id: Optional[str] = None # null
211
- identity_number: Optional[str] = None # null
212
- extra_field: Optional[dict] = None # {}
213
- is_active: Optional[bool] = True # true
214
-
215
-
216
- @dataclass
217
- class ChannelOrderDto(OmnitronOrderDto):
218
- customer = CustomerDto
219
- shipping_address = AddressDto
220
- billing_address = AddressDto
221
- cargo_company = str
222
-
223
-
224
- @dataclass
225
- class ChannelCreateOrderDto:
226
- order: ChannelOrderDto
227
- order_item: List[OrderItemDto]