akeneo 1.6.1 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +23 -0
- data/akeneo.gemspec +2 -2
- data/lib/akeneo/attribute_service.rb +19 -0
- data/lib/akeneo/category_service.rb +13 -0
- data/lib/akeneo/family_service.rb +13 -0
- data/lib/akeneo/product_service.rb +4 -0
- data/lib/akeneo/service_base.rb +15 -0
- metadata +6 -6
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 8cc4f6ecb550de1781121fd9fc162e6f0404d1fe0f02c150a96d834f10711beb
         | 
| 4 | 
            +
              data.tar.gz: 055dc4d5548ec75f62bf7f806ac4ab35229fa421646c0d92afb180f9ac1bb76e
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: '08f8ee88b7104485fdbeaa7451079d430cb54eefcb1feda70045eadc4e2371bb63045bac9f0e886e4bb067e13c362336fbfab52a67868d62360a9685eb594eec'
         | 
| 7 | 
            +
              data.tar.gz: 9d63a9a995ab7ec03e0f117e89a60c647f1a620365c74426908b30824e06bb8f11fd08f7263e1eb95dbed7801e88fed25e5184984b471e2874ebc4bcac24212e
         | 
    
        data/Gemfile.lock
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | @@ -19,6 +19,29 @@ client = Akeneo::API.new( | |
| 19 19 |  | 
| 20 20 | 
             
            client.product(511707)
         | 
| 21 21 | 
             
            # => {"identifier"=>"511707", "family"=>"simple_product", "parent"=>nil, "groups"=>[]...
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            Some methods with parameters is inside services classes, and be called that way
         | 
| 24 | 
            +
            client.family_service.all
         | 
| 25 | 
            +
            # => Returns a Enumeration to list all families
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            client.product_service.create(object)
         | 
| 28 | 
            +
            # => Returns a JSON with status code relative to what happened
         | 
| 29 | 
            +
            201: CREATED
         | 
| 30 | 
            +
            "{"line":1,"identifier":"bot","status_code":201}"
         | 
| 31 | 
            +
             | 
| 32 | 
            +
            204: NO CONTENT/UPDATED
         | 
| 33 | 
            +
            "{"line":1,"identifier":"top","status_code":204}"
         | 
| 34 | 
            +
             | 
| 35 | 
            +
            422: UNPROCESSABLE ENTITY/ERROR
         | 
| 36 | 
            +
            In this case, returns message too
         | 
| 37 | 
            +
            "{"line":1,"identifier":"bot","status_code":422,"message":"Validation failed.","errors":[{"property":"values","message":"The value Top 2 vezes is already set on another product for the unique attribute nome_marketing","attribute":"nome_marketing","locale":null,"scope":null}]}"
         | 
| 38 | 
            +
            ```
         | 
| 39 | 
            +
             | 
| 40 | 
            +
            Returns options from attribute
         | 
| 41 | 
            +
            ```
         | 
| 42 | 
            +
            options = client.attribute_service.options(codigo_do_atributo)
         | 
| 43 | 
            +
             | 
| 44 | 
            +
            options["_embedded"]["items"].map{|a| [a['code'], a['labels']]}
         | 
| 22 45 | 
             
            ```
         | 
| 23 46 |  | 
| 24 47 | 
             
            ## Configuration
         | 
    
        data/akeneo.gemspec
    CHANGED
    
    | @@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) | |
| 5 5 |  | 
| 6 6 | 
             
            Gem::Specification.new do |spec|
         | 
| 7 7 | 
             
              spec.name          = 'akeneo'
         | 
| 8 | 
            -
              spec.version       = '1. | 
| 8 | 
            +
              spec.version       = '1.7.0'
         | 
| 9 9 | 
             
              spec.authors       = ['AWN Dev Team']
         | 
| 10 10 | 
             
              spec.email         = ['edv@awn.de']
         | 
| 11 11 |  | 
| @@ -32,7 +32,7 @@ Gem::Specification.new do |spec| | |
| 32 32 | 
             
              spec.add_development_dependency 'rspec'
         | 
| 33 33 | 
             
              spec.add_development_dependency 'rubocop'
         | 
| 34 34 | 
             
              spec.add_development_dependency 'webmock'
         | 
| 35 | 
            -
              spec.add_dependency 'httparty'
         | 
| 35 | 
            +
              spec.add_dependency 'httparty', '~> 0.17.0'
         | 
| 36 36 | 
             
              spec.add_dependency 'mime-types'
         | 
| 37 37 | 
             
              spec.add_dependency 'redis'
         | 
| 38 38 | 
             
              spec.add_dependency 'semantic_logger'
         | 
| @@ -4,12 +4,31 @@ require_relative './service_base.rb' | |
| 4 4 |  | 
| 5 5 | 
             
            module Akeneo
         | 
| 6 6 | 
             
              class AttributeService < ServiceBase
         | 
| 7 | 
            +
                def all
         | 
| 8 | 
            +
                  Enumerator.new do |attributes|
         | 
| 9 | 
            +
                    request_url = "/attributes?#{limit_param}"
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                    loop do
         | 
| 12 | 
            +
                      response = get_request(request_url)
         | 
| 13 | 
            +
                      extract_collection_items(response).each { |attribute| attributes << attribute }
         | 
| 14 | 
            +
                      request_url = extract_next_page_path(response)
         | 
| 15 | 
            +
                      break unless request_url
         | 
| 16 | 
            +
                    end
         | 
| 17 | 
            +
                  end
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
             | 
| 7 20 | 
             
                def find(code)
         | 
| 8 21 | 
             
                  response = get_request("/attributes/#{code}")
         | 
| 9 22 |  | 
| 10 23 | 
             
                  response.parsed_response if response.success?
         | 
| 11 24 | 
             
                end
         | 
| 12 25 |  | 
| 26 | 
            +
                def options(attribute_code)
         | 
| 27 | 
            +
                  response = get_request("/attributes/#{attribute_code}/options")
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                  response.parsed_response if response.success?
         | 
| 30 | 
            +
                end
         | 
| 31 | 
            +
             | 
| 13 32 | 
             
                def option(code, option_code)
         | 
| 14 33 | 
             
                  response = get_request("/attributes/#{code}/options/#{option_code}")
         | 
| 15 34 |  | 
| @@ -4,6 +4,19 @@ require_relative './service_base.rb' | |
| 4 4 |  | 
| 5 5 | 
             
            module Akeneo
         | 
| 6 6 | 
             
              class CategoryService < ServiceBase
         | 
| 7 | 
            +
                def all
         | 
| 8 | 
            +
                  Enumerator.new do |categories|
         | 
| 9 | 
            +
                    request_url = "/categories?#{limit_param}"
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                    loop do
         | 
| 12 | 
            +
                      response = get_request(request_url)
         | 
| 13 | 
            +
                      extract_collection_items(response).each { |category| categories << category }
         | 
| 14 | 
            +
                      request_url = extract_next_page_path(response)
         | 
| 15 | 
            +
                      break unless request_url
         | 
| 16 | 
            +
                    end
         | 
| 17 | 
            +
                  end
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
             | 
| 7 20 | 
             
                def find(code)
         | 
| 8 21 | 
             
                  response = get_request("/categories/#{code}")
         | 
| 9 22 |  | 
| @@ -4,6 +4,19 @@ require_relative './service_base.rb' | |
| 4 4 |  | 
| 5 5 | 
             
            module Akeneo
         | 
| 6 6 | 
             
              class FamilyService < ServiceBase
         | 
| 7 | 
            +
                def all
         | 
| 8 | 
            +
                  Enumerator.new do |families|
         | 
| 9 | 
            +
                    request_url = "/families?#{limit_param}"
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                    loop do
         | 
| 12 | 
            +
                      response = get_request(request_url)
         | 
| 13 | 
            +
                      extract_collection_items(response).each { |family| families << family }
         | 
| 14 | 
            +
                      request_url = extract_next_page_path(response)
         | 
| 15 | 
            +
                      break unless request_url
         | 
| 16 | 
            +
                    end
         | 
| 17 | 
            +
                  end
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
             | 
| 7 20 | 
             
                def find(code)
         | 
| 8 21 | 
             
                  response = get_request("/families/#{code}")
         | 
| 9 22 |  | 
| @@ -44,6 +44,10 @@ module Akeneo | |
| 44 44 | 
             
                  patch_request("/products/#{code}", body: options.to_json)
         | 
| 45 45 | 
             
                end
         | 
| 46 46 |  | 
| 47 | 
            +
                def create_several(product_objects)
         | 
| 48 | 
            +
                  patch_for_collection_request('/products', body: product_objects.to_json)
         | 
| 49 | 
            +
                end
         | 
| 50 | 
            +
             | 
| 47 51 | 
             
                private
         | 
| 48 52 |  | 
| 49 53 | 
             
                def build_path(family, completeness, updated_after)
         | 
    
        data/lib/akeneo/service_base.rb
    CHANGED
    
    | @@ -37,6 +37,10 @@ module Akeneo | |
| 37 37 | 
             
                  { 'Content-Type' => 'application/json' }
         | 
| 38 38 | 
             
                end
         | 
| 39 39 |  | 
| 40 | 
            +
                def akeneo_collection_headers
         | 
| 41 | 
            +
                  { 'Content-Type' => 'application/vnd.akeneo.collection+json' }
         | 
| 42 | 
            +
                end
         | 
| 43 | 
            +
             | 
| 40 44 | 
             
                def authorization_headers
         | 
| 41 45 | 
             
                  { 'Authorization' => "Bearer #{@access_token}" }
         | 
| 42 46 | 
             
                end
         | 
| @@ -45,6 +49,10 @@ module Akeneo | |
| 45 49 | 
             
                  authorization_headers.merge(json_headers)
         | 
| 46 50 | 
             
                end
         | 
| 47 51 |  | 
| 52 | 
            +
                def collection_request_headers
         | 
| 53 | 
            +
                  authorization_headers.merge(akeneo_collection_headers)
         | 
| 54 | 
            +
                end
         | 
| 55 | 
            +
             | 
| 48 56 | 
             
                def get_request(path, options = {})
         | 
| 49 57 | 
             
                  HTTParty.get(
         | 
| 50 58 | 
             
                    "#{@url}/api/rest/v1#{path}",
         | 
| @@ -59,6 +67,13 @@ module Akeneo | |
| 59 67 | 
             
                  )
         | 
| 60 68 | 
             
                end
         | 
| 61 69 |  | 
| 70 | 
            +
                def patch_for_collection_request(path, options = {})
         | 
| 71 | 
            +
                  HTTParty.patch(
         | 
| 72 | 
            +
                    "#{@url}/api/rest/v1#{path}",
         | 
| 73 | 
            +
                    options.merge(headers: collection_request_headers)
         | 
| 74 | 
            +
                  )
         | 
| 75 | 
            +
                end
         | 
| 76 | 
            +
             | 
| 62 77 | 
             
                def pagination_param
         | 
| 63 78 | 
             
                  "pagination_type=#{DEFAULT_PAGINATION_TYPE}"
         | 
| 64 79 | 
             
                end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: akeneo
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1. | 
| 4 | 
            +
              version: 1.7.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - AWN Dev Team
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2019-05- | 
| 11 | 
            +
            date: 2019-05-28 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rake
         | 
| @@ -70,16 +70,16 @@ dependencies: | |
| 70 70 | 
             
              name: httparty
         | 
| 71 71 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 72 72 | 
             
                requirements:
         | 
| 73 | 
            -
                - - " | 
| 73 | 
            +
                - - "~>"
         | 
| 74 74 | 
             
                  - !ruby/object:Gem::Version
         | 
| 75 | 
            -
                    version:  | 
| 75 | 
            +
                    version: 0.17.0
         | 
| 76 76 | 
             
              type: :runtime
         | 
| 77 77 | 
             
              prerelease: false
         | 
| 78 78 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 79 79 | 
             
                requirements:
         | 
| 80 | 
            -
                - - " | 
| 80 | 
            +
                - - "~>"
         | 
| 81 81 | 
             
                  - !ruby/object:Gem::Version
         | 
| 82 | 
            -
                    version:  | 
| 82 | 
            +
                    version: 0.17.0
         | 
| 83 83 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 84 84 | 
             
              name: mime-types
         | 
| 85 85 | 
             
              requirement: !ruby/object:Gem::Requirement
         |