@@ -3,21 +3,27 @@ package api
33import (
44 "encoding/json"
55 "net/http"
6-
6+ "strings"
77 "github.com/loginradius/lr-cli/request"
88)
99
1010// Social Provider Schemas
1111type ActiveProvider struct {
12+ Provider string `json:"ProviderName"`
13+ Status bool `json:"Status"`
14+ }
15+
16+ type ProviderDetail struct {
1217 HtmlFileName string `json:"HtmlFileName"`
1318 Provider string `json:"Provider"`
14- ProviderId int `json:"ProviderId"`
19+ ProviderId string `json:"ProviderId"`
1520 ProviderKey string `json:"ProviderKey"`
1621 ProviderSecret string `json:"ProviderSecret"`
1722 Scope []string `json:"Scope"`
1823 Status bool `json:"Status"`
1924}
2025
26+
2127type ProviderOptSchema struct {
2228 Display string `json:"display"`
2329 Name string `json:"name"`
@@ -42,6 +48,7 @@ type AddProviderObj struct {
4248 ProviderSecret string `json:"ProviderSecret"`
4349 Scope []string `json:"Scope"`
4450 Status bool `json:"status"`
51+ HtmlFileName string `json:"HtmlFileName"`
4552}
4653
4754type AddProviderSchema struct {
@@ -101,39 +108,67 @@ type Schema struct {
101108 Options []OptSchema `json:"Options"`
102109 Rules string `json:"Rules"`
103110 Type string `json:"Type"`
111+ Permission string `json:"Permission"`
112+ Parent string `json:"Parent"`
104113}
105114type OptSchema struct {
106115 Value string `json:"value"`
107116 Text string `json:"text"`
108117}
109118
110- type CustomFieldSchema struct {
119+ type CustomSchema struct {
111120 Key string `json:"Key"`
112121 Display string `json:"Display"`
113122}
114123
115- type FieldSchema struct {
116- CustomFields []CustomFieldSchema `json:"customFields"`
117- RegistrationFields map [string ]Schema `json:"registrationFields"`
118- }
119124type RegistrationSchema struct {
120- Data FieldSchema `json:"data"`
125+ Data []Schema `json:"data"`
126+ }
127+
128+ type CustomFieldSchema struct {
129+ Data []CustomSchema `json:"data"`
121130}
131+
122132type AddCFRespSchema struct {
123133 ResponseAddCustomField struct {
124134 Data []CustomFieldSchema `json:"Data"`
135+ ErrorCode int `json:"errorCode"`
136+ Message string `json:"message"`
137+ Description string `json:"description"`
138+
125139 } `json:"responseAddCustomField"`
126140}
127141type UpdateRegFieldSchema struct {
128- Fields []Schema `json:"fields "`
142+ Data []Schema `json:"data "`
129143}
130144
131145type PasswordlessLogin struct {
132146 Enabled bool `json:"isEnabled"`
133147}
134148
135- func GetRegistrationFields () (* RegistrationSchema , error ) {
136- url := conf .AdminConsoleAPIDomain + "/platform-configuration/registration-schema"
149+ type CustomFieldLimit struct {
150+ Limit int `json:"CustomFieldLimit"`
151+ }
152+
153+
154+ func GetAllCustomFields () (* CustomFieldSchema , error ) {
155+ url := conf .AdminConsoleAPIDomain + "/platform-configuration/custom-fields?d="
156+
157+ var resultResp CustomFieldSchema
158+ resp , err := request .Rest (http .MethodGet , url , nil , "" )
159+ if err != nil {
160+ return nil , err
161+ }
162+ err = json .Unmarshal (resp , & resultResp )
163+ if err != nil {
164+ return nil , err
165+ }
166+
167+ return & resultResp , nil
168+ }
169+
170+ func GetAllRegistrationFields () (map [string ]Schema , error ) {
171+ url := conf .AdminConsoleAPIDomain + "/platform-configuration/platform-registration-fields?d="
137172
138173 var resultResp RegistrationSchema
139174 resp , err := request .Rest (http .MethodGet , url , nil , "" )
@@ -145,14 +180,59 @@ func GetRegistrationFields() (*RegistrationSchema, error) {
145180 if err != nil {
146181 return nil , err
147182 }
183+ provMap := make (map [string ]Schema , len (resultResp .Data ))
184+
185+ for _ ,value := range resultResp .Data {
186+ if value .Parent == "" {
187+ provMap [strings .ToLower (value .Name )] = value
188+ }
189+ }
148190
191+
192+ return provMap , nil
193+ }
194+
195+
196+ func GetRegistrationFields () (map [string ]Schema , error ) {
197+ url := conf .AdminConsoleAPIDomain + "/platform-configuration/registration-form-settings?d="
198+
199+ var resultResp RegistrationSchema
200+ resp , err := request .Rest (http .MethodGet , url , nil , "" )
201+ if err != nil {
202+ return nil , err
203+ }
204+ err = json .Unmarshal (resp , & resultResp )
205+ if err != nil {
206+ return nil , err
207+ }
208+ provMap := make (map [string ]Schema , len (resultResp .Data ))
209+
210+ for _ ,value := range resultResp .Data {
211+ provMap [strings .ToLower (value .Name )] = value
212+ }
213+ return provMap , nil
214+ }
215+
216+ func GetCustomFieldLimit () (* CustomFieldLimit , error ) {
217+ url := conf .AdminConsoleAPIDomain + "/platform-configuration/custom-fields-limit"
218+
219+ var resultResp CustomFieldLimit
220+ resp , err := request .Rest (http .MethodGet , url , nil , "" )
221+ if err != nil {
222+ return nil , err
223+ }
224+
225+ err = json .Unmarshal (resp , & resultResp )
226+ if err != nil {
227+ return nil , err
228+ }
149229 return & resultResp , nil
150230}
151231
152232func AddCustomField (customfield string ) (* AddCFRespSchema , error ) {
153233 url := conf .AdminConsoleAPIDomain + "/platform-configuration/custom-field"
154234 body , _ := json .Marshal (map [string ]string {
155- "customField " : customfield ,
235+ "customfield " : customfield ,
156236 })
157237 var resultResp AddCFRespSchema
158238 resp , err := request .Rest (http .MethodPost , url , nil , string (body ))
@@ -191,7 +271,7 @@ func DeleteCustomField(field string) (*bool, error) {
191271}
192272
193273func UpdateRegField (data UpdateRegFieldSchema ) (* RegistrationSchema , error ) {
194- url := conf .AdminConsoleAPIDomain + "/platform-configuration/registration-schema "
274+ url := conf .AdminConsoleAPIDomain + "/platform-configuration/default-fields?d= "
195275 body , _ := json .Marshal (data )
196276 var resultResp RegistrationSchema
197277 resp , err := request .Rest (http .MethodPost , url , nil , string (body ))
@@ -247,7 +327,8 @@ func GetAllProviders() (map[string]ProviderSchema, error) {
247327 return provMap , nil
248328}
249329
250- func GetActiveProviders () (map [string ]ActiveProvider , error ) {
330+
331+ func GetProvidersDetail () (map [string ]ProviderDetail , error ) {
251332 url := conf .AdminConsoleAPIDomain + "/platform-configuration/social-providers/options"
252333
253334 resp , err := request .Rest (http .MethodGet , url , nil , "" )
@@ -256,6 +337,33 @@ func GetActiveProviders() (map[string]ActiveProvider, error) {
256337 return nil , err
257338 }
258339
340+ type ProviderDetailList struct {
341+ Data []ProviderDetail `json:"Data"`
342+ }
343+ var resultResp ProviderDetailList
344+
345+ err = json .Unmarshal (resp , & resultResp )
346+ if err != nil {
347+ return nil , err
348+ }
349+
350+ provMap := make (map [string ]ProviderDetail , len (resultResp .Data ))
351+ for _ , val := range resultResp .Data {
352+ provMap [strings .ToLower (val .Provider )] = val
353+ }
354+
355+ return provMap , nil
356+ }
357+
358+ func GetActiveProviders () (map [string ]ActiveProvider , error ) {
359+ url := conf .AdminConsoleAPIDomain + "/platform-configuration/social-providers?v="
360+
361+ resp , err := request .Rest (http .MethodGet , url , nil , "" )
362+
363+ if err != nil {
364+ return nil , err
365+ }
366+
259367 type ActiveProviderList struct {
260368 Data []ActiveProvider `json:"Data"`
261369 }
@@ -267,7 +375,7 @@ func GetActiveProviders() (map[string]ActiveProvider, error) {
267375 }
268376 provMap := make (map [string ]ActiveProvider , len (resultResp .Data ))
269377 for _ , val := range resultResp .Data {
270- provMap [val .Provider ] = val
378+ provMap [strings . ToLower ( val .Provider ) ] = val
271379 }
272380
273381 return provMap , nil
0 commit comments