Example #1
0
func (c *Client) version() (*apiVersionResponse, error) {
	var resp *apiVersionResponse
	err := providers.Do(
		c,
		"GET",
		fmt.Sprintf("%s/api_version", c.EndPoint()),
		nil,
		&resp)
	log.Printf("[DEBUG] FreeboxAPI version response: %v", resp)
	return resp, err
}
Example #2
0
func (c *Client) closeSession() (*apiLogoutSessionResponse, error) {
	var resp *apiLogoutSessionResponse
	err := providers.Do(
		c,
		"POST",
		fmt.Sprintf("%s/login/logout", c.EndPoint()),
		nil,
		&resp)
	if err != nil {
		return nil, err
	}
	log.Printf("[DEBUG] FreeboxAPI close session response: %v", resp)
	c.SessionToken = ""
	return resp, err
}
Example #3
0
func (c *Client) connectionStatus() (*apiConnectionStatusResponse, error) {
	log.Printf("[DEBUG] FreeboxAPI connection status\n")
	var resp *apiConnectionStatusResponse
	err := providers.Do(
		c,
		"GET",
		c.getFreeboxAPIRequest("connection"),
		nil,
		&resp)
	if err != nil {
		return nil, err
	}
	log.Printf("[DEBUG] FreeboxAPI connection status response: %v", resp)
	return resp, nil
}
Example #4
0
func (c *Client) login() (*apiLoginResponse, error) {
	log.Printf("[DEBUG] FreeboxAPI login\n")
	var resp *apiLoginResponse
	err := providers.Do(
		c,
		"GET",
		c.getFreeboxAPIRequest("login"),
		nil,
		&resp)
	if err != nil {
		return nil, err
	}
	c.Challenge = resp.Result.Challenge
	log.Printf("[DEBUG] FreeboxAPI login response: %v", resp)
	return resp, nil
}
Example #5
0
func (c *Client) authorize() (*apiAuthorizeResponse, error) {
	log.Printf("[DEBUG] FreeboxAPI retrieve authorization\n")
	var resp *apiAuthorizeResponse
	err := providers.Do(
		c,
		"POST",
		c.getFreeboxAPIRequest("login/authorize"),
		apiAuthorizeRequest{
			AppID:      c.Identifier,
			AppName:    c.Name,
			AppVersion: c.Version,
			DeviceName: c.DeviceName,
		},
		&resp)
	if err != nil {
		return nil, err
	}
	log.Printf("[DEBUG] FreeboxAPI Authorize response: %v", resp)
	return resp, nil
}
Example #6
0
func (c *Client) openSession() (*apiLoginSessionResponse, error) {
	log.Printf("[DEBUG] FreeboxAPI open session\n")
	hash := hmac.New(sha1.New, []byte(c.Token))
	hash.Write([]byte(c.Challenge))
	c.Password = fmt.Sprintf("%x", hash.Sum(nil))
	var resp *apiLoginSessionResponse
	err := providers.Do(
		c,
		"POST",
		c.getFreeboxAPIRequest("login/session"),
		apiLoginSessionRequest{
			AppID:      c.Identifier,
			AppVersion: c.Version,
			Password:   c.Password,
		},
		&resp)
	if err != nil {
		return nil, err
	}
	log.Printf("[DEBUG] FreeboxAPI open session response: %v", resp)
	c.SessionToken = resp.Result.SessionToken
	return resp, nil
}