Module: GoPay

Defined in:
lib/gopay.rb,
lib/gopay/error.rb,
lib/gopay/payment.rb,
lib/gopay/version.rb

Defined Under Namespace

Classes: Error, Payment, Version

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.client_idObject

Returns the value of attribute client_id.



5
6
7
# File 'lib/gopay.rb', line 5

def client_id
  @client_id
end

.client_secretObject

Returns the value of attribute client_secret.



5
6
7
# File 'lib/gopay.rb', line 5

def client_secret
  @client_secret
end

.gateObject

Returns the value of attribute gate.



5
6
7
# File 'lib/gopay.rb', line 5

def gate
  @gate
end

.goidObject

Returns the value of attribute goid.



5
6
7
# File 'lib/gopay.rb', line 5

def goid
  @goid
end

.notification_hostObject

Returns the value of attribute notification_host.



5
6
7
# File 'lib/gopay.rb', line 5

def notification_host
  @notification_host
end

.return_hostObject

Returns the value of attribute return_host.



5
6
7
# File 'lib/gopay.rb', line 5

def return_host
  @return_host
end

Class Method Details

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (GoPay)

    the object that the method was called on



8
9
10
# File 'lib/gopay.rb', line 8

def self.configure
  yield self
end

.request(method, path, body_parameters: {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/gopay.rb', line 12

def self.request(method, path, body_parameters: {})
  token = token get_token_scope(method, path)
  content_type = get_content_type(path)

  body_parameters = content_type == 'application/json' ? body_parameters.to_json : from_hash_to_query(body_parameters)

  response = Unirest.send(method, GoPay.gate+path, headers: { "Accept" => "application/json", "Content-Type" => content_type, "Authorization" => "Bearer #{token}" }, parameters: body_parameters)

  unless response.code == 200
    raise GoPay::Error.handle_gopay_error(response)
  end

  response.body
end