Class: BridgeBankin::API::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/bridge_bankin/api/client.rb

Overview

Allows to request the Bridge API using Ruby native net/http library

Constant Summary collapse

HTTP_VERBS_MAP =
{
  get: Net::HTTP::Get,
  post: Net::HTTP::Post,
  put: Net::HTTP::Put,
  delete: Net::HTTP::Delete
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



22
23
24
# File 'lib/bridge_bankin/api/client.rb', line 22

def access_token
  @access_token
end

Instance Method Details

#delete(path, **params) ⇒ Hash

Handles a DELETE request

Parameters:

  • path (String)

    the API endpoint PATH to query

  • params (Hash)

    any params that might be required (or optional) to communicate with the API

Returns:

  • (Hash)

    the parsed API response

Raises:

  • (API::Error)

    expectation if API responding with any error



74
75
76
# File 'lib/bridge_bankin/api/client.rb', line 74

def delete(path, **params)
  request :delete, path, params
end

#get(path, **params) ⇒ Hash

Handles a GET request

Parameters:

  • path (String)

    the API endpoint PATH to query

  • params (Hash)

    any params that might be required (or optional) to communicate with the API

Returns:

  • (Hash)

    the parsed API response

Raises:

  • (API::Error)

    expectation if API responding with any error



34
35
36
# File 'lib/bridge_bankin/api/client.rb', line 34

def get(path, **params)
  request :get, path, params
end

#post(path, **params) ⇒ Hash

Handles a POST request

Parameters:

  • path (String)

    the API endpoint PATH to query

  • params (Hash)

    any params that might be required (or optional) to communicate with the API

Returns:

  • (Hash)

    the parsed API response

Raises:

  • (API::Error)

    expectation if API responding with any error



48
49
50
# File 'lib/bridge_bankin/api/client.rb', line 48

def post(path, **params)
  request :post, path, params
end

#put(path, **params) ⇒ Hash

Handles a PUT request

Parameters:

  • path (String)

    the API endpoint PATH to query

  • params (Hash)

    any params that might be required (or optional) to communicate with the API

Returns:

  • (Hash)

    the parsed API response

Raises:

  • (API::Error)

    expectation if API responding with any error



61
62
63
# File 'lib/bridge_bankin/api/client.rb', line 61

def put(path, **params)
  request :put, path, params
end