erp_integration 0.15.0 → 0.17.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/lib/erp_integration/channel_listing.rb +9 -0
 - data/lib/erp_integration/configuration.rb +9 -0
 - data/lib/erp_integration/fulfil/api_resource.rb +1 -1
 - data/lib/erp_integration/fulfil/or_clause.rb +19 -0
 - data/lib/erp_integration/fulfil/query.rb +2 -1
 - data/lib/erp_integration/fulfil/query_methods.rb +43 -1
 - data/lib/erp_integration/fulfil/resources/channel_listing.rb +13 -0
 - data/lib/erp_integration/version.rb +1 -1
 - data/lib/erp_integration.rb +1 -0
 - metadata +6 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 18ec55a600cfb88679e7c8ac4a8e397cd304312a5f85a7c2e54d63307d7c86ff
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 106c3c7f314668d09bb8589d1ea5243e4586a705871f891edf95efd0d9228028
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 9b8cd54866c82420eed9237a40d8d668494763ed7ef15ac588a15d73260e163eb416a1fb8bc316cd4e08624dddfc70a99e99b3056b046ed4ebb0601298ae0728
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 90e3145efef13b1d5f6307dd75a74811604cc2766f643970847d3570ff7dcba62fa11c252590b94d9f43f46df2b42352e1de754cf3a55a17f2472ce89a8fc980
         
     | 
| 
         @@ -0,0 +1,9 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module ErpIntegration
         
     | 
| 
      
 4 
     | 
    
         
            +
              # The `ErpIntegration::ChannelListing` exposes an uniformed API for interaction with
         
     | 
| 
      
 5 
     | 
    
         
            +
              # third-party ERP vendors.
         
     | 
| 
      
 6 
     | 
    
         
            +
              class ChannelListing < Resource
         
     | 
| 
      
 7 
     | 
    
         
            +
                attr_accessor :id, :channel, :product, :quantity
         
     | 
| 
      
 8 
     | 
    
         
            +
              end
         
     | 
| 
      
 9 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -37,6 +37,11 @@ module ErpIntegration 
     | 
|
| 
       37 
37 
     | 
    
         
             
                # @return [Symbol] The configured adapter for the bill_of_material.
         
     | 
| 
       38 
38 
     | 
    
         
             
                attr_writer :bill_of_material_output_adapter
         
     | 
| 
       39 
39 
     | 
    
         | 
| 
      
 40 
     | 
    
         
            +
                # Allows configuring an adapter for the `ChannelListing` resource. When
         
     | 
| 
      
 41 
     | 
    
         
            +
                # none is configured, it will default to Fulfil.
         
     | 
| 
      
 42 
     | 
    
         
            +
                # @return [Symbol] The configured adapter for the channel_listing.
         
     | 
| 
      
 43 
     | 
    
         
            +
                attr_writer :channel_listing_adapter
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
       40 
45 
     | 
    
         
             
                # Allows configuring an adapter for the `CustomerShipment` resource. When
         
     | 
| 
       41 
46 
     | 
    
         
             
                # none is configured, it will default to Fulfil.
         
     | 
| 
       42 
47 
     | 
    
         
             
                # @return [Symbol] The configured adapter for the customer shipment.
         
     | 
| 
         @@ -124,6 +129,10 @@ module ErpIntegration 
     | 
|
| 
       124 
129 
     | 
    
         
             
                  @bill_of_material_output_adapter || :fulfil
         
     | 
| 
       125 
130 
     | 
    
         
             
                end
         
     | 
| 
       126 
131 
     | 
    
         | 
| 
      
 132 
     | 
    
         
            +
                def channel_listing_adapter
         
     | 
| 
      
 133 
     | 
    
         
            +
                  @channel_listing_adapter || :fulfil
         
     | 
| 
      
 134 
     | 
    
         
            +
                end
         
     | 
| 
      
 135 
     | 
    
         
            +
             
     | 
| 
       127 
136 
     | 
    
         
             
                def customer_shipment_adapter
         
     | 
| 
       128 
137 
     | 
    
         
             
                  @customer_shipment_adapter || :fulfil
         
     | 
| 
       129 
138 
     | 
    
         
             
                end
         
     | 
| 
         @@ -0,0 +1,19 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module ErpIntegration
         
     | 
| 
      
 4 
     | 
    
         
            +
              module Fulfil
         
     | 
| 
      
 5 
     | 
    
         
            +
                class OrClause
         
     | 
| 
      
 6 
     | 
    
         
            +
                  LOGIC_OPERATOR = 'OR'
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                  def initialize(where_clauses:)
         
     | 
| 
      
 9 
     | 
    
         
            +
                    @where_clauses = where_clauses
         
     | 
| 
      
 10 
     | 
    
         
            +
                  end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                  def to_filter
         
     | 
| 
      
 13 
     | 
    
         
            +
                    return [] unless @where_clauses.any?
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                    @where_clauses.map(&:to_filter).unshift(LOGIC_OPERATOR)
         
     | 
| 
      
 16 
     | 
    
         
            +
                  end
         
     | 
| 
      
 17 
     | 
    
         
            +
                end
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -23,9 +23,10 @@ module ErpIntegration 
     | 
|
| 
       23 
23 
     | 
    
         | 
| 
       24 
24 
     | 
    
         
             
                  # @param fields [Array<String|Symbol>] A list of fields for Fulfil.
         
     | 
| 
       25 
25 
     | 
    
         
             
                  # @param filters [Array<WhereClause>] A list of where clauses for Fulfil.
         
     | 
| 
       26 
     | 
    
         
            -
                  def initialize(fields, filters)
         
     | 
| 
      
 26 
     | 
    
         
            +
                  def initialize(fields, filters, alternative_filters = [])
         
     | 
| 
       27 
27 
     | 
    
         
             
                    @fields = (fields || DEFAULT_FIELDS).map(&:to_s).uniq
         
     | 
| 
       28 
28 
     | 
    
         
             
                    @filters = (filters || []).map(&:to_filter).uniq
         
     | 
| 
      
 29 
     | 
    
         
            +
                    @filters += alternative_filters.map(&:to_filter).uniq if alternative_filters&.any?
         
     | 
| 
       29 
30 
     | 
    
         
             
                  end
         
     | 
| 
       30 
31 
     | 
    
         | 
| 
       31 
32 
     | 
    
         
             
                  def to_json(*_object)
         
     | 
| 
         @@ -2,11 +2,12 @@ 
     | 
|
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            require_relative 'query'
         
     | 
| 
       4 
4 
     | 
    
         
             
            require_relative 'where_clause'
         
     | 
| 
      
 5 
     | 
    
         
            +
            require_relative 'or_clause'
         
     | 
| 
       5 
6 
     | 
    
         | 
| 
       6 
7 
     | 
    
         
             
            module ErpIntegration
         
     | 
| 
       7 
8 
     | 
    
         
             
              module Fulfil
         
     | 
| 
       8 
9 
     | 
    
         
             
                module QueryMethods
         
     | 
| 
       9 
     | 
    
         
            -
                  attr_accessor :selected_fields, :where_clauses
         
     | 
| 
      
 10 
     | 
    
         
            +
                  attr_accessor :selected_fields, :where_clauses, :or_clauses
         
     | 
| 
       10 
11 
     | 
    
         | 
| 
       11 
12 
     | 
    
         
             
                  # The `QueryMethods#select` works in two unique ways
         
     | 
| 
       12 
13 
     | 
    
         
             
                  #
         
     | 
| 
         @@ -82,6 +83,47 @@ module ErpIntegration 
     | 
|
| 
       82 
83 
     | 
    
         
             
                    self
         
     | 
| 
       83 
84 
     | 
    
         
             
                  end
         
     | 
| 
       84 
85 
     | 
    
         | 
| 
      
 86 
     | 
    
         
            +
                  # The `or` method introduces an interface to query resources in Fulfil
         
     | 
| 
      
 87 
     | 
    
         
            +
                  # Is quite similar to the `where` method but with one big difference.
         
     | 
| 
      
 88 
     | 
    
         
            +
                  # The `or` method allows us to use the OR operator with several conditions
         
     | 
| 
      
 89 
     | 
    
         
            +
                  #
         
     | 
| 
      
 90 
     | 
    
         
            +
                  # @example
         
     | 
| 
      
 91 
     | 
    
         
            +
                  #   $ ErpIntegration::SalesOrder.or(id: 100, carrier: 12).all
         
     | 
| 
      
 92 
     | 
    
         
            +
                  #   # => <ErpIntegration::Fulfil::Collection @items=[
         
     | 
| 
      
 93 
     | 
    
         
            +
                  #          <ErpIntegration::SalesOrder:0x00007f8577cb6d40 @carrier=12, @id=3179663 />
         
     | 
| 
      
 94 
     | 
    
         
            +
                  #          <ErpIntegration::SalesOrder:0x00007f8577cb6d40 @carrier=16, @id=100 /> ] />
         
     | 
| 
      
 95 
     | 
    
         
            +
                  #
         
     | 
| 
      
 96 
     | 
    
         
            +
                  # @example
         
     | 
| 
      
 97 
     | 
    
         
            +
                  #   $ ErpIntegration::SalesOrder.or(id: [100, 200]).all
         
     | 
| 
      
 98 
     | 
    
         
            +
                  #   # => <ErpIntegration::Fulfil::Collection @items=[
         
     | 
| 
      
 99 
     | 
    
         
            +
                  #          <ErpIntegration::SalesOrder:0x00007f8577cb6d40 @id=100 />
         
     | 
| 
      
 100 
     | 
    
         
            +
                  #          <ErpIntegration::SalesOrder:0x00007f8577cb6d40 @id=200 /> ] />
         
     | 
| 
      
 101 
     | 
    
         
            +
                  #
         
     | 
| 
      
 102 
     | 
    
         
            +
                  #   Now we are just accepting the last 'or' method so if we have multiple
         
     | 
| 
      
 103 
     | 
    
         
            +
                  #   we are only accepting the last one.
         
     | 
| 
      
 104 
     | 
    
         
            +
                  def or(*args)
         
     | 
| 
      
 105 
     | 
    
         
            +
                    clone.or!(*args)
         
     | 
| 
      
 106 
     | 
    
         
            +
                  end
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
      
 108 
     | 
    
         
            +
                  def or!(args)
         
     | 
| 
      
 109 
     | 
    
         
            +
                    where_clauses = []
         
     | 
| 
      
 110 
     | 
    
         
            +
                    args.each_pair do |key, value_or_values|
         
     | 
| 
      
 111 
     | 
    
         
            +
                      [*value_or_values].each do |value|
         
     | 
| 
      
 112 
     | 
    
         
            +
                        where_clauses << WhereClause.new(
         
     | 
| 
      
 113 
     | 
    
         
            +
                          key: key, value: value
         
     | 
| 
      
 114 
     | 
    
         
            +
                        )
         
     | 
| 
      
 115 
     | 
    
         
            +
                      end
         
     | 
| 
      
 116 
     | 
    
         
            +
                    end
         
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
      
 118 
     | 
    
         
            +
                    self.or_clauses = [
         
     | 
| 
      
 119 
     | 
    
         
            +
                      OrClause.new(
         
     | 
| 
      
 120 
     | 
    
         
            +
                        where_clauses: where_clauses
         
     | 
| 
      
 121 
     | 
    
         
            +
                      )
         
     | 
| 
      
 122 
     | 
    
         
            +
                    ]
         
     | 
| 
      
 123 
     | 
    
         
            +
             
     | 
| 
      
 124 
     | 
    
         
            +
                    self
         
     | 
| 
      
 125 
     | 
    
         
            +
                  end
         
     | 
| 
      
 126 
     | 
    
         
            +
             
     | 
| 
       85 
127 
     | 
    
         
             
                  def where_ilike(args)
         
     | 
| 
       86 
128 
     | 
    
         
             
                    where(args.merge(comparison_operator: 'ilike'))
         
     | 
| 
       87 
129 
     | 
    
         
             
                  end
         
     | 
    
        data/lib/erp_integration.rb
    CHANGED
    
    | 
         @@ -23,6 +23,7 @@ module ErpIntegration 
     | 
|
| 
       23 
23 
     | 
    
         
             
              autoload :BillOfMaterial, 'erp_integration/bill_of_material'
         
     | 
| 
       24 
24 
     | 
    
         
             
              autoload :BillOfMaterialInput, 'erp_integration/bill_of_material_input'
         
     | 
| 
       25 
25 
     | 
    
         
             
              autoload :BillOfMaterialOutput, 'erp_integration/bill_of_material_output'
         
     | 
| 
      
 26 
     | 
    
         
            +
              autoload :ChannelListing, 'erp_integration/channel_listing'
         
     | 
| 
       26 
27 
     | 
    
         
             
              autoload :CustomerShipment, 'erp_integration/customer_shipment'
         
     | 
| 
       27 
28 
     | 
    
         
             
              autoload :CustomerShipmentReturn, 'erp_integration/customer_shipment_return'
         
     | 
| 
       28 
29 
     | 
    
         
             
              autoload :Product, 'erp_integration/product'
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: erp_integration
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.17.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Stefan Vermaas
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2023-01-12 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: activesupport
         
     | 
| 
         @@ -262,6 +262,7 @@ files: 
     | 
|
| 
       262 
262 
     | 
    
         
             
            - lib/erp_integration/bill_of_material.rb
         
     | 
| 
       263 
263 
     | 
    
         
             
            - lib/erp_integration/bill_of_material_input.rb
         
     | 
| 
       264 
264 
     | 
    
         
             
            - lib/erp_integration/bill_of_material_output.rb
         
     | 
| 
      
 265 
     | 
    
         
            +
            - lib/erp_integration/channel_listing.rb
         
     | 
| 
       265 
266 
     | 
    
         
             
            - lib/erp_integration/configuration.rb
         
     | 
| 
       266 
267 
     | 
    
         
             
            - lib/erp_integration/customer_shipment.rb
         
     | 
| 
       267 
268 
     | 
    
         
             
            - lib/erp_integration/customer_shipment_return.rb
         
     | 
| 
         @@ -270,12 +271,14 @@ files: 
     | 
|
| 
       270 
271 
     | 
    
         
             
            - lib/erp_integration/fulfil/client.rb
         
     | 
| 
       271 
272 
     | 
    
         
             
            - lib/erp_integration/fulfil/context.rb
         
     | 
| 
       272 
273 
     | 
    
         
             
            - lib/erp_integration/fulfil/finder_methods.rb
         
     | 
| 
      
 274 
     | 
    
         
            +
            - lib/erp_integration/fulfil/or_clause.rb
         
     | 
| 
       273 
275 
     | 
    
         
             
            - lib/erp_integration/fulfil/persistence.rb
         
     | 
| 
       274 
276 
     | 
    
         
             
            - lib/erp_integration/fulfil/query.rb
         
     | 
| 
       275 
277 
     | 
    
         
             
            - lib/erp_integration/fulfil/query_methods.rb
         
     | 
| 
       276 
278 
     | 
    
         
             
            - lib/erp_integration/fulfil/resources/bill_of_material.rb
         
     | 
| 
       277 
279 
     | 
    
         
             
            - lib/erp_integration/fulfil/resources/bill_of_material_input.rb
         
     | 
| 
       278 
280 
     | 
    
         
             
            - lib/erp_integration/fulfil/resources/bill_of_material_output.rb
         
     | 
| 
      
 281 
     | 
    
         
            +
            - lib/erp_integration/fulfil/resources/channel_listing.rb
         
     | 
| 
       279 
282 
     | 
    
         
             
            - lib/erp_integration/fulfil/resources/customer_shipment.rb
         
     | 
| 
       280 
283 
     | 
    
         
             
            - lib/erp_integration/fulfil/resources/customer_shipment_return.rb
         
     | 
| 
       281 
284 
     | 
    
         
             
            - lib/erp_integration/fulfil/resources/product.rb
         
     | 
| 
         @@ -332,7 +335,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       332 
335 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       333 
336 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       334 
337 
     | 
    
         
             
            requirements: []
         
     | 
| 
       335 
     | 
    
         
            -
            rubygems_version: 3. 
     | 
| 
      
 338 
     | 
    
         
            +
            rubygems_version: 3.3.7
         
     | 
| 
       336 
339 
     | 
    
         
             
            signing_key:
         
     | 
| 
       337 
340 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       338 
341 
     | 
    
         
             
            summary: Connects Mejuri with third-party ERP vendors
         
     |