From e3166a9f4048cd2fd658c55630cfcddb0ededbd9 Mon Sep 17 00:00:00 2001 From: Steve Ramage <49958178+steve-r-west@users.noreply.github.com> Date: Mon, 26 Aug 2024 11:20:29 -0700 Subject: [PATCH] Partially Resolves #472 - Add basic support for Subscriptions (#473) --- .github/workflows/test.yml | 2 +- external/resources/yaml/resources.yaml | 134 +++++++++++++++++++++++ external/runbooks/run-all-runbooks.sh | 7 +- external/runbooks/subscriptions.epcc.yml | 45 ++++++++ 4 files changed, 186 insertions(+), 2 deletions(-) create mode 100644 external/runbooks/subscriptions.epcc.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0f50bfd..cd7b65b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -78,5 +78,5 @@ jobs: uses: actions/upload-artifact@v4 with: name: distribution - path: dist/epcc-cli_linux_amd64 + path: dist/epcc-cli_linux_amd64_v1/epcc retention-days: 5 diff --git a/external/resources/yaml/resources.yaml b/external/resources/yaml/resources.yaml index 6198c55..d8519b1 100644 --- a/external/resources/yaml/resources.yaml +++ b/external/resources/yaml/resources.yaml @@ -2372,3 +2372,137 @@ stores: get-entity: docs: "https://elasticpath.dev/docs/getting-started/api-reference" url: "/v2/stores/{settings}" +subscription-products: + docs: "https://elasticpath.dev/docs/api/subscriptions/products" + json-api-type: subscription_product + json-api-format: compliant + singular-name: subscription-product + get-collection: + docs: https://elasticpath.dev/docs/api/subscriptions/list-products + url: /v2/subscriptions/products + get-entity: + docs: https://elasticpath.dev/docs/api/subscriptions/get-product + url: /v2/subscriptions/products/{subscription_products} + create-entity: + docs: https://elasticpath.dev/docs/api/subscriptions/create-product + url: /v2/subscriptions/products + update-entity: + docs: https://elasticpath.dev/docs/api/subscriptions/update-product + url: /v2/subscriptions/products/{subscription_products} + delete-entity: + docs: https://elasticpath.dev/docs/api/subscriptions/delete-product + url: /v2/subscriptions/products/{subscription_products} + attributes: + ^price\.([a-zA-Z0-9-_]+)\.amount$: + type: INT + ^price\.([a-zA-Z0-9-_]+)\.includes_tax$: + type: BOOL + description: + type: STRING + autofill: VALUE:Auto Generated + external_ref: + type: STRING + main_image: + type: STRING + name: + type: STRING + autofill: FUNC:Name + price_units.amount: + type: INT + price_units.unit: + type: ENUM:day,month + sku: + type: STRING +subscription-plans: + docs: "https://elasticpath.dev/docs/api/subscriptions/plans" + json-api-type: subscription_plan + json-api-format: compliant + singular-name: subscription-plan + get-collection: + docs: "https://elasticpath.dev/docs/api/subscriptions/list-plans" + url: /v2/subscriptions/plans + get-entity: + docs: "https://elasticpath.dev/docs/api/subscriptions/get-plan" + url: /v2/subscriptions/plans/{subscription_plans} + create-entity: + docs: "https://elasticpath.dev/docs/api/subscriptions/create-plan" + url: /v2/subscriptions/plans + update-entity: + docs: "https://elasticpath.dev/docs/api/subscriptions/update-plan" + url: /v2/subscriptions/plans/{subscription_plans} + delete-entity: + docs: "https://elasticpath.dev/docs/api/subscriptions/delete-plan" + url: /v2/subscriptions/plans/{subscription_plans} + attributes: + ^fixed_price\.(USD|[a-zA-Z0-9-_]+)\.amount$: + type: INT + ^fixed_price\.(USD|[a-zA-Z0-9-_]+)\.includes_tax$: + type: BOOL + billing_day: + type: INT + billing_frequency: + type: INT + autofill: VALUE:1 + billing_interval_type: + type: ENUM:day,week,month,year + autofill: VALUE:day + billing_month_day: + type: INT + can_cancel: + type: BOOL + autofill: VALUE:true + can_pause: + type: BOOL + autofill: VALUE:true + can_resume: + type: BOOL + autofill: VALUE:true + description: + type: STRING + autofill: VALUE:Auto Generated + end_behavior: + type: ENUM:close,roll + autofill: VALUE:close + external_ref: + type: STRING + name: + type: STRING + autofill: FUNC:Name + plan_length: + type: INT + autofill: VALUE:1 + status: + type: ENUM:active,draft,archive + trial_period: + type: INT +subscription-offerings: + docs: "https://elasticpath.dev/docs/api/subscriptions/offerings" + json-api-type: subscription_offering + json-api-format: compliant + get-collection: + docs: "https://elasticpath.dev/docs/api/subscriptions/create-offering" + url: /v2/subscriptions/offerings + get-entity: + docs: "https://elasticpath.dev/docs/api/subscriptions/get-offering" + url: /v2/subscriptions/offerings/{subscription_offerings} + create-entity: + docs: "https://elasticpath.dev/docs/api/subscriptions/create-offering" + url: /v2/subscriptions/offerings + update-entity: + docs: "https://elasticpath.dev/docs/api/subscriptions/update-offering" + url: /v2/subscriptions/offerings/{subscription_offerings} + delete-entity: + docs: "https://elasticpath.dev/docs/api/subscriptions/delete-offering" + url: /v2/subscriptions/offerings/{subscription_offerings} + attributes: + description: + type: STRING + autofill: VALUE:Auto Generated + external_ref: + type: STRING + id: + type: RESOURCE_ID:subscription-offerings + name: + type: STRING + autofill: FUNC:Name + singular-name: subscription-offering diff --git a/external/runbooks/run-all-runbooks.sh b/external/runbooks/run-all-runbooks.sh index b441fb9..120966d 100755 --- a/external/runbooks/run-all-runbooks.sh +++ b/external/runbooks/run-all-runbooks.sh @@ -11,8 +11,13 @@ set -x #Let's test that epcc command works after an embarrassing bug that caused it to panic :( -#epcc +epcc +echo "Starting Subscriptions Tests" +epcc reset-store .+ +epcc runbooks run subscriptions create-subscription-plans +epcc runbooks run subscriptions create-subscription-products +epcc runbooks run subscriptions create-subscription-offerings echo "Starting Account Cart Association Tests" epcc reset-store .+ diff --git a/external/runbooks/subscriptions.epcc.yml b/external/runbooks/subscriptions.epcc.yml new file mode 100644 index 0000000..9b9fe6f --- /dev/null +++ b/external/runbooks/subscriptions.epcc.yml @@ -0,0 +1,45 @@ +name: "subscriptions" +description: + long: "Utilities for working with subscriptions" + short: "Utilities for working with subscriptions" +actions: + create-subscription-products: + variables: + count: + type: INT + default: 10 + description: + short: "Create a lot of subscription products" + description: + short: "Create a number of products" + commands: + - | + {{ range untilStep 0 .count 1 -}}epcc create --skip-alias-processing -s subscription-product --auto-fill + {{ end }} + create-subscription-plans: + variables: + count: + type: INT + default: 10 + description: + short: "Create a lot of subscription plans" + description: + short: "Create a number of orders" + commands: + - | + {{ range untilStep 0 .count 1 -}}epcc create --skip-alias-processing -s subscription-plan status active --auto-fill billing_interval_type day billing_frequency 214 plan_length 1 end_behavior close can_pause true can_resume true can_cancel true fixed_price.USD.amount {{ pseudoRandInt 1 200 }}00 fixed_price.USD.includes_tax true + {{ end }} + create-subscription-offerings: + variables: + count: + type: INT + default: 10 + description: + short: "Create a lot of subscription offerings" + description: + short: "Create a number of offerings" + commands: + - | + {{ range untilStep 0 .count 1 -}}epcc create --skip-alias-processing -s subscription-offering --auto-fill + {{ end }} +