feat: sign in to IMVU for Access Pass products (#4)
Co-authored-by: dhkatz <[email protected]>
This commit was merged in pull request #4.
This commit is contained in:
1 parent
dd8205602c
commit
145ebf25c1
11 files changed
+1001
-24
No files matched your search
+46
-2
@@ -70,15 +70,59 @@ type Config struct {
|
||||
Accounts []Account `json:"accounts"`
|
||||
}
|
||||
|
||||
// Job is a claimed import job. Rating is IMVU's ("general", "adult"), or "" when the hub couldn't see it.
|
||||
// Job is a claimed job. Rating is IMVU's ("general", "adult"), or "" when IMVU hides the product from the hub.
|
||||
type Job struct {
|
||||
ID string `json:"id"`
|
||||
Kind string `json:"kind"` // "import" or "recheck"
|
||||
Kind string `json:"kind"` // "import", "recheck", or "list" (a whole shop, signed in)
|
||||
IMVUProduct int64 `json:"imvuProduct"`
|
||||
IMVUCreator int64 `json:"imvuCreator"` // a "list" job's shop
|
||||
LastRevision int `json:"lastRevision"` // the newest IMVU revision imported already, or 0
|
||||
Rating string `json:"rating"`
|
||||
}
|
||||
|
||||
// Seen is a product as the importer's IMVU account sees it.
|
||||
type Seen struct {
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Rating string `json:"rating"`
|
||||
CreatorID int64 `json:"creatorId"`
|
||||
CreatorName string `json:"creatorName"`
|
||||
Purchasable bool `json:"purchasable"`
|
||||
}
|
||||
|
||||
// Listing reports a "list" job's shop, as the importer's account lists it; the hub keeps and queues its products.
|
||||
func (c *Client) Listing(ctx context.Context, job string, products []Seen) (listed, queued int, err error) {
|
||||
if products == nil {
|
||||
products = []Seen{}
|
||||
}
|
||||
var r struct {
|
||||
Listed int `json:"listed"`
|
||||
Queued int `json:"queued"`
|
||||
}
|
||||
err = c.do(ctx, http.MethodPost, "/api/v1/importer/jobs/"+url.PathEscape(job)+"/listing", map[string]any{"products": products}, &r)
|
||||
return r.Listed, r.Queued, err
|
||||
}
|
||||
|
||||
// Info reports a job's product as the importer's account sees it (nil: not at all). The hub answers its rating
|
||||
// (now known, "" if not) and whether the job's grant covers it.
|
||||
func (c *Client) Info(ctx context.Context, job string, p *Seen) (rating string, covered bool, err error) {
|
||||
body := map[string]any{"found": false}
|
||||
if p != nil {
|
||||
body = map[string]any{"found": true, "name": p.Name, "rating": p.Rating, "creatorId": p.CreatorID, "creatorName": p.CreatorName, "purchasable": p.Purchasable}
|
||||
}
|
||||
var r struct {
|
||||
Rating *string `json:"rating"`
|
||||
Covered bool `json:"covered"`
|
||||
}
|
||||
if err := c.do(ctx, http.MethodPost, "/api/v1/importer/jobs/"+url.PathEscape(job)+"/info", body, &r); err != nil {
|
||||
return "", false, err
|
||||
}
|
||||
if r.Rating != nil {
|
||||
rating = *r.Rating
|
||||
}
|
||||
return rating, r.Covered, nil
|
||||
}
|
||||
|
||||
// Hello sends the importer's version and public key (base64 SPKI) and returns its config.
|
||||
func (c *Client) Hello(ctx context.Context, version, publicKey string) (*Config, error) {
|
||||
var cfg Config
|
||||
|
||||
Reference in new issue
Block a user