Skip to content

Commit 3235b4b

Browse files
committed
made the URL dynamic
1 parent 568066e commit 3235b4b

File tree

5 files changed

+14
-22
lines changed

5 files changed

+14
-22
lines changed

cmd/pull.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ func saveResponseAndConvert() {
6363

6464
var AccessToken = config.FetchAndValidate("AccessToken") // returns string
6565

66+
var PullURL = config.DevnagriURL + "/project/pull"
67+
6668
resp, err := resty.R().
6769
SetHeader("Accept", "application/json").
6870
SetHeader("Content-Type", "multipart/form-data").
@@ -71,7 +73,7 @@ func saveResponseAndConvert() {
7173
"client_id": ClientID,
7274
"client_secret": ClientSecret,
7375
"project_key": ProjectKey}).
74-
Post("http://dev.devnagri.co.in/api/project/pull")
76+
Post(PullURL)
7577

7678
if err != nil {
7779
panic(err)

cmd/push.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ func listAllFilesAndPush() {
6767

6868
var Extension = config.FetchAndValidate("Extension")
6969

70+
var PushURL = config.DevnagriURL + "/project/push"
71+
7072
resp, err := resty.R().
7173
SetHeader("Accept", "application/json").
7274
SetHeader("Content-Type", "multipart/form-data").
@@ -81,7 +83,7 @@ func listAllFilesAndPush() {
8183
"file[0][file_type]": "xml",
8284
"file[0][location]": filename,
8385
}).
84-
Post("http://dev.devnagri.co.in/api/project/push")
86+
Post(PushURL)
8587

8688
if err != nil {
8789
panic(err)

cmd/status.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,16 @@ func fetchStatus() {
6464

6565
var AccessToken = config.FetchAndValidate("AccessToken") // returns string
6666

67+
var StatusURL = config.DevnagriURL + "/project/status"
68+
6769
resp, err := resty.R().
6870
SetHeader("Accept", "application/json").
6971
SetAuthToken(AccessToken).
7072
SetFormData(map[string]string{
7173
"client_id": ClientID,
7274
"client_secret": ClientSecret,
7375
"project_key": ProjectKey}).
74-
Post("http://dev.devnagri.co.in/api/project/status")
76+
Post(StatusURL)
7577

7678
if err != nil {
7779
panic(err)
@@ -124,8 +126,7 @@ func fetchStatus() {
124126
fmt.Println("totalWordsCount : ", totalWordsCount)
125127
fmt.Println("translatedWordsCount : ", translatedWordsCount)
126128

127-
128-
//TODO: Do some maths here to print out the percentage
129+
//TODO: Do some maths here to print out the percentage
129130
/*
130131
for _, y := range valChildren {
131132
fmt.Println("\n", y)

cmd/validate.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,15 @@ func validate() {
5858

5959
var ProjectKey = config.FetchAndValidate("ProjectKey") // returns string
6060

61+
var ValidateURL = config.DevnagriURL + "/project/validations"
62+
6163
resp, err := resty.R().
6264
SetHeader("Content-Type", "multipart/form-data").
6365
SetFormData(map[string]string{
6466
"client_id": ClientID,
6567
"client_secret": ClientSecret,
6668
"project_key": ProjectKey}).
67-
Post("http://dev.devnagri.co.in/api/key/validations")
68-
// Post("http://192.168.60.10/api/key/validations")
69+
Post(ValidateURL)
6970

7071
if err != nil {
7172
panic(err)

config/config.go

+1-15
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,4 @@ func FetchAndValidate(fieldName string) string {
2727

2828
}
2929

30-
/*
31-
var ClientID = fetchAndValidate("ClientID") // returns string
32-
33-
var ClientSecret = fetchAndValidate("ClientSecret") // returns string
34-
35-
var ProjectKey = fetchAndValidate("ProjectKey") // returns string
36-
37-
var RootDir = fetchAndValidate("RootDir") // returns string
38-
39-
var SourceLanguage = fetchAndValidate("SourceLanguage") // returns string
40-
41-
var TargetLanguages = fetchAndValidate("TargetLanguages") // returns string
42-
43-
var GlobalPreferenceInCaseOfMergeConflict = fetchAndValidate("GlobalPreferenceInCaseOfMergeConflict") // returns string
44-
*/
30+
var DevnagriURL = "http://dev.devnagri.co.in/api"

0 commit comments

Comments
 (0)