@@ -46,6 +46,97 @@ def get_uris(self):
46
46
47
47
return self .item ['login' ]['uris' ]
48
48
49
+ def get_card_fields (self ):
50
+ if 'card' not in self .item :
51
+ return []
52
+
53
+ items = dict ()
54
+
55
+ if self .item ["card" ]["cardholderName" ] is not None :
56
+ items ["Cardholder Name" ] = self .item ["card" ]["cardholderName" ]
57
+ if self .item ["card" ]["brand" ] is not None :
58
+ items ["Brand Name" ] = self .item ["card" ]["brand" ]
59
+ if self .item ["card" ]["number" ] is not None :
60
+ items ["Number" ] = self .item ["card" ]["number" ]
61
+ if self .item ["card" ]["expMonth" ] is not None :
62
+ items ["Expiration Month" ] = self .item ["card" ]["expMonth" ]
63
+ if self .item ["card" ]["expYear" ] is not None :
64
+ items ["Expiration Year" ] = self .item ["card" ]["expYear" ]
65
+ if self .item ["card" ]["code" ] is not None :
66
+ items ["Code" ] = self .item ["card" ]["code" ]
67
+
68
+ return items
69
+
70
+ def get_identity_fields (self ):
71
+ if 'identity' not in self .item :
72
+ return []
73
+
74
+ old_items = self .item ["identity" ]
75
+ items = dict ()
76
+
77
+ temp = ""
78
+ found = False
79
+
80
+ # format Identity name as firstName middleName lastName
81
+ for i in ["title" , "firstName" , "middleName" , "lastName" ]:
82
+ if old_items [i ] is not None :
83
+ if found :
84
+ temp = " " .join ([temp , old_items [i ]])
85
+ else :
86
+ found = True
87
+ temp = "" .join ([temp , old_items [i ]])
88
+ if temp != "" :
89
+ items ["Identity name" ] = temp
90
+
91
+ if old_items ["username" ] is not None :
92
+ items ["Identity username" ] = old_items ["username" ]
93
+
94
+ if old_items ["company" ] is not None :
95
+ items ["Company" ] = old_items ["company" ]
96
+
97
+ if old_items ["ssn" ] is not None :
98
+ items ["National Insurance number" ] = old_items ["ssn" ]
99
+
100
+ if old_items ["passportNumber" ] is not None :
101
+ items ["Passport number" ] = old_items ["passportNumber" ]
102
+
103
+ if old_items ["licenseNumber" ] is not None :
104
+ items ["License number" ] = old_items ["licenseNumber" ]
105
+
106
+ if old_items ["email" ] is not None :
107
+ items ["Email" ] = old_items ["email" ]
108
+
109
+ if old_items ["phone" ] is not None :
110
+ items ["Phone" ] = old_items ["phone" ]
111
+
112
+ # form address string in below format
113
+ # address1
114
+ # address2
115
+ # address3
116
+ # city, state, postalCode
117
+ # country
118
+ temp , found = "" , False
119
+ for i in ["address1" , "address2" , "address3" ]:
120
+ if found :
121
+ temp = "\n " .join ([temp , old_items [i ]])
122
+ else :
123
+ found = True
124
+ temp = "" .join ([temp , old_items [i ]])
125
+
126
+ found = False
127
+ for i in ["city" , "state" , "postalCode" ]:
128
+ if found :
129
+ temp = ", " .join ([temp , old_items [i ]])
130
+ else :
131
+ found = True
132
+ temp = "\n " .join ([temp , old_items [i ]])
133
+
134
+ if old_items ["country" ] is not None :
135
+ temp = "\n " .join ([temp , old_items ["country" ]])
136
+ if temp != "" :
137
+ items ["Address" ] = temp
138
+
139
+ return items
49
140
def get_custom_fields (self ):
50
141
if 'fields' not in self .item :
51
142
return []
0 commit comments