Skip to content

Commit 7961100

Browse files
mohammed786ravitejag
authored andcommitted
Refactored the Devlop branch and updated get social command
1 parent 8197f7b commit 7961100

4 files changed

Lines changed: 38 additions & 75 deletions

File tree

api/platformConfiguration.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type Provider struct {
2020
}
2121

2222
type ProviderList struct {
23-
Data1 []Provider `json:"Data"`
23+
Data []Provider `json:"Data"`
2424
}
2525
type FieldTypeConfig struct {
2626
Name string
@@ -29,37 +29,37 @@ type FieldTypeConfig struct {
2929
}
3030

3131
var TypeMap = map[int]FieldTypeConfig{
32-
1: FieldTypeConfig{
32+
1: {
3333
Name: "String",
3434
ShouldDisplayValidaitonRuleInput: true,
3535
ShouldShowOption: false,
3636
},
37-
2: FieldTypeConfig{
37+
2: {
3838
Name: "CheckBox",
3939
ShouldDisplayValidaitonRuleInput: false,
4040
ShouldShowOption: false,
4141
},
42-
3: FieldTypeConfig{
42+
3: {
4343
Name: "Option",
4444
ShouldDisplayValidaitonRuleInput: false,
4545
ShouldShowOption: true,
4646
},
47-
4: FieldTypeConfig{
47+
4: {
4848
Name: "Password",
4949
ShouldDisplayValidaitonRuleInput: true,
5050
ShouldShowOption: false,
5151
},
52-
5: FieldTypeConfig{
52+
5: {
5353
Name: "Hidden",
5454
ShouldDisplayValidaitonRuleInput: true,
5555
ShouldShowOption: false,
5656
},
57-
6: FieldTypeConfig{
57+
6: {
5858
Name: "Email",
5959
ShouldDisplayValidaitonRuleInput: true,
6060
ShouldShowOption: false,
6161
},
62-
7: FieldTypeConfig{
62+
7: {
6363
Name: "Text",
6464
ShouldDisplayValidaitonRuleInput: true,
6565
ShouldShowOption: false,

cmd/add/social/social.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ func add1(opts1 *socialProvider) error {
160160
func verify(str string) (bool, error) {
161161
result, err := api.GetActiveProviders()
162162
var match = false
163-
for i := 0; i < len(result.Data1); i++ {
164-
if str == result.Data1[i].Provider {
163+
for i := 0; i < len(result.Data); i++ {
164+
if str == result.Data[i].Provider {
165165
match = true
166166
}
167167
}

cmd/get/social/social.go

Lines changed: 26 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ var temp string
1111

1212
var Url string
1313

14-
var arr = [5]string{"Facebook", "Google", "Twitter", "LinkedIn", "GitHub"}
15-
1614
func NewsocialCmd() *cobra.Command {
1715

1816
cmd := &cobra.Command{
@@ -21,78 +19,43 @@ func NewsocialCmd() *cobra.Command {
2119
Long: `This commmand lists social providers`,
2220
Example: `$ lr get social`,
2321
RunE: func(cmd *cobra.Command, args []string) error {
24-
fstatus, _ := cmd.Flags().GetBool("all")
25-
if fstatus {
26-
temp = "all"
27-
}
28-
fstatus1, _ := cmd.Flags().GetBool("active")
29-
if fstatus1 {
30-
temp = "active"
31-
}
32-
if !fstatus && !fstatus1 {
33-
fmt.Println("Please use atleast one of the flags 'lr get social --all' or 'lr get social --active'")
34-
return nil
35-
}
3622
return get()
37-
3823
},
3924
}
40-
fl := cmd.Flags()
41-
fl.BoolP("all", "a", false, "option to get all providers")
42-
fl.BoolP("active", "c", false, "option to get active providers")
4325

4426
return cmd
4527
}
4628

4729
func get() error {
48-
if temp == "all" {
49-
res, err := api.GetSites()
50-
if err != nil {
51-
return err
52-
}
53-
if res.Productplan.Name == "free" {
54-
for i := 0; i < 3; i++ {
55-
fmt.Println(i+1, arr[i])
56-
}
57-
return nil
58-
}
59-
if res.Productplan.Name == "developer" {
60-
for i := 0; i < len(arr); i++ {
61-
fmt.Println(i+1, arr[i])
62-
}
63-
return nil
64-
}
30+
31+
resultResp, err := api.GetActiveProviders()
32+
if err != nil {
33+
return err
6534
}
66-
if temp == "active" {
67-
resultResp, err := api.GetActiveProviders()
68-
if err != nil {
69-
return err
70-
}
71-
if len(resultResp.Data1) == 0 {
72-
fmt.Println("There is no social configuration")
73-
return nil
74-
}
75-
var num int
76-
for i := 0; i < len(resultResp.Data1); i++ {
77-
fmt.Print(fmt.Sprint(i+1) + ".")
78-
fmt.Println(resultResp.Data1[i].Provider)
79-
}
80-
// Taking input from user
81-
fmt.Print("Please select a number from 1 to " + fmt.Sprint(len(resultResp.Data1)) + " :")
82-
fmt.Scanln(&num)
83-
for 1 > num || num > len(resultResp.Data1) {
84-
fmt.Print("Please select a number from 1 to " + fmt.Sprint(len(resultResp.Data1)) + " :")
35+
if len(resultResp.Data) == 0 {
36+
fmt.Println("There is no social configuration")
37+
return nil
38+
}
39+
var num int
40+
for i := 0; i < len(resultResp.Data); i++ {
41+
fmt.Print(fmt.Sprint(i+1) + ".")
42+
fmt.Println(resultResp.Data[i].Provider)
43+
}
44+
// Taking input from user
45+
fmt.Print("Please select a number from 1 to " + fmt.Sprint(len(resultResp.Data)) + " :")
46+
fmt.Scanln(&num)
47+
for 1 > num || num > len(resultResp.Data) {
48+
fmt.Print("Please select a number from 1 to " + fmt.Sprint(len(resultResp.Data)) + " :")
8549

86-
fmt.Scanln(&num)
87-
}
88-
fmt.Println("HtmlFileName: " + resultResp.Data1[num-1].HtmlFileName)
89-
fmt.Println("Provider: ", resultResp.Data1[num-1].Provider)
90-
fmt.Println("ProviderId: ", resultResp.Data1[num-1].ProviderId)
91-
fmt.Println("ProviderKey: ", resultResp.Data1[num-1].ProviderKey)
92-
fmt.Println("ProviderSecret: ", resultResp.Data1[num-1].ProviderSecret)
93-
fmt.Println("Scope: ", resultResp.Data1[num-1].Scope)
94-
fmt.Println("Status: ", resultResp.Data1[num-1].Status)
50+
fmt.Scanln(&num)
9551
}
52+
fmt.Println("HtmlFileName: " + resultResp.Data[num-1].HtmlFileName)
53+
fmt.Println("Provider: ", resultResp.Data[num-1].Provider)
54+
fmt.Println("ProviderId: ", resultResp.Data[num-1].ProviderId)
55+
fmt.Println("ProviderKey: ", resultResp.Data[num-1].ProviderKey)
56+
fmt.Println("ProviderSecret: ", resultResp.Data[num-1].ProviderSecret)
57+
fmt.Println("Scope: ", resultResp.Data[num-1].Scope)
58+
fmt.Println("Status: ", resultResp.Data[num-1].Status)
9659

9760
return nil
9861
}

cmd/set/theme/theme.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type body struct {
2424
}
2525
type CustomJS struct {
2626
Content string `json:"Content"`
27-
fileName string `json:"fileName"`
27+
FileName string `json:"fileName"`
2828
}
2929

3030
func NewThemeCmd() *cobra.Command {
@@ -159,7 +159,7 @@ func updateCalls() error {
159159
var customJSProf body
160160
cjs := CustomJS{
161161
Content: "options = {\n \"language\": \"English\"\n}",
162-
fileName: "lr-interface-options",
162+
FileName: "lr-interface-options",
163163
}
164164
customJSAuth.CustomJS = append(customJSAuth.CustomJS, cjs)
165165
customJSProf.CustomJS = append(customJSProf.CustomJS, cjs)

0 commit comments

Comments
 (0)