Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to assign a default value to $maxTries in REST requests #281

Closed
3 of 4 tasks
ugurarici opened this issue Jun 16, 2023 · 2 comments · May be fixed by #282
Closed
3 of 4 tasks

Ability to assign a default value to $maxTries in REST requests #281

ugurarici opened this issue Jun 16, 2023 · 2 comments · May be fixed by #282
Labels

Comments

@ugurarici
Copy link

Overview

I would like to request the ability to assign a default value to the $maxTries parameter in REST requests.

Type

  • New feature
  • Changes to existing features

Motivation

What inspired this feature request? What problems were you facing?

Currently, when using "Rest resources" to make requests, for example, when calling the save() method on a PHP object derived from the Shopify\Rest\Admin2023_04\Customer class, a default Shopify\Clients\Rest object is created here. Depending on the desired operation and the corresponding HTTP method required, one of the get(), post(), put(), or delete() methods is invoked on this object. Although these methods can accept a $tries parameter, if this parameter is not explicitly provided when calling the relevant method, it is assumed to be null, and a default $maxTries value of 1 is assigned. When we create an object from a "Rest resource" class like Shopify\Rest\Admin2023_04\Customer, we do not directly invoke the get(), post(), put(), or delete() methods ourselves, as the class internally handles this. Therefore, we are unable to pass the $tries parameter ourselves. Consequently, when using "Rest resources," we cannot achieve multiple retries for an operation. If we can assign a default $tries value at some point during the package initialization, for example when setting up the library with Shopify\Context::initialize method, unless we override it, we can ensure that the operation is retried at least that many times.

So we can initialize the Context with something like this:

Context::initialize(
    apiKey: $_ENV['SHOPIFY_API_KEY'],
    apiSecretKey: $_ENV['SHOPIFY_API_SECRET'],
    scopes: $_ENV['SHOPIFY_APP_SCOPES'],
    hostName: $_ENV['SHOPIFY_APP_HOST_NAME'],
    sessionStorage: new FileSessionStorage('/tmp/php_sessions'),
    apiVersion: '2023-04',
    maxTries: 5,
    isEmbeddedApp: true,
    isPrivateApp: false,
);

And request method of Shopify\Clients\Http can use this as default value.

$maxTries = $tries ?? Context::$MAX_TRIES;

instead of

$maxTries = $tries ?? 1;

Area

  • Add any relevant Area: <area> labels to this issue

Checklist

  • I have described this feature request in a way that is actionable (if possible)
@github-actions
Copy link

This issue is stale because it has been open for 60 days with no activity. It will be closed if no further action occurs in 14 days.

@github-actions github-actions bot added the Stale label Aug 16, 2023
@github-actions
Copy link

We are closing this issue because it has been inactive for a few months.
This probably means that it is not reproducible or it has been fixed in a newer version.
If it’s an enhancement and hasn’t been taken on since it was submitted, then it seems other issues have taken priority.

If you still encounter this issue with the latest stable version, please reopen using the issue template. You can also contribute directly by submitting a pull request– see the CONTRIBUTING.md file for guidelines

Thank you!

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant