Skip to content

Commit 5be018f

Browse files
authored
Merge pull request #1 from AndroidPoet/fix/api-v2-corrections
fix(api-v2): correct endpoints and request bodies to match REST API v2
2 parents 5691b4c + 3b89084 commit 5be018f

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

cmd/revenuecat-cli/commands/apps/apps.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ func runAPIKeys(cmd *cobra.Command, args []string) error {
412412
} `json:"items"`
413413
}
414414

415-
path := fmt.Sprintf("/projects/%s/apps/%s/api_keys", client.GetProjectID(), appID)
415+
path := fmt.Sprintf("/projects/%s/apps/%s/public_api_keys", client.GetProjectID(), appID)
416416
if err := client.Get(ctx, path, &resp); err != nil {
417417
return err
418418
}

cmd/revenuecat-cli/commands/customers/customers.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ var (
2121
startAfter string
2222
allPages bool
2323
attributes string
24+
expiresAt int64
2425
)
2526

2627
// CustomersCmd manages customers
@@ -191,8 +192,10 @@ func init() {
191192
// Grant entitlement flags
192193
grantEntitlementCmd.Flags().StringVar(&customerID, "customer-id", "", "customer ID")
193194
grantEntitlementCmd.Flags().StringVar(&entitlementID, "entitlement-id", "", "entitlement ID")
195+
grantEntitlementCmd.Flags().Int64Var(&expiresAt, "expires-at", 0, "expiry date in ms since epoch (required by the API)")
194196
grantEntitlementCmd.MarkFlagRequired("customer-id")
195197
grantEntitlementCmd.MarkFlagRequired("entitlement-id")
198+
grantEntitlementCmd.MarkFlagRequired("expires-at")
196199

197200
// Revoke entitlement flags
198201
revokeEntitlementCmd.Flags().StringVar(&customerID, "customer-id", "", "customer ID")
@@ -347,7 +350,7 @@ func runCreate(cmd *cobra.Command, args []string) error {
347350
ctx, cancel := client.Context()
348351
defer cancel()
349352

350-
body := map[string]interface{}{"app_user_id": customerID}
353+
body := map[string]interface{}{"id": customerID}
351354
path := fmt.Sprintf("/projects/%s/customers", client.GetProjectID())
352355
var customer map[string]interface{}
353356
if err := client.Post(ctx, path, body, &customer); err != nil {
@@ -655,7 +658,10 @@ func runGrantEntitlement(cmd *cobra.Command, args []string) error {
655658
ctx, cancel := client.Context()
656659
defer cancel()
657660

658-
body := map[string]interface{}{"entitlement_id": entitlementID}
661+
body := map[string]interface{}{
662+
"entitlement_id": entitlementID,
663+
"expires_at": expiresAt,
664+
}
659665
path := fmt.Sprintf("/projects/%s/customers/%s/actions/grant_entitlement", client.GetProjectID(), customerID)
660666
if err := client.Post(ctx, path, body, nil); err != nil {
661667
return err

cmd/revenuecat-cli/commands/entitlements/entitlements.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ func runUpdate(cmd *cobra.Command, args []string) error {
276276

277277
var ent EntitlementInfo
278278
path := fmt.Sprintf("/projects/%s/entitlements/%s", client.GetProjectID(), entitlementID)
279-
if err := client.Patch(ctx, path, body, &ent); err != nil {
279+
if err := client.Post(ctx, path, body, &ent); err != nil {
280280
return err
281281
}
282282

0 commit comments

Comments
 (0)