Restructure code
This commit is contained in:
parent
87f0ed570d
commit
32322f02b2
12
Grabazine.go
12
Grabazine.go
|
|
@ -1,8 +1,6 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"./src/LibraryDto"
|
|
||||||
"./src/LoginDto"
|
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"flag"
|
"flag"
|
||||||
|
|
@ -104,7 +102,7 @@ func main() {
|
||||||
fmt.Println("Terminating the application...")
|
fmt.Println("Terminating the application...")
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetPages(userToken LoginDto.Response, issue LibraryDto.Data) Response {
|
func GetPages(userToken LoginResponse, issue LibraryData) Response {
|
||||||
|
|
||||||
client := &http.Client{
|
client := &http.Client{
|
||||||
}
|
}
|
||||||
|
|
@ -140,7 +138,7 @@ func GetInitialToken() (token string, err error) {
|
||||||
return string(found[2]), nil
|
return string(found[2]), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetLoginToken(initialToken string, username string, password string) LoginDto.Response{
|
func GetLoginToken(initialToken string, username string, password string) LoginResponse{
|
||||||
client := &http.Client{
|
client := &http.Client{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -153,7 +151,7 @@ func GetLoginToken(initialToken string, username string, password string) LoginD
|
||||||
resp, _ := client.Do(req)
|
resp, _ := client.Do(req)
|
||||||
data, _ := ioutil.ReadAll(resp.Body)
|
data, _ := ioutil.ReadAll(resp.Body)
|
||||||
|
|
||||||
responseType := LoginDto.Response{}
|
responseType := LoginResponse{}
|
||||||
|
|
||||||
_ = json.Unmarshal([]byte(data), &responseType)
|
_ = json.Unmarshal([]byte(data), &responseType)
|
||||||
|
|
||||||
|
|
@ -161,7 +159,7 @@ func GetLoginToken(initialToken string, username string, password string) LoginD
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetLibrary(userToken LoginDto.Response) LibraryDto.Response{
|
func GetLibrary(userToken LoginResponse) LibraryResponse{
|
||||||
client := &http.Client{
|
client := &http.Client{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -173,7 +171,7 @@ func GetLibrary(userToken LoginDto.Response) LibraryDto.Response{
|
||||||
resp, _ := client.Do(req)
|
resp, _ := client.Do(req)
|
||||||
data, _ := ioutil.ReadAll(resp.Body)
|
data, _ := ioutil.ReadAll(resp.Body)
|
||||||
|
|
||||||
responseType := LibraryDto.Response{}
|
responseType := LibraryResponse{}
|
||||||
|
|
||||||
_ = json.Unmarshal(data, &responseType)
|
_ = json.Unmarshal(data, &responseType)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
package LibraryDto
|
package main
|
||||||
|
|
||||||
type Response struct {
|
type LibraryResponse struct {
|
||||||
Status bool `json:"status"`
|
Status bool `json:"status"`
|
||||||
Data []Data `json:"data"`
|
Data []LibraryData `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Data struct {
|
type LibraryData struct {
|
||||||
Id int `json:"id"`
|
Id int `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Publication Publication `json:"publication"`
|
Publication Publication `json:"publication"`
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
package LoginDto
|
package main
|
||||||
|
|
||||||
type Response struct {
|
type LoginResponse struct {
|
||||||
Status bool `json:"status"`
|
Status bool `json:"status"`
|
||||||
Data Data `json:"data"`
|
Data LoginData `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Data struct {
|
type LoginData struct {
|
||||||
User User `json:"user"`
|
User User `json:"user"`
|
||||||
Token Token `json:"token"`
|
Token Token `json:"token"`
|
||||||
RefreshToken string `json:"refreshToken"`
|
RefreshToken string `json:"refreshToken"`
|
||||||
Loading…
Reference in New Issue