44 "encoding/json"
55 "net/http"
66
7- "github.com/loginradius/lr-cli/config"
87 "github.com/loginradius/lr-cli/request"
98)
109
@@ -28,79 +27,76 @@ type FieldTypeConfig struct {
2827}
2928
3029var TypeMap = map [int ]FieldTypeConfig {
31- 1 : {
30+ 0 : {
3231 Name : "String" ,
3332 ShouldDisplayValidaitonRuleInput : true ,
3433 ShouldShowOption : false ,
3534 },
36- 2 : {
35+ 1 : {
3736 Name : "CheckBox" ,
3837 ShouldDisplayValidaitonRuleInput : false ,
3938 ShouldShowOption : false ,
4039 },
41- 3 : {
40+ 2 : {
4241 Name : "Option" ,
4342 ShouldDisplayValidaitonRuleInput : false ,
4443 ShouldShowOption : true ,
4544 },
46- 4 : {
45+ 3 : {
4746 Name : "Password" ,
4847 ShouldDisplayValidaitonRuleInput : true ,
4948 ShouldShowOption : false ,
5049 },
51- 5 : {
50+ 4 : {
5251 Name : "Hidden" ,
5352 ShouldDisplayValidaitonRuleInput : true ,
5453 ShouldShowOption : false ,
5554 },
56- 6 : {
55+ 5 : {
5756 Name : "Email" ,
5857 ShouldDisplayValidaitonRuleInput : true ,
5958 ShouldShowOption : false ,
6059 },
61- 7 : {
60+ 6 : {
6261 Name : "Text" ,
6362 ShouldDisplayValidaitonRuleInput : true ,
6463 ShouldShowOption : false ,
6564 },
6665}
6766
6867type Schema struct {
69- Display string `json:"Display"`
70- Enabled bool `json:"Enabled"`
71- IsMandatory bool `json:"IsMandatory"`
72- Parent string `json:"Parent"`
73- ParentDataSource string `json:"ParentDataSource"`
74- Permission string `json:"Permission"`
75- Name string `json:"name"`
76- Options []Array `json:"options"`
77- Rules string `json:"rules"`
78- Status string `json:"status"`
79- Type string `json:"type"`
68+ Display string `json:"Display"`
69+ Enabled bool `json:"Enabled"`
70+ IsMandatory bool `json:"IsMandatory"`
71+ Parent string `json:"Parent"`
72+ ParentDataSource string `json:"ParentDataSource"`
73+ Permission string `json:"Permission"`
74+ Name string `json:"name"`
75+ Options []OptSchema `json:"options"`
76+ Rules string `json:"rules"`
77+ Status string `json:"status"`
78+ Type string `json:"type"`
8079}
81- type Array struct {
80+ type OptSchema struct {
8281 Value string `json:"value"`
8382 Text string `json:"text"`
8483}
8584
86- var Url string
87-
88- type ResultResp struct {
85+ type StandardFields struct {
8986 Data []Schema `json:"Data"`
9087}
9188
92- func GetFields ( tem string ) (* ResultResp , error ) {
93- conf := config . GetInstance ()
94- if tem == "active" {
95- Url = conf .AdminConsoleAPIDomain + "/platform-configuration/registration-form-settings?"
89+ func GetStandardFields ( ftype string ) (* StandardFields , error ) {
90+ var url string
91+ if ftype == "active" {
92+ url = conf .AdminConsoleAPIDomain + "/platform-configuration/registration-form-settings?"
9693 }
97- if tem == "all" {
98- Url = conf .AdminConsoleAPIDomain + "/platform-configuration/platform-registration-fields?"
94+ if ftype == "all" {
95+ url = conf .AdminConsoleAPIDomain + "/platform-configuration/platform-registration-fields?"
9996 }
10097
101- var resultResp ResultResp
102- resp , err := request .Rest (http .MethodGet , Url , nil , "" )
103-
98+ var resultResp StandardFields
99+ resp , err := request .Rest (http .MethodGet , url , nil , "" )
104100 if err != nil {
105101 return nil , err
106102 }
@@ -109,14 +105,24 @@ func GetFields(tem string) (*ResultResp, error) {
109105 if err != nil {
110106 return nil , err
111107 }
108+
109+ if ftype == "all" {
110+ var basicFields StandardFields
111+ for i := 0 ; i < len (resultResp .Data ); i ++ {
112+ if resultResp .Data [i ].Parent == "" {
113+ basicFields .Data = append (basicFields .Data , resultResp .Data [i ])
114+ }
115+ }
116+ return & basicFields , nil
117+ }
112118 return & resultResp , nil
113119}
120+
114121func GetActiveProviders () (* ProviderList , error ) {
115- conf := config .GetInstance ()
116- Url = conf .AdminConsoleAPIDomain + "/platform-configuration/social-providers/options?"
122+ url := conf .AdminConsoleAPIDomain + "/platform-configuration/social-providers/options?"
117123
118124 var R1 ProviderList
119- resp , err := request .Rest (http .MethodGet , Url , nil , "" )
125+ resp , err := request .Rest (http .MethodGet , url , nil , "" )
120126
121127 if err != nil {
122128 return nil , err
0 commit comments