Class: SpyriApi::Articles

Inherits:
Object
  • Object
show all
Defined in:
lib/spyri_api/articles.rb

Constant Summary collapse

BASEPATH =
'/articles'.freeze
SEARCHABLE_ATTRIBUTES =
[:sirius_id, :title].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client) ⇒ Articles

Returns a new instance of Articles.



11
12
13
# File 'lib/spyri_api/articles.rb', line 11

def initialize(api_client)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



9
10
11
# File 'lib/spyri_api/articles.rb', line 9

def api_client
  @api_client
end

Instance Method Details

#get(id) ⇒ Object



24
25
26
27
# File 'lib/spyri_api/articles.rb', line 24

def get(id)
  path = "#{BASEPATH}/#{id}"
  @api_client.call_api(:GET, path)
end

#search(opts = {}) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/spyri_api/articles.rb', line 15

def search(opts = {})
  query_params = {}
  SEARCHABLE_ATTRIBUTES.each do |key|
    query_params[key.to_s] = opts[key] if !opts[key].nil?
  end
  path = BASEPATH
  @api_client.call_api(:GET, path, query_params: query_params)
end