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,161 +0,0 @@
1
- import random
2
- import uuid
3
- from typing import List, Any, Tuple
4
-
5
- from omnisdk.omnitron.models import Product, BatchRequest
6
-
7
- from channel_app.core.commands import CommandInterface, ChannelCommandInterface
8
- from channel_app.core.data import ProductBatchRequestResponseDto, ErrorReportDto
9
- from channel_app.omnitron.constants import ResponseStatus
10
-
11
-
12
- class SendInsertedProducts(ChannelCommandInterface):
13
- param_sync = True
14
-
15
- def get_data(self) -> List[Product]:
16
- data = self.objects
17
- return data
18
-
19
- def validated_data(self, data) -> object:
20
- return data
21
-
22
- def transform_data(self, data) -> object:
23
- return data
24
-
25
- def send_request(self, transformed_data) -> object:
26
- response = self.__mocked_request(data=transformed_data)
27
- return response
28
-
29
- def normalize_response(self, data, validated_data, transformed_data,
30
- response) -> Tuple[
31
- List[ProductBatchRequestResponseDto], List[ErrorReportDto], Any]:
32
- report: List[ErrorReportDto] = self.create_report(response)
33
- if not self.param_sync:
34
- remote_batch_id = response.get("remote_batch_request_id")
35
- self.batch_request.remote_batch_id = remote_batch_id
36
- return "", report, data
37
- else:
38
- response_data = []
39
- for row in response:
40
- response_data.append(ProductBatchRequestResponseDto(
41
- sku=row["sku"],
42
- message=row["message"],
43
- remote_id=row["remote_id"],
44
- status=row["status"]
45
- ))
46
-
47
- response_data: List[ProductBatchRequestResponseDto]
48
- return response_data, report, data
49
-
50
- def __mocked_request(self, data):
51
- """
52
- Mock a request and response for the send operation to mimic actual channel data
53
- :param data:
54
- """
55
- batch_id = str(uuid.uuid4())
56
- self.integration._sent_data[batch_id] = data
57
- return {"remote_batch_request_id": batch_id}
58
-
59
- def __mock_request_sync(self, data):
60
- result = []
61
- for row in data:
62
- obj = dict(
63
- sku=row["sku"],
64
- message=row["message"],
65
- remote_id=row["remote_id"],
66
- status=row["status"])
67
- result.append(obj)
68
- return result
69
-
70
-
71
- class SendUpdatedProducts(SendInsertedProducts):
72
- pass
73
-
74
-
75
- class SendDeletedProducts(SendInsertedProducts):
76
- def __mocked_request(self, data):
77
- """
78
- Mock a request and response for the send operation to mimic actual channel data
79
- :param data:
80
- """
81
- batch_id = str(uuid.uuid4())
82
- self.integration._sent_data[batch_id] = data
83
- return {"remote_batch_request_id": batch_id}
84
-
85
-
86
- class CheckProducts(ChannelCommandInterface):
87
-
88
- def get_data(self) -> BatchRequest:
89
- batch_request = self.objects
90
- return batch_request
91
-
92
- def validated_data(self, data) -> object:
93
- return data
94
-
95
- def transform_data(self, data) -> object:
96
- return data
97
-
98
- def send_request(self, transformed_data: BatchRequest) -> object:
99
- """
100
- Sends a post request to the channel client to insert the products
101
- :param transformed_data:
102
- :return: list
103
- [{ remote_data},]
104
- """
105
-
106
- response = self.__mocked_request(
107
- data=self.integration._sent_data[transformed_data.remote_batch_id],
108
- remote_batch_id=transformed_data.remote_batch_id)
109
- return response
110
-
111
- def normalize_response(self, data, validated_data, transformed_data,
112
- response) -> Tuple[List[ProductBatchRequestResponseDto],
113
- List[ErrorReportDto], Any]:
114
- response_data = []
115
- for row in response:
116
- obj = ProductBatchRequestResponseDto(
117
- sku=row["sku"],
118
- message=row["message"],
119
- remote_id=row["remote_id"],
120
- status=row["status"])
121
- response_data.append(obj)
122
- report = self.create_report(response)
123
- return response_data, report, data
124
-
125
- def __mocked_request(self, data, remote_batch_id):
126
- """
127
- Mock a request and response for the send operation to mimic actual channel data
128
- :param data:
129
- :return: list
130
-
131
- [{
132
- "status": "SUCCESS",
133
- "remote_id": "123a1",
134
- "sku": "1KBATC0197",
135
- "message": ""
136
- },]
137
- """
138
-
139
- response_data = []
140
- prefix = remote_batch_id[-8:]
141
- for index, item in enumerate(data):
142
- if random.random() < 0.8:
143
- response_item = {
144
- 'sku': item.sku,
145
- 'message': "",
146
- 'remote_id': "{}_{}".format(prefix, index),
147
- 'status': ResponseStatus.success
148
- }
149
- else:
150
- response_item = {
151
- "status": ResponseStatus.fail,
152
- "remote_id": None,
153
- "sku": item.sku,
154
- "message": "exception message"
155
- }
156
- response_data.append(response_item)
157
- return response_data
158
-
159
-
160
- class CheckDeletedProducts(CheckProducts):
161
- pass