googleapis / google-api-python-client

๐Ÿ The official Python client library for Google's discovery based APIs.
https://googleapis.github.io/google-api-python-client/docs/
Apache License 2.0
7.54k stars 2.37k forks source link

Add a base plan #1892

Open YonatanSasoony opened 1 year ago

YonatanSasoony commented 1 year ago

Hey!

What is the best way to add a BasePlan to an existing subscription?

According to google_play_api.monetization.subscriptions.BasePlans there is not an update method.

I've tried to use google_play_api.monetization.subscriptions.patch() to update the BasePlans list:

   subscription = (
        google_play_api.monetization()
        .subscriptions()
        .get(
            packageName=package_name,
            productId=product_id,
        )
        .execute()
    )
    base_plans = subscription["basePlans"]
    base_plans.append(new_base_plan_details)
    subscription["basePlans"] = base_plans
    create_base_plan_request = (
        google_play_api.monetization()
        .subscriptions()
        .patch(
            packageName=package_name,
            productId=product_id,
            body=subscription,
        )
    )
  create_base_plan_request.uri += "&regionsVersion.version=2022/01"
  create_base_plan_request.uri += "&updateMask=Subscription.basePlans"
  create_base_plan_request.execute()

And got 400 Error: Request contains an invalid argument. Any idea what is wrong here?

parthea commented 1 year ago

Hi @YonatanSasoony,

Please could you try out a similar request in the 'Try this API' interface on this page and check whether the issue still exists? This will determine if it is an API issue or client library issue.

In addition, for updateMask, can you try using basePlans instead of Subscription.basePlans as shown here?

https://developers.google.com/android-publisher/api-ref/rest/v3/monetization.subscriptions#Subscription

ghost commented 1 year ago

@YonatanSasoony did you get it to work? Struggling with patch as well. Same issues as #2025

leemyongkun commented 5 months ago

Subscription.basePlans => base_plans ๋กœ ๋„ฃ์–ด์•ผ 200์œผ๋กœ ๊ฒฐ๊ณผ๋ฅผ ๋ฐ›์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋‹ค๋งŒ, ๊ทธ๋งˆ์ €๋„ BasePlan ์ถ”๊ฐ€๊ฐ€ ์•„๋‹ˆ๊ณ , ์ˆ˜์ •์‚ฌํ•ญ์ž…๋‹ˆ๋‹ค. productId๊ฐ€ ์—†์„๊ฒฝ์šฐ์—๋Š” ์‹ ๊ทœ ๊ตฌ๋…์ด ์ƒ์„ฑ๋˜๋Š” ๊ตฌ์กฐ์ธ๊ฒƒ๊ฐ™๋„ค์š”.