Class: Adyen::Service

Inherits:
Object
  • Object
show all
Defined in:
lib/adyen/services/service.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, version, service, method_names, with_application_info = []) ⇒ Service

Returns a new instance of Service.



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/adyen/services/service.rb', line 14

def initialize(client, version, service, method_names, with_application_info = [])
  @client = client
  @version = version
  @service = service

  # dynamically create API methods
  method_names.each do |method_name|
    define_singleton_method method_name do |request, headers = {}|
      action = self.class.action_for_method_name(method_name)
      @client.call_adyen_api(@service, action, request, headers, @version, with_application_info.include?(method_name))
    end
  end
end

Instance Attribute Details

#serviceObject

Returns the value of attribute service.



3
4
5
# File 'lib/adyen/services/service.rb', line 3

def service
  @service
end

#versionObject

Returns the value of attribute version.



3
4
5
# File 'lib/adyen/services/service.rb', line 3

def version
  @version
end

Class Method Details

.action_for_method_name(method_name) ⇒ Object

add snake case to camel case converter to String to convert rubinic method names to Adyen API methods

i.e. snake_case -> snakeCase note that the first letter is not capitalized as normal



10
11
12
# File 'lib/adyen/services/service.rb', line 10

def self.action_for_method_name(method_name)
  method_name.to_s.gsub(/_./) { |x| x[1].upcase }
end