Class: Akeneo::PublishedProductService

Inherits:
ServiceBase show all
Defined in:
lib/akeneo/published_product_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 included from Cache

disabled=, #get_request, prepended

Constructor Details

#initialize(url:, access_token:) ⇒ PublishedProductService

Returns a new instance of PublishedProductService.



7
8
9
10
# File 'lib/akeneo/published_product_service.rb', line 7

def initialize(url:, access_token:)
  @url = url
  @access_token = access_token
end

Instance Method Details

#published_products(updated_after: nil) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/akeneo/published_product_service.rb', line 12

def published_products(updated_after: nil)
  Enumerator.new do |products|
    path = "/published-products?#{pagination_param}"
    path += search_params(updated_after: updated_after)

    loop do
      response = get_request(path)
      extract_products(response).each { |product| products << product }
      path = extract_next_page_path(response)
      break unless path
    end
  end.lazy
end