php.blade.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. ```php
  2. $client = new \GuzzleHttp\Client();
  3. @if($hasRequestOptions)
  4. $response = $client->{{ strtolower($route['methods'][0]) }}(
  5. '{{ rtrim($baseUrl, '/') . '/' . ltrim($route['boundUri'], '/') }}',
  6. [
  7. @if(!empty($route['headers']))
  8. 'headers' => {!! \Knuckles\Scribe\Tools\WritingUtils::printPhpValue($route['headers'], 8) !!},
  9. @endif
  10. @if(!empty($route['cleanQueryParameters']))
  11. 'query' => {!! \Knuckles\Scribe\Tools\WritingUtils::printQueryParamsAsKeyValue($route['cleanQueryParameters'], "'", "=>", 12, "[]", 8) !!},
  12. @endif
  13. @if(count($route['fileParameters']))
  14. 'multipart' => [
  15. @foreach($route['cleanBodyParameters'] as $parameter => $value)
  16. @foreach(\Knuckles\Scribe\Tools\WritingUtils::getParameterNamesAndValuesForFormData($parameter,$value) as $key => $actualValue)
  17. [
  18. 'name' => '{!! $key !!}',
  19. 'contents' => '{!! $actualValue !!}'
  20. ],
  21. @endforeach
  22. @endforeach
  23. @foreach($route['fileParameters'] as $parameter => $file)
  24. [
  25. 'name' => '{!! $parameter !!}',
  26. 'contents' => fopen('{!! $file->path() !!}', 'r')
  27. ],
  28. @endforeach
  29. ],
  30. @elseif(!empty($route['cleanBodyParameters']))
  31. 'json' => {!! \Knuckles\Scribe\Tools\WritingUtils::printPhpValue($route['cleanBodyParameters'], 8) !!},
  32. @endif
  33. ]
  34. );
  35. @else
  36. $response = $client->{{ strtolower($route['methods'][0]) }}('{{ rtrim($baseUrl, '/') . '/' . ltrim($route['boundUri'], '/') }}');
  37. @endif
  38. $body = $response->getBody();
  39. print_r(json_decode((string) $body));
  40. ```