-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservice.py
executable file
·263 lines (201 loc) · 8.16 KB
/
service.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
import json
import hashlib
import cvs_services.hooks.pre as pre_hook
import cvs_services.hooks.post as post_hook
from bottle import route, run, hook, response, request, HTTPResponse, default_app, post
from cvs_services.components.users import controller as user
from cvs_services.components.orders import controller as order
from cvs_services.config import Headers
import cvs_services.dal as dbm
user_obj = user.ControllerUserClass()
order_obj = order.ControllerOrderClass()
db = dbm.DBLayer()
@route('/hello')
def hello():
print "hello"
response={}
response['status'] = "success"
response['message'] = "Hello to VT Services."
return response
# --------------------------------------------------- Users Services ------------------------------------------------------------------- #
@route('/users/register', method='POST')
def user_register():
"""
This service is use to register user with email.
The key parameters that must have to send in post data are :
postParameters = ['first_name','last_name','email','phone']
In case of user registration response will be status: success and a message will be return like user registration successfully.
If user's email is already exist in our system then response will be status: failure and message will be already registered with this email.
In case of any error during server process or query error has occurred response will be status: failure and message will be like Exception Error.
"""
data = user_obj.user_register(request.forms)
return data
@route('/users/forgot/password', method='POST')
def user_forgotpassword():
"""
This is to forgot password.
"""
data = user_obj.user_forgotpassword(request.forms)
return data
@route('/users/login')
def user_login():
""" This is to user login. """
data = user_obj.user_login()
return data
@route('/users/update/profile', method='POST')
def user_update_profile():
""" This is to update user profile data."""
if 'userid' and 'email' not in request.forms:
return {'status':'Failure','message':'User Id is missing,please try with correct data.'}
data = user_obj.user_update_profile(request.forms)
return data
@route('/users/info')
def get_users_info():
"""
This is to get info of single user (new)
"""
data = user_obj.get_users_info()
return data
#**************** Customer **************************#
@route('/customers/all')
def get_all_customers():
""" This is to get all customers data related to business owner and system admin. """
data = user_obj.get_all_customers()
return data
@route('/customers/count')
def get_all_customers_count():
""" This is to get all customers data related to business owner and system admin.. """
data = user_obj.get_all_customers("1")
return data
@route('/customer/orders/customerId/:customerId')
def get_customer_orders(customerId):
""" This is to get all customers data related to business owner and system admin. """
data = user_obj.get_customer_orders(customerId)
return data
@route('/customer/orders/count/customerId/:customerId')
def get_customer_orders_count(customerId):
""" This is to get all customers data related to business owner and system admin. """
data = user_obj.get_customer_orders(customerId,"1")
return data
@route('/customer/update',method='POST')
def update_customer_status():
""" This is to get all customers data related to business owner and system admin."""
data = user_obj.update_customer_status(request.forms)
return data
@route('/sms/log',method='POST')
def sms_log():
""" This is to save sms log."""
data = user_obj.sms_log(request.forms)
return data
#*******************************************ORDERS***********************************************************************************************************************************#
# @route('/orders/all')
# def get_all_orders():
# """
# This is to get info of all orders
# """
#
# data = order_obj.get_all_orders()
# return data
#
# @route('/orders/detail/orderid/:orderid')
# def get_one_order(orderid):
# """This service use to get one order detail."""
# data = order_obj.get_all_orders(orderid)
# return data
@route('/orders/all')
def get_all_orders():
"""
This is to get info of all orders
"""
data = order_obj.get_all_orders()
return data
@route('/orders/count')
def get_all_orders_count():
"""
This is to get info of all orders
"""
data = order_obj.get_all_orders("1")
return data
@route('/orders/detail/orderid/:orderid')
def get_order_detail(orderid):
"""This service use to get one order detail."""
data = order_obj.get_order_detail(orderid)
return data
@route('/orders/detail/count/orderid/:orderid')
def get_order_detail_count(orderid):
"""This service use to get one order detail."""
data = order_obj.get_order_detail(orderid,"1")
return data
@route('/orders/update/status', method='POST')
def order_update_status():
""" This service is use to update order status. """
result = order_obj.order_update_status(request.forms)
return result
@route('/orders/update/print', method='POST')
def order_update_print():
""" This service is use to update order status. """
result = order_obj.order_update_print(request.forms)
return result
@route('/products/all')
def get_all_products():
""" This service is use to get products list. """
data = order_obj.get_all_products()
return data
@route('/orders/add/product', method='POST')
def add_products():
""" This service is use to update order status. """
result = order_obj.add_products(request.forms)
return result
# @route('/orders/remove/orderId/:orderid' , method='POST')
# def remove_order(orderid):
# """This service use to remove one item from order detail."""
# data = order_obj.remove_order(orderid)
# return data
# @route('/orders/item/remove/orderid/:orderid/detailid/:detailid' , method='POST')
# def remove_item_from_order(orderid,detailid):
# """This service use to remove one item from order detail."""
# data = order_obj.remove_item_from_order(orderid,detailid)
# return data
#
#
# @route('/orders/items/remove' , method='POST')
# def remove_items_from_order():
# """This service use to remove multiple item from order detail."""
# data = order_obj.remove_items_from_order(request.forms)
# return data
@route('/orders/item/remove/orderid/:orderid/detailid/:detailid' , method='POST')
def remove_item_from_order(orderid,detailid):
"""This service use to remove one item from order detail."""
data = order_obj.remove_item_from_order(orderid,detailid)
return data
@route('/orders/items/remove' , method='POST')
def remove_items_from_order():
"""This service use to remove multiple item from order detail."""
data = order_obj.remove_item_from_order(None,None,request.forms)
return data
@route('/orders/item/change/detailid/:detailid/newQuantity/:newQuantity' , method='POST')
def change_item_quantity_from_order(detailid,newQuantity):
"""This service use to change one quantity item order detail."""
data = order_obj.change_item_quantity_from_order(detailid,newQuantity)
return data
@route('/orders/messages/orderid/:orderid')
def get_messages_log(orderid):
"""This service use to get one order messages log."""
data = order_obj.get_messages_log(orderid)
return data
@route('/orders/message/send' , method='POST')
def send_owner_message():
"""This service use to send owner sms to customers."""
data = order_obj.send_owner_message(request.forms)
return data
# ********************************************************************************************************************************************************************************** #
@hook('before_request')
def pre_request():
pre_hook.initialize()
pre_hook.get_headers(request.headers)
pre_hook.authenticate()
pre_hook.establish_connection()
@hook('after_request')
def post_request():
post_hook.close_connection()
post_hook.add_headers()