func (self *Client) Fetch(method string, url string, structure interface{}) error {
	client := &http.Client{}

	req, err := http.NewRequest(method, "https://api.snowflakedev.org"+url, nil)
	if err != nil {
		return errors.New("UnexpectedError: Failed making a request")
	}

	req.Header.Add("Authorization", self.Token)

	res, err := client.Do(req)
	if err != nil {
		return errors.New("UnexpectedError: Failed making a request")
	}

	defer res.Body.Close()

	data, readErr := ioutil.ReadAll(res.Body)
	if readErr != nil {
		return errors.New("UnexpectedError: Failed reading request data")
	}

	fmt.Println(string(data))

	unusual := isUnusualResponse(res.StatusCode)
	if unusual {
		return errors.New("SnowflakeApiError: Snowflake api sent an unusual api response as " + string(data) + " with status code as " + strconv.Itoa(res.StatusCode) + "!")
	}

	marshallErr := json.Unmarshal(data, structure)
	if marshallErr != nil {
		return errors.New("UnexpectedError: Failed while marshalling json: " + marshallErr.Error())
	}

	return nil
}
// Simply fetches from the snowflake api and returns a json parsed object!
Simply fetches from the snowflake api and returns a json parsed object!
// Simply fetches from the snowflake api and returns a json parsed object!
func (self *Client) Fetch(method string, url string, structure interface{}) error {
	client := &http.Client{}
	req, err := http.NewRequest(method, "https://api.snowflakedev.org"+url, nil)
	if err != nil {
		return errors.New("UnexpectedError: Failed making a request")
	}
	req.Header.Add("Authorization", self.Token)
	res, err := client.Do(req)
	if err != nil {
		return errors.New("UnexpectedError: Failed making a request")
	}
	defer res.Body.Close()
	data, readErr := ioutil.ReadAll(res.Body)
	if readErr != nil {
		return errors.New("UnexpectedError: Failed reading request data")
	}
	fmt.Println(string(data))
	unusual := isUnusualResponse(res.StatusCode)
	if unusual {
		return errors.New("SnowflakeApiError: Snowflake api sent an unusual api response as " + string(data) + " with status code as " + strconv.Itoa(res.StatusCode) + "!")
	}
	marshallErr := json.Unmarshal(data, structure)
	if marshallErr != nil {
		return errors.New("UnexpectedError: Failed while marshalling json: " + marshallErr.Error())
	}
	return nil
}
func ( self * Client ) Fetch ( method string , url string , structure interface { } ) error { client := & http . Client { } req , err := http . NewRequest ( method , " " + url , nil ) if err != nil { return errors . New ( " " ) } req . Header . Add ( " " , self . Token ) res , err := client . Do ( req ) if err != nil { return errors . New ( " " ) } defer res . Body . Close ( ) data , readErr := ioutil . ReadAll ( res . Body ) if readErr != nil { return errors . New ( " " ) } fmt . Println ( string ( data ) ) unusual := isUnusualResponse ( res . StatusCode ) if unusual { return errors . New ( " " + string ( data ) + " " + strconv . Itoa ( res . StatusCode ) + " " ) } marshallErr := json . Unmarshal ( data , structure ) if marshallErr != nil { return errors . New ( " " + marshallErr . Error ( ) ) } return nil }
Simply fetches from the snowflake api and returns a json parsed object!
Simply fetches from the snowflake api and returns a json parsed object!