Class: Akeneo::CategoryService

Inherits:
ServiceBase show all
Defined in:
lib/akeneo/category_service.rb

Constant Summary

Constants inherited from ServiceBase

ServiceBase::API_VERSION, ServiceBase::DEFAULT_PAGINATION_LIMIT, ServiceBase::DEFAULT_PAGINATION_TYPE

Constants included from Cache

Akeneo::Cache::DEFAULT_EXPIRES_IN

Instance Method Summary collapse

Methods inherited from ServiceBase

#initialize

Methods included from Cache

disabled=, #get_request, prepended

Constructor Details

This class inherits a constructor from Akeneo::ServiceBase

Instance Method Details

#allObject



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/akeneo/category_service.rb', line 7

def all
  Enumerator.new do |categories|
    request_url = "/categories?#{limit_param}"

    loop do
      response = get_request(request_url)
      extract_collection_items(response).each { |category| categories << category }
      request_url = extract_next_page_path(response)
      break unless request_url
    end
  end
end

#find(code) ⇒ Object



20
21
22
23
24
# File 'lib/akeneo/category_service.rb', line 20

def find(code)
  response = get_request("/categories/#{code}")

  response.parsed_response if response.success?
end