1+ ( function ( $ , api ) {
2+ function getAccount ( ) {
3+ var uri = api . account . url ( 'user' ) ;
4+ api . get ( uri ) ;
5+ }
6+
7+ function deleteAccount ( ) {
8+ var uri = api . account . url ( 'user' ) ;
9+ api . remove ( uri , '' ) ;
10+ }
11+
12+ function putAccount ( PutUserAccountDataTitle , PutUserAccountDataGender , PutUserAccountDataFname , PutUserAccountDataLname , PutUserAccountDataStreet , PutUserAccountDataNumber , PutUserAccountDataPCode , PutUserAccountDataLocation , PutUserAccountDataTelNo , PutUserAccountDataMTelNo , PutUserAccountDataCulture , PutUserAccountDataMEmail , PutUserAccountDataCCode ) {
13+ var uri = api . account . url ( 'user' ) ;
14+ var payload = {
15+ data : [
16+ {
17+ 'name' : 'Title' ,
18+ 'value' : PutUserAccountDataTitle
19+ } ,
20+ {
21+ 'name' : 'Gender' ,
22+ 'value' : PutUserAccountDataGender
23+ } ,
24+ {
25+ 'name' : 'FirstName' ,
26+ 'value' : PutUserAccountDataFname
27+ } ,
28+ {
29+ 'name' : 'LastName' ,
30+ 'value' : PutUserAccountDataLname
31+ } ,
32+ {
33+ 'name' : 'Street' ,
34+ 'value' : PutUserAccountDataStreet
35+ } ,
36+ {
37+ 'name' : 'Number' ,
38+ 'value' : PutUserAccountDataNumber
39+ } ,
40+ {
41+ 'name' : 'PostalCode' ,
42+ 'value' : PutUserAccountDataPCode
43+ } ,
44+ {
45+ 'name' : 'Location' ,
46+ 'value' : PutUserAccountDataLocation
47+ } ,
48+ {
49+ 'name' : 'TelephoneNumber' ,
50+ 'value' : PutUserAccountDataTelNo
51+ } ,
52+ {
53+ 'name' : 'MobileTelephoneNumber' ,
54+ 'value' : PutUserAccountDataMTelNo
55+ } ,
56+ {
57+ 'name' : 'Culture' ,
58+ 'value' : PutUserAccountDataCulture
59+ } ,
60+ {
61+ 'name' : 'EmailAddress' ,
62+ 'value' : PutUserAccountDataMEmail
63+ } ,
64+ {
65+ 'name' : 'CountryCode' ,
66+ 'value' : PutUserAccountDataCCode
67+ }
68+ ]
69+ } ;
70+
71+ api . update ( uri , JSON . stringify ( payload ) ) ;
72+ }
73+
74+ function getRelationship ( ) {
75+ var uri = api . account . url ( 'relationship' ) ;
76+ api . get ( uri ) ;
77+ }
78+
79+ function deleteRelationship ( ) {
80+ var uri = api . account . url ( 'relationship' ) ;
81+ api . remove ( uri , '' ) ;
82+ }
83+
84+ function changePassword ( ChangePassCurrPass , ChangePassNewPass , ChangePassLang , ChangePassClientId , ChangePassRedUrl ) {
85+ var uri = api . account . url ( 'user' , 'password' ) ;
86+ var payload = {
87+ 'CurrentPassword' : ChangePassCurrPass ,
88+ 'NewPassword' : ChangePassNewPass ,
89+ 'Language' : ChangePassLang ,
90+ 'ClientRequest' : {
91+ 'ClientId' : ChangePassClientId ,
92+ 'RedirectUrl' : ChangePassRedUrl
93+ }
94+ } ;
95+ api . create ( uri , JSON . stringify ( payload ) ) ;
96+ }
97+
98+ function postRelationship ( PostActionValue , ShcSerialNo , ShcName , PinCode , RestoreConfig ) {
99+ var uri = api . account . url ( 'relationship' ) ;
100+ var value = PostActionValue ;
101+
102+ if ( value === 'true' ) {
103+ value = true ;
104+ } else if ( value === 'false' ) {
105+ value = false ;
106+ }
107+
108+ var payload = {
109+ 'accountname' : '' ,
110+ 'serialnumber' : ShcSerialNo ,
111+ 'desc' : '' ,
112+ 'config' : [
113+ {
114+ 'name' : 'Name' ,
115+ 'value' : ShcName
116+ } ,
117+ {
118+ 'name' : 'Code' ,
119+ 'value' : PinCode
120+ } ,
121+ {
122+ 'name' : 'RestoreConfig' ,
123+ 'value' : RestoreConfig === 'true'
124+ }
125+ ]
126+ } ;
127+
128+ api . create ( uri , JSON . stringify ( payload ) ) ;
129+ }
130+
131+ function postConfigRelationship ( RelationshipNewName ) {
132+ var uri = api . account . url ( 'relationship' , 'config' ) ;
133+ var payload = {
134+ 'name' : 'Name' ,
135+ 'value' : RelationshipNewName
136+ } ;
137+
138+ api . create ( uri , JSON . stringify ( payload ) ) ;
139+ }
140+
141+ function sendResetPasswordLink ( SendResetPasswordLinkEmail , SendResetPasswordLinkLanguage , SendResetPassClientId , SendResetPassRedUrl ) {
142+ var uri = api . account . url ( 'user' , 'password' , 'forgot' ) ;
143+ var payload = {
144+ 'Email' : SendResetPasswordLinkEmail ,
145+ 'Language' : SendResetPasswordLinkLanguage ,
146+ 'ClientRequest' : {
147+ 'ClientId' : SendResetPassClientId ,
148+ 'RedirectUrl' : SendResetPassRedUrl
149+ } ,
150+ '__RequestVerificationToken' : 'dummy'
151+ }
152+
153+ api . create ( uri , JSON . stringify ( payload ) ) ;
154+ }
155+
156+ function removeStoreAccount ( ) {
157+ var uri = api . account . url ( 'user' , 'storeaccountname' ) ;
158+ api . remove ( uri , '' ) ;
159+ }
160+
161+ function updateApiCommands ( bind ) {
162+ bind ( {
163+ userUri : api . account . url ( 'user' ) ,
164+ relationshipUri : api . account . url ( 'relationship' ) ,
165+ relationshipConfigUri : api . account . url ( 'relationship' , 'config' ) ,
166+ changePasswordUri : api . account . url ( 'user' , 'password' ) ,
167+ resetPasswordUri : api . account . url ( 'user' , 'password' , 'forgot' ) ,
168+ storeAccountUri : api . account . url ( 'user' , 'storeaccountname' ) ,
169+ tacUri : api . account . url ( 'authorize' , 'TaC' )
170+ } ) ;
171+ }
172+
173+ api . extend ( {
174+ getAccount : getAccount ,
175+ putAccount : putAccount ,
176+ deleteAccount : deleteAccount ,
177+ changePassword : changePassword ,
178+ getRelationship : getRelationship ,
179+ deleteRelationship : deleteRelationship ,
180+ postConfigRelationship : postConfigRelationship ,
181+ postRelationship : postRelationship ,
182+ updateApiCommands : updateApiCommands ,
183+ sendResetPasswordLink : sendResetPasswordLink ,
184+ removeStoreAccount : removeStoreAccount
185+ } ) ;
186+ } ( jQuery , ClientApi ) ) ;
0 commit comments