Sha256: da8ce67bb77d64e89fa2bdcf1f693bd4c5fba65b2738a814ca83cec4500e8fb5

Contents?: true

Size: 938 Bytes

Versions: 6

Compression:

Stored size: 938 Bytes

Contents

module Adyen
  class Service
    attr_accessor :service, :version

    # 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
    def self.action_for_method_name(method_name)
      method_name.to_s.gsub(/_./) { |x| x[1].upcase }
    end

    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
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
adyen-ruby-api-library-6.2.0 lib/adyen/services/service.rb
adyen-ruby-api-library-6.1.0 lib/adyen/services/service.rb
adyen-ruby-api-library-6.0.0 lib/adyen/services/service.rb
adyen-ruby-api-library-5.1.0 lib/adyen/services/service.rb
adyen-ruby-api-library-5.0.0 lib/adyen/services/service.rb
adyen-ruby-api-library-4.4.0 lib/adyen/services/service.rb