Module: ActiveProject::Connections::Rest
- Includes:
- Base, Pagination
- Included in:
- Adapters::Basecamp::Connection, Adapters::Fizzy::Connection, Adapters::Jira::Connection, Adapters::Trello::Connection
- Defined in:
- lib/active_project/connections/rest.rb
Overview
Reusable REST connection logic for normal, boring APIs like Jira, Basecamp, and Trello. You know, ones that don’t require a decoder ring and a theological debate to use.
Constant Summary
Constants included from HttpClient
HttpClient::DEFAULT_HEADERS, HttpClient::DEFAULT_RETRY_OPTS
Instance Attribute Summary
Attributes included from HttpClient
Instance Method Summary collapse
-
#init_rest(base_url:, auth_middleware:, extra_headers: {}, retry_options: {}) {|conn| ... } ⇒ Object
Must be called from the concrete adapter’s initialize.
-
#request_rest(method, path, body = nil, query = nil, headers = {}) ⇒ Object
Wrapper around HttpClient#request.
Methods included from Pagination
Methods included from HttpClient
Methods included from Base
Instance Method Details
#init_rest(base_url:, auth_middleware:, extra_headers: {}, retry_options: {}) {|conn| ... } ⇒ Object
Must be called from the concrete adapter’s initialize.
Unlike GraphQL, this one doesn’t need you to bend the knee or cite the Book of Steve Job.
15 16 17 18 19 20 21 22 |
# File 'lib/active_project/connections/rest.rb', line 15 def init_rest(base_url:, auth_middleware:, extra_headers: {}, retry_options: {}) build_connection( base_url: base_url, auth_middleware: auth_middleware, extra_headers: extra_headers, retry_options: ) end |
#request_rest(method, path, body = nil, query = nil, headers = {}) ⇒ Object
Wrapper around HttpClient#request. Adapters may override this if their APIs have… quirks (read: sins).
26 27 28 29 30 |
# File 'lib/active_project/connections/rest.rb', line 26 def request_rest(method, path, body = nil, query = nil, headers = {}) request(method, path, body: body, query: query, headers: headers) rescue Faraday::Error => e raise map_faraday_error(e) # Wrap Faraday errors in our custom trauma response. end |