简体   繁体   中英

Laravel Shopify Osiset: How do I use Osiset functions correctly?

I've been dealing with the Laravel/Osiset-Shopify framework for some time and even after a long research there are things that I don't understand yet.

For example, if I want to fetch my webhooks, it is relatively cumbersome

Auth::user()->api()->rest('GET', '/admin/api/2021-04/webhooks.json')['body']

There is a function getWebhooks() under \osiset\laravel-shopify\src\ShopifyApp\Services\ApiHelper.php which I would much rather use.

I came across this documentation from Osiset, for which I don't know how to use it.

I tried to load the service use Osiset\ShopifyApp\Services\ApiHelper; and get the output data dd(ApiHelper::getWebhooks([])); . However, I get the error message Non-static method Osiset\ShopifyApp\Services\ApiHelper::getWebhooks() cannot be called statically .

Also

$foo = new ApiHelper;
dd( $foo->getWebhooks() );

did not lead to any result: Call to a member function rest() on null .

Can someone show me how to access Osiset's internal functions and use the documentation properly?

You can use this documentation

and for the webhooks.json, You can use this to get the results $userId will be the user's primary key.

 $shop = User::find($userId); 
 $method = 'GET';
 $url = '/admin/api/2021-04/webhooks.json';
 return  $shop->api()->rest($method, $url, []);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM