mirror of
https://github.com/passbolt/go-passbolt.git
synced 2025-09-13 14:29:09 +00:00
move api package to sub folder
This commit is contained in:
parent
ff29c83d56
commit
ff1be787f2
23 changed files with 61 additions and 61 deletions
39
api/favorites.go
Normal file
39
api/favorites.go
Normal file
|
@ -0,0 +1,39 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// Favorite is a Favorite
|
||||
type Favorite struct {
|
||||
ID string `json:"id,omitempty"`
|
||||
Created *Time `json:"created,omitempty"`
|
||||
ForeignKey string `json:"foreign_key,omitempty"`
|
||||
ForeignModel string `json:"foreign_model,omitempty"`
|
||||
Modified *Time `json:"modified,omitempty"`
|
||||
}
|
||||
|
||||
// CreateFavorite Creates a new Passbolt Favorite for the given Resource ID
|
||||
func (c *Client) CreateFavorite(ctx context.Context, resourceID string) (*Favorite, error) {
|
||||
msg, err := c.DoCustomRequest(ctx, "POST", "/favorites/resource/"+resourceID+".json", "v2", nil, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var favorite Favorite
|
||||
err = json.Unmarshal(msg.Body, &favorite)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &favorite, nil
|
||||
}
|
||||
|
||||
// DeleteFavorite Deletes a Passbolt Favorite
|
||||
func (c *Client) DeleteFavorite(ctx context.Context, favoriteID string) error {
|
||||
_, err := c.DoCustomRequest(ctx, "DELETE", "/favorites/"+favoriteID+".json", "v2", nil, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue