Class: ActiveJobject::Request::Engine::OAuth2

Inherits:
Base
  • Object
show all
Defined in:
lib/active_jobject/request/engine/oauth2.rb

Class Method Summary collapse

Methods inherited from Base

after_request, before_request, error_class

Class Method Details

.delete(site:, headers: {}, params: {}) ⇒ OAuth2::Response

Make a HTTP DELETE request.

Returns:

  • (OAuth2::Response)

    the response from the request

Raises:

See Also:

  • OAuth2::Client#request


78
79
80
81
82
83
84
# File 'lib/active_jobject/request/engine/oauth2.rb', line 78

def delete(site:, headers: {}, params: {})
  host, path = deconstruct_uri(site)

  authorization_strategy.call(site: host).delete(path, params:, headers:)
rescue ::OAuth2::Error => e
  raise handle_error(e, caller)
end

.get(site:, headers: {}, params: {}) ⇒ OAuth2::Response

Make a HTTP GET request.

Returns:

  • (OAuth2::Response)

    the response from the request

Raises:

See Also:

  • OAuth2::Client#request


18
19
20
21
22
23
24
# File 'lib/active_jobject/request/engine/oauth2.rb', line 18

def get(site:, headers: {}, params: {})
  host, path = deconstruct_uri(site)

  authorization_strategy.call(site: host).get(path, params:, headers:)
rescue ::OAuth2::Error => e
  raise handle_error(e, caller)
end

.patch(site:, headers: {}, params: {}, body: nil) ⇒ OAuth2::Response

Make a HTTP PATCH request.

Returns:

  • (OAuth2::Response)

    the response from the request

Raises:

See Also:

  • OAuth2::Client#request


63
64
65
66
67
68
69
# File 'lib/active_jobject/request/engine/oauth2.rb', line 63

def patch(site:, headers: {}, params: {}, body: nil)
  host, path = deconstruct_uri(site)

  authorization_strategy.call(site: host).patch(path, params:, headers:, body:)
rescue ::OAuth2::Error => e
  raise handle_error(e, caller)
end

.post(site:, headers: {}, params: {}, body: nil) ⇒ OAuth2::Response

Make a HTTP POST request.

Returns:

  • (OAuth2::Response)

    the response from the request

Raises:

See Also:

  • OAuth2::Client#request


33
34
35
36
37
38
39
# File 'lib/active_jobject/request/engine/oauth2.rb', line 33

def post(site:, headers: {}, params: {}, body: nil)
  host, path = deconstruct_uri(site)

  authorization_strategy.call(site: host).post(path, params:, headers:, body:)
rescue ::OAuth2::Error => e
  raise handle_error(e, caller)
end

.put(site:, headers: {}, params: {}, body: nil) ⇒ OAuth2::Response

Make a HTTP PUT request.

Returns:

  • (OAuth2::Response)

    the response from the request

Raises:

See Also:

  • OAuth2::Client#request


48
49
50
51
52
53
54
# File 'lib/active_jobject/request/engine/oauth2.rb', line 48

def put(site:, headers: {}, params: {}, body: nil)
  host, path = deconstruct_uri(site)

  authorization_strategy.call(site: host).put(path, params:, headers:, body:)
rescue ::OAuth2::Error => e
  raise handle_error(e, caller)
end