Class: Core::Models::Decorators::Gateway

Inherits:
Draper::Decorator
  • Object
show all
Defined in:
lib/core/models/decorators/gateway.rb

Overview

Decorator for a service, providing methods to make requests on it.

Author:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(action, _object) ⇒ Gateway

Returns a new instance of Gateway.



15
16
17
18
19
# File 'lib/core/models/decorators/gateway.rb', line 15

def initialize(action, _object)
  super(_object)
  @logger = Logger.new(STDOUT)
  @action = action
end

Instance Attribute Details

#action ⇒ String

Returns the action of the route using this API.

Returns:

  • (String) —

    the action of the route using this API.



11
12
13
# File 'lib/core/models/decorators/gateway.rb', line 11

def action
  @action
end

#logger ⇒ Object

Returns the value of attribute logger.



13
14
15
# File 'lib/core/models/decorators/gateway.rb', line 13

def logger
  @logger
end

Instance Method Details

#delete(session:, url:, params:) ⇒ Object

Shortcut to make a DELETE request on the API.

Parameters:

  • session (Core::Models::Authentication::Session) —

    the session of the user requesting the API.

  • url (String) —

    the URL you want to reach on the service.

  • params (Hash) —

    the additional parameters to pass in the JSON body.



25
26
27
# File 'lib/core/models/decorators/gateway.rb', line 25

def delete(session:, url:, params:)
  return make_request_without_body(verb: 'delete', session: session, url: url, params: params)
end

#get(session:, url:, params:) ⇒ Object

Shortcut to make a GET request on the API.

Parameters:

  • session (Core::Models::Authentication::Session) —

    the session of the user requesting the API.

  • url (String) —

    the URL you want to reach on the service.

  • params (Hash) —

    the additional parameters to pass in the JSON body.



33
34
35
# File 'lib/core/models/decorators/gateway.rb', line 33

def get(session:, url:, params:)
  return make_request_without_body(verb: 'get', session: session, url: url, params: params)
end

#post(session:, url:, params:) ⇒ Object

Shortcut to make a POST request on the API.

Parameters:

  • session (Core::Models::Authentication::Session) —

    the session of the user requesting the API.

  • url (String) —

    the URL you want to reach on the service.

  • params (Hash) —

    the additional parameters to pass in the JSON body.



41
42
43
# File 'lib/core/models/decorators/gateway.rb', line 41

def post(session:, url:, params:)
  return make_request(verb: 'post', session: session, url: url, params: params)
end

#put(session:, url:, params:) ⇒ Object

Shortcut to make a PUT request on the API.

Parameters:

  • session (Core::Models::Authentication::Session) —

    the session of the user requesting the API.

  • url (String) —

    the URL you want to reach on the service.

  • params (Hash) —

    the additional parameters to pass in the JSON body.



49
50
51
# File 'lib/core/models/decorators/gateway.rb', line 49

def put(session:, url:, params:)
  return make_request(verb: 'put', session: session, url: url, params: params)
end