Class: Ibanity::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(certificate:, key:, key_passphrase:, api_scheme: "https", api_host: "api.ibanity.com", api_port: "443", ssl_ca_file: nil) ⇒ Client

Returns a new instance of Client.



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

def initialize(certificate:, key:, key_passphrase:, api_scheme: "https", api_host: "api.ibanity.com", api_port: "443", ssl_ca_file: nil)
  @certificate = OpenSSL::X509::Certificate.new(certificate)
  @key         = OpenSSL::PKey::RSA.new(key, key_passphrase)
  @base_uri    = "#{api_scheme}://#{api_host}:#{api_port}"
  @ssl_ca_file = ssl_ca_file
end

Instance Attribute Details

#base_uriObject (readonly)

Returns the value of attribute base_uri.



4
5
6
# File 'lib/ibanity/client.rb', line 4

def base_uri
  @base_uri
end

Instance Method Details

#build_uri(path) ⇒ Object



29
30
31
# File 'lib/ibanity/client.rb', line 29

def build_uri(path)
  URI.join(@base_uri, path).to_s
end

#delete(uri, query_params = {}, customer_access_token = nil) ⇒ Object



25
26
27
# File 'lib/ibanity/client.rb', line 25

def delete(uri, query_params = {}, customer_access_token = nil)
  execute(:delete, uri, build_headers(customer_access_token), query_params)
end

#get(uri, query_params = {}, customer_access_token = nil) ⇒ Object



13
14
15
# File 'lib/ibanity/client.rb', line 13

def get(uri, query_params = {}, customer_access_token = nil)
  execute(:get, uri, build_headers(customer_access_token), query_params, nil)
end

#patch(uri, payload, query_params = {}, customer_access_token = nil) ⇒ Object



21
22
23
# File 'lib/ibanity/client.rb', line 21

def patch(uri, payload, query_params = {}, customer_access_token = nil)
  execute(:patch, uri, build_headers(customer_access_token), query_params, payload)
end

#post(uri, payload, query_params = {}, customer_access_token = nil) ⇒ Object



17
18
19
# File 'lib/ibanity/client.rb', line 17

def post(uri, payload, query_params = {}, customer_access_token = nil)
  execute(:post, uri, build_headers(customer_access_token), query_params, payload)
end