Class: Transfeera::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/transfeera/request.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(application) ⇒ Request



5
6
7
8
# File 'lib/transfeera/request.rb', line 5

def initialize(application)
  @application = application
  @environment = Transfeera.configuration.environment
end

Class Method Details

.instanceObject



10
11
12
# File 'lib/transfeera/request.rb', line 10

def self.instance
  new(:default)
end

Instance Method Details

#delete(uri) ⇒ Object



44
45
46
47
48
49
50
51
# File 'lib/transfeera/request.rb', line 44

def delete(uri)
  response = connection.delete do |req|
    req.path = url(uri)
    req.headers = default_headers
  end

  Transfeera::Response.new(response)
end

#get(uri, headers: {}, params: {}) ⇒ Object



34
35
36
37
38
39
40
41
42
# File 'lib/transfeera/request.rb', line 34

def get(uri, headers: {}, params: {})
  response = connection.get do |req|
    req.path = url(uri)
    req.params = params
    req.headers = headers.merge(default_headers)
  end

  Transfeera::Response.new(response)
end

#post(uri, body: {}, headers: {}) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/transfeera/request.rb', line 14

def post(uri, body: {}, headers: {})
  response = connection.post do |req|
    req.path = url(uri)
    req.body = body.to_json unless body.empty?
    req.headers = headers.merge(default_headers)
  end

  Transfeera::Response.new(response)
end

#put(uri, body: {}) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/transfeera/request.rb', line 24

def put(uri, body: {})
  response = connection.put do |req|
    req.path = url(uri)
    req.headers = default_headers
    req.body = body.to_json unless body.empty?
  end

  Transfeera::Response.new(response)
end