Class: Fintecture::PisClient

Inherits:
Object
  • Object
show all
Defined in:
lib/fintecture/pis_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ PisClient

Returns a new instance of PisClient.



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/fintecture/pis_client.rb', line 18

def initialize(config)
  @app_id = config[:app_id]
  @app_secret = config[:app_secret]
  @private_key = config[:private_key]

  environment = config[:environment].downcase
  unless environment.include?(environment)
    raise "#{environment} not a valid environment, options are [#{environment.join(', ')}]"
  end

  @environment = config[:environment]
end

Instance Attribute Details

#app_idObject (readonly)

Getters



32
33
34
# File 'lib/fintecture/pis_client.rb', line 32

def app_id
  @app_id
end

#app_secretObject (readonly)

Getters



32
33
34
# File 'lib/fintecture/pis_client.rb', line 32

def app_secret
  @app_secret
end

#environmentObject (readonly)

Getters



32
33
34
# File 'lib/fintecture/pis_client.rb', line 32

def environment
  @environment
end

#private_keyObject (readonly)

Getters



32
33
34
# File 'lib/fintecture/pis_client.rb', line 32

def private_key
  @private_key
end

#tokenObject (readonly)

Getters



32
33
34
# File 'lib/fintecture/pis_client.rb', line 32

def token
  @token
end

#token_expires_inObject (readonly)

Getters



32
33
34
# File 'lib/fintecture/pis_client.rb', line 32

def token_expires_in
  @token_expires_in
end

Instance Method Details

#applicationsObject



88
89
90
91
92
# File 'lib/fintecture/pis_client.rb', line 88

def applications
  res = Fintecture::Ressources::Applications.get self

  JSON.parse res.body
end

#connect(payload, state, redirect_uri = nil, origin_uri = nil, with_virtualbeneficiary: false) ⇒ Object



45
46
47
48
49
# File 'lib/fintecture/pis_client.rb', line 45

def connect(payload, state, redirect_uri = nil, origin_uri = nil, with_virtualbeneficiary: false)
  res = Fintecture::Pis::Connect.generate self, Marshal.load(Marshal.dump(payload)), state, redirect_uri, origin_uri, with_virtualbeneficiary: with_virtualbeneficiary

  JSON.parse res.body
end

#generate_tokenObject

Methodes



35
36
37
38
39
40
41
42
43
# File 'lib/fintecture/pis_client.rb', line 35

def generate_token
  res = Fintecture::Authentication.get_access_token self
  body = JSON.parse res.body

  @token = body['access_token']
  @token_expires_in = body['expires_in']

  body
end

#initiate(payload, provider_id, redirect_uri, state = nil) ⇒ Object



57
58
59
60
61
62
# File 'lib/fintecture/pis_client.rb', line 57

def initiate(payload, provider_id, redirect_uri, state = nil)
  res = Fintecture::Pis::Initiate.generate self, Marshal.load(Marshal.dump(payload)), provider_id, redirect_uri,
                                           state

  JSON.parse res.body
end

#payments(session_id = nil, with_virtualbeneficiary: false) ⇒ Object



64
65
66
67
68
# File 'lib/fintecture/pis_client.rb', line 64

def payments(session_id = nil, with_virtualbeneficiary: false)
  res = Fintecture::Pis::Payments.get self, session_id, with_virtualbeneficiary: with_virtualbeneficiary

  JSON.parse res.body
end

#providers(provider_id: nil, paramsProviders: nil) ⇒ Object



82
83
84
85
86
# File 'lib/fintecture/pis_client.rb', line 82

def providers(provider_id: nil, paramsProviders: nil)
  res = Fintecture::Ressources::Providers.get self, provider_id, paramsProviders

  JSON.parse res.body
end

#refund(session_id, amount = nil, user_id = nil) ⇒ Object



70
71
72
73
74
# File 'lib/fintecture/pis_client.rb', line 70

def refund(session_id, amount = nil, user_id = nil)
  res = Fintecture::Pis::Refund.generate self, session_id, amount, user_id

  JSON.parse res.body
end

#request_to_pay(payload, x_language, redirect_uri = nil) ⇒ Object



51
52
53
54
55
# File 'lib/fintecture/pis_client.rb', line 51

def request_to_pay(payload, x_language, redirect_uri = nil)
  res = Fintecture::Pis::RequestToPay.generate self, Marshal.load(Marshal.dump(payload)), x_language, redirect_uri

  JSON.parse res.body
end

#settlements(settlement_id = nil, include_payments = false) ⇒ Object



76
77
78
79
80
# File 'lib/fintecture/pis_client.rb', line 76

def settlements(settlement_id = nil, include_payments = false)
  res = Fintecture::Pis::Settlements.get self, settlement_id, include_payments

  JSON.parse res.body
end

#test_accounts(provider_id = nil) ⇒ Object



94
95
96
97
98
# File 'lib/fintecture/pis_client.rb', line 94

def test_accounts(provider_id = nil)
  res = Fintecture::Ressources::TestAccounts.get self, provider_id

  JSON.parse res.body
end