Sha256: 3db7bb65eebb526902e2e7205f88424dd0a6746f12f236abbeeda888323f8b85

Contents?: true

Size: 664 Bytes

Versions: 5

Compression:

Stored size: 664 Bytes

Contents

module Ya::API::Direct
  class DirectServiceBase
    attr_reader :method_items, :version
    def initialize(client, methods_data)
      @client = client
      @method_items = methods_data
      init_methods
    end

    protected
    def init_methods
      @method_items.each do |method|
        self.class.send :define_method, method do |params = {}|
          result = exec_request(method, params || {})
          callback_by_result result
          result[:data]
        end
      end
    end

    def exec_request(method, request_body)
      client.gateway.request method, request_body, @version
    end

    def callback_by_result(result={})
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ya-api-direct-0.2.10 lib/ya/api/direct/direct_service_base.rb
ya-api-direct-0.2.6 lib/ya/api/direct/direct_service_base.rb
ya-api-direct-0.2.5 lib/ya/api/direct/direct_service_base.rb
ya-api-direct-0.2.4 lib/ya/api/direct/direct_service_base.rb
ya-api-direct-0.2.3 lib/ya/api/direct/direct_service_base.rb