Sha256: 52324d65b58c67dd358767bf443f72695e8d01e6863b37df5f6f3dbb40f5b640

Contents?: true

Size: 672 Bytes

Versions: 3

Compression:

Stored size: 672 Bytes

Contents

module Direct::API::V5
  class Service
    def initialize(client:, service_name:)
      @client = client
      @service_name = service_name
    end

    # Direct API methods
    def method_missing(method, *args)
      params = args[0] || {}
      if params.is_a?(Hash)
        call_api_method(method, params)
      else
        super
      end
    end

    protected

    def call_api_method(method_name, params = {})
      request = Request.new(
        settings: @client.settings,
        service_name: @service_name,
        api_method: method_name,
        params: params
      )
      body, headers = request.send

      Response.new(body, headers)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
direct-api-v5-0.1.2 lib/direct/api/v5/service.rb
direct-api-v5-0.1.1 lib/direct/api/v5/service.rb
direct-api-v5-0.1.0 lib/direct/api/v5/service.rb