| 130 |
ashish |
1 |
from shop2020.thriftpy.model.v1.user.ttypes import Address as TAddress,\
|
| 1583 |
varun.gupt |
2 |
Phone as TPhone, SocialHandles as TSocialHandles, UserCommunication as TUserCommunication,\
|
| 565 |
rajveer |
3 |
UserState as TUserState, User as TUser, Cart as TCart, Line as TLine, Sex as TSex
|
| 130 |
ashish |
4 |
from shop2020.utils.Utils import to_java_date
|
|
|
5 |
|
|
|
6 |
def to_t_address(address):
|
|
|
7 |
t_address = TAddress()
|
|
|
8 |
t_address.id = address.id
|
|
|
9 |
t_address.line1 = address.line_1
|
|
|
10 |
t_address.line2 = address.line_2
|
|
|
11 |
t_address.landmark = address.landmark
|
|
|
12 |
t_address.city = address.city
|
|
|
13 |
t_address.state = address.state
|
|
|
14 |
t_address.pin = address.pin
|
|
|
15 |
t_address.country = address.country
|
|
|
16 |
t_address.enabled = address.enabled
|
|
|
17 |
t_address.type = address.type
|
|
|
18 |
t_address.addedOn = to_java_date(address.added_on)
|
| 414 |
ashish |
19 |
t_address.name = address.name
|
|
|
20 |
t_address.phone = address.phone
|
| 557 |
chandransh |
21 |
return t_address
|
| 130 |
ashish |
22 |
|
| 557 |
chandransh |
23 |
def to_t_user(user):
|
|
|
24 |
t_user = TUser()
|
| 576 |
chandransh |
25 |
if user is None:
|
|
|
26 |
t_user.userId = -1
|
|
|
27 |
return t_user
|
|
|
28 |
|
| 557 |
chandransh |
29 |
t_user.userId = user.id
|
|
|
30 |
t_user.name = user.name
|
|
|
31 |
t_user.email = user.email
|
| 619 |
rajveer |
32 |
t_user.password = user.password
|
| 557 |
chandransh |
33 |
t_user.sex = user.sex
|
|
|
34 |
|
|
|
35 |
t_user.socialHandles = to_t_social_handle(user.social_handles)
|
|
|
36 |
t_user.communicationEmail = user.communication_email
|
|
|
37 |
t_user.defaultAddressId = user.default_address_id
|
|
|
38 |
t_user.isAnonymous = user.is_anonymous
|
|
|
39 |
t_user.activeCartId = user.active_cart_id
|
| 567 |
rajveer |
40 |
t_user.dateOfBirth = user.date_of_birth
|
|
|
41 |
t_user.mobileNumber = user.mobile_number
|
| 130 |
ashish |
42 |
#put all addresses
|
| 557 |
chandransh |
43 |
if user.addresses:
|
|
|
44 |
t_user.addresses = list()
|
|
|
45 |
for address in user.addresses:
|
|
|
46 |
t_user.addresses.append(to_t_address(address))
|
|
|
47 |
return t_user
|
| 513 |
rajveer |
48 |
|
| 130 |
ashish |
49 |
def to_t_internal_info(internal_info):
|
|
|
50 |
pass
|
|
|
51 |
|
|
|
52 |
def to_t_user_state(user_state):
|
|
|
53 |
t_user_state = TUserState()
|
|
|
54 |
t_user_state.userId = user_state.user.id
|
| 557 |
chandransh |
55 |
t_user_state.lastLogin = to_java_date(user_state.last_login)
|
| 130 |
ashish |
56 |
t_user_state.lastLogout = to_java_date(user_state.last_logout)
|
|
|
57 |
t_user_state.emailVerificationSentOn = to_java_date(user_state.email_verification_sent_on)
|
|
|
58 |
t_user_state.smsVerificationSentOn = to_java_date(user_state.sms_verification_sent_on)
|
| 557 |
chandransh |
59 |
t_user_state.isEmailVerified = user_state.is_email_verified
|
| 130 |
ashish |
60 |
t_user_state.isSMSVerified = user_state.is_sms_verified
|
|
|
61 |
t_user_state.activeSince = to_java_date(user_state.active_since)
|
|
|
62 |
t_user_state.status = user_state.account_status
|
|
|
63 |
return t_user_state
|
|
|
64 |
|
|
|
65 |
def to_t_phone(phone):
|
|
|
66 |
t_phone = TPhone()
|
|
|
67 |
t_phone.areaCode = phone.area_code
|
|
|
68 |
t_phone.countryCode = phone.country_code
|
|
|
69 |
t_phone.extension = phone.extension
|
|
|
70 |
t_phone.number = phone.number
|
|
|
71 |
t_phone.type = phone.type
|
|
|
72 |
return t_phone
|
|
|
73 |
|
|
|
74 |
def to_t_social_handle(social_handles):
|
|
|
75 |
t_socialHandle = TSocialHandles()
|
|
|
76 |
for social_handle in social_handles:
|
|
|
77 |
if social_handle.service.name == "Facebook":
|
|
|
78 |
t_socialHandle.facebook = social_handle.handle
|
|
|
79 |
if social_handle.service.name == "OpenSocial":
|
|
|
80 |
t_socialHandle.opensocial = social_handle.handle
|
|
|
81 |
if social_handle.service.name == "Twitter":
|
|
|
82 |
t_socialHandle.twitter = social_handle.handle
|
| 557 |
chandransh |
83 |
return t_socialHandle
|
|
|
84 |
|
|
|
85 |
def to_t_cart(cart):
|
|
|
86 |
t_cart = TCart()
|
|
|
87 |
if cart:
|
|
|
88 |
t_cart.id = cart.id
|
|
|
89 |
t_cart.status = cart.cart_status
|
|
|
90 |
lines = []
|
|
|
91 |
if cart.lines:
|
|
|
92 |
for line in cart.lines:
|
|
|
93 |
lines.append(to_t_line(line))
|
|
|
94 |
t_cart.lines = lines
|
|
|
95 |
t_cart.createdOn = to_java_date(cart.created_on)
|
|
|
96 |
t_cart.updatedOn = to_java_date(cart.updated_on)
|
|
|
97 |
t_cart.userId = cart.user_id
|
|
|
98 |
t_cart.addressId = cart.address_id
|
| 690 |
chandransh |
99 |
t_cart.checkedOutOn = to_java_date(cart.checked_out_on)
|
| 557 |
chandransh |
100 |
return t_cart
|
|
|
101 |
|
| 612 |
chandransh |
102 |
def to_t_line(line):
|
|
|
103 |
t_line = TLine()
|
|
|
104 |
if line:
|
| 643 |
chandransh |
105 |
t_line.cartId = line.cart_id
|
| 612 |
chandransh |
106 |
t_line.itemId = line.item_id
|
|
|
107 |
t_line.quantity = line.quantity
|
|
|
108 |
t_line.estimate = line.estimate
|
|
|
109 |
t_line.createdOn = to_java_date(line.created_on)
|
|
|
110 |
t_line.updatedOn = to_java_date(line.updated_on)
|
|
|
111 |
t_line.lineStatus = line.line_status
|
|
|
112 |
return t_line
|
| 1583 |
varun.gupt |
113 |
|
|
|
114 |
def to_t_user_communication(user_communication):
|
|
|
115 |
t_user_communication = TUserCommunication()
|
|
|
116 |
|
|
|
117 |
if user_communication:
|
|
|
118 |
t_user_communication.id = user_communication.id
|
| 1603 |
varun.gupt |
119 |
t_user_communication.userId = user_communication.user_id
|
|
|
120 |
t_user_communication.communicationType = user_communication.communication_type
|
|
|
121 |
t_user_communication.orderId = user_communication.order_id
|
|
|
122 |
t_user_communication.airwaybillNo = user_communication.airwaybill_no
|
|
|
123 |
t_user_communication.replyTo = user_communication.reply_to
|
|
|
124 |
t_user_communication.productName = user_communication.product_name
|
| 1583 |
varun.gupt |
125 |
t_user_communication.subject = user_communication.subject
|
|
|
126 |
t_user_communication.message = user_communication.message
|
|
|
127 |
t_user_communication.communication_timestamp = to_java_date(user_communication.communication_timestamp)
|
|
|
128 |
|
|
|
129 |
return t_user_communication
|