Module: Teems::Services::WriteRequests
- Included in:
- ApiClient
- Defined in:
- lib/teems/services/api_client.rb
Overview
POST/PATCH request methods, extracted to manage class size
Instance Method Summary collapse
Instance Method Details
#patch(endpoint_key, path, **options) ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/teems/services/api_client.rb', line 59 def patch(endpoint_key, path, **) account = .delete(:account) body = .delete(:body) req = Net::HTTP::Patch.new(URI("#{resolve_endpoint(endpoint_key)}#{path}")) apply_auth(req, account, endpoint_key) req.body = JSON.generate(body) if body run_request(path, get_http_for_endpoint(endpoint_key)) { |http| http.request(req) } end |
#post(endpoint_key, path, **options) ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/teems/services/api_client.rb', line 50 def post(endpoint_key, path, **) account = .delete(:account) body = .delete(:body) req = Net::HTTP::Post.new(URI("#{resolve_endpoint(endpoint_key)}#{path}")) apply_auth(req, account, endpoint_key) req.body = JSON.generate(body) if body run_request(path, get_http_for_endpoint(endpoint_key)) { |http| http.request(req) } end |