Class: YANAPI::API

Inherits:
Object
  • Object
show all
Defined in:
lib/yanapi/api.rb

Constant Summary collapse

REQUIRED_PARAMS =
[:method, :query_params]
ACCEPTED_METHODS =
['questionSearch',
'getByUser',
'getByCategory',
'getQuestion'
]

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ API

Returns a new instance of API.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/yanapi/api.rb', line 19

def initialize(params)

  @params = check_params(params)
  
  @query = case @params[:method]
           when 'questionSearch'
             TermQuery.new(@params)
           when 'getByCategory'
             CategoryQuery.new(@params)
           when 'getByUser'
             UserQuery.new(@params)
           when 'getQuestion'
             QuestionQuery.new(@params)
           end
end

Instance Method Details

#getObject

This is a connector to the specific method in the query.



36
37
38
# File 'lib/yanapi/api.rb', line 36

def get
  @query.get
end

#versionObject



40
41
42
# File 'lib/yanapi/api.rb', line 40

def version
  VERSION
end