Class: PayU::Client

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/pay_u/client.rb

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.



6
7
8
9
10
11
12
13
# File 'lib/pay_u/client.rb', line 6

def initialize
  @client ||= Faraday.new(url: PayU.configuration.api_url) do |connection|
    connection.request :url_encoded
    connection.response :logger if PayU.configuration.test?
    connection.adapter Faraday.default_adapter
    connection.basic_auth "pRRXKOl8ikMmt9u", "4Vj8eK4rloUd272L48hsrarnUA"
  end
end

Instance Method Details

#delete(url) ⇒ Object



37
38
39
40
41
# File 'lib/pay_u/client.rb', line 37

def delete(url)
  response = @client.delete(&perform_request(url))

  response.success?
end

#get(url) ⇒ Object



16
17
18
19
20
# File 'lib/pay_u/client.rb', line 16

def get(url)
  response = @client.get(&perform_request(url))

  process_response(response)
end

#post(url, params: {}) ⇒ Object



23
24
25
26
27
# File 'lib/pay_u/client.rb', line 23

def post(url, params: {})
  response = @client.post(&perform_request_with_params(url, params))

  process_response(response)
end

#put(url, params: {}) ⇒ Object



30
31
32
33
34
# File 'lib/pay_u/client.rb', line 30

def put(url, params: {})
  response = @client.put(&perform_request_with_params(url, params))

  process_response(response)
end