Class: Arkaan::Decorators::Gateway

Inherits:
Draper::Decorator
  • Object
show all
Defined in:
lib/arkaan/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.



14
15
16
17
18
# File 'lib/arkaan/decorators/gateway.rb', line 14

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

Instance Attribute Details

#actionString

Returns the action of the route using this API.

Returns:

  • (String)

    the action of the route using this API.



10
11
12
# File 'lib/arkaan/decorators/gateway.rb', line 10

def action
  @action
end

#loggerObject

Returns the value of attribute logger.



12
13
14
# File 'lib/arkaan/decorators/gateway.rb', line 12

def logger
  @logger
end

Instance Method Details

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

Shortcut to make a DELETE request on the API.

Parameters:

  • session (Arkaan::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.



24
25
26
# File 'lib/arkaan/decorators/gateway.rb', line 24

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 (Arkaan::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.



32
33
34
# File 'lib/arkaan/decorators/gateway.rb', line 32

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 (Arkaan::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.



40
41
42
# File 'lib/arkaan/decorators/gateway.rb', line 40

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 (Arkaan::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.



48
49
50
# File 'lib/arkaan/decorators/gateway.rb', line 48

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