File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,37 @@ puts GithubService.new.repositories('alebian')
6262
6363Or, even easier, run ` rails generate wor:requests:service NAME ` in your Rails root
6464
65+
66+ If you need to send body parameters in a post request you can write something like this:
67+
68+ ``` ruby
69+ require ' wor/requests'
70+
71+ class ExternalService < Wor ::Requests ::Base
72+ def post_request_example (authorization )
73+ post(
74+ attempting_to: ' Make a POST request to an external service.' ,
75+ path: ' /some_endpoint' ,
76+ headers: {
77+ Authorization: authorization,
78+ ' Content-type' => ' application/json'
79+ },
80+ body: {
81+ # Some Json
82+ }
83+ )
84+ end
85+
86+ protected
87+
88+ def base_url
89+ ' https://external.service.com'
90+ end
91+ end
92+
93+ ExternalService .new .post_request_example(token)
94+ ```
95+
6596## Contributing
6697
67981 . Fork it
You can’t perform that action at this time.
0 commit comments