Skip to content

Commit 59fe9e9

Browse files
gussicilianoalebian
authored andcommitted
Add doc for post with token (#34)
* Updated README: added example for post with token
1 parent 09649ea commit 59fe9e9

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,37 @@ puts GithubService.new.repositories('alebian')
6262

6363
Or, 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

6798
1. Fork it

0 commit comments

Comments
 (0)