Skip to content

Commit 65b3cfb

Browse files
committed
Add Ruby example
1 parent 0e0e47b commit 65b3cfb

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
@php
2+
/** @var Knuckles\Camel\Output\OutputEndpointData $endpoint */
3+
@endphp
4+
5+
```ruby
6+
7+
require 'rest-client'
8+
9+
@if(!empty($endpoint->cleanBodyParameters))
10+
body = {!! json_encode($endpoint->cleanBodyParameters, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) !!}
11+
@endif
12+
@if(!empty($endpoint->headers))
13+
headers = {
14+
@foreach($endpoint->headers as $header => $value)
15+
"{{$header}}": "{{$value}}",
16+
@endforeach
17+
}
18+
@endif
19+
20+
response = RestClient.{{strtolower($endpoint->httpMethods[0])}}(
21+
'{{ $baseUrl }}/{{ $endpoint->boundUri }}'@if(!empty($endpoint->cleanBodyParameters)),
22+
body @endif
23+
@if(!empty($endpoint->headers)),
24+
headers
25+
@endif
26+
)
27+
28+
p response.body
29+
30+
```

0 commit comments

Comments
 (0)