Class: Akeneo::AttributeService

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

Constant Summary

Constants inherited from ServiceBase

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

Constants included from Cache

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/attribute_service.rb', line 7

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

    loop do
      response = get_request(request_url)
      extract_collection_items(response).each { |attribute| attributes << attribute }
      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/attribute_service.rb', line 20

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

  response.parsed_response if response.success?
end

#option(code, option_code) ⇒ Object



32
33
34
35
36
# File 'lib/akeneo/attribute_service.rb', line 32

def option(code, option_code)
  response = get_request("/attributes/#{code}/options/#{option_code}")

  response.parsed_response if response.success?
end

#options(attribute_code) ⇒ Object



26
27
28
29
30
# File 'lib/akeneo/attribute_service.rb', line 26

def options(attribute_code)
  response = get_request("/attributes/#{attribute_code}/options")

  response.parsed_response if response.success?
end