cin7_api 1.0.3 → 1.0.4
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
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: def4242ec47be664686584c99a2375d3c349c3e30410caac8e42a0ae2ad24089
         | 
| 4 | 
            +
              data.tar.gz: f71f8db45c6efec4c24252c9a5ee25050bc79b9626f64787213d68c6625807ce
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 2e0bc2731ab0ec35e5d45efa3d748310b27833ccdaf76490a8272858608da8143db299119841d1a4b03e1ea36799e09e2a483aea15fd187857c76c77e5a15c47
         | 
| 7 | 
            +
              data.tar.gz: bb2e02999a87823610ffc55037a6c1ad06752bdd9df89be4c2d35046f956d1605f9e1856d1a8e2b917d13ef5105231f89d807fc9c9fff734543503e80ace8621
         | 
    
        data/Gemfile.lock
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            PATH
         | 
| 2 2 | 
             
              remote: .
         | 
| 3 3 | 
             
              specs:
         | 
| 4 | 
            -
                cin7_api (1.0. | 
| 4 | 
            +
                cin7_api (1.0.4)
         | 
| 5 5 | 
             
                  activesupport
         | 
| 6 6 | 
             
                  faraday (~> 2.5)
         | 
| 7 7 | 
             
                  zeitwerk
         | 
| @@ -19,10 +19,10 @@ GEM | |
| 19 19 | 
             
                concurrent-ruby (1.1.10)
         | 
| 20 20 | 
             
                diff-lcs (1.5.0)
         | 
| 21 21 | 
             
                dotenv (2.8.1)
         | 
| 22 | 
            -
                faraday (2. | 
| 22 | 
            +
                faraday (2.6.0)
         | 
| 23 23 | 
             
                  faraday-net_http (>= 2.0, < 3.1)
         | 
| 24 24 | 
             
                  ruby2_keywords (>= 0.0.4)
         | 
| 25 | 
            -
                faraday-net_http (3.0. | 
| 25 | 
            +
                faraday-net_http (3.0.1)
         | 
| 26 26 | 
             
                i18n (1.12.0)
         | 
| 27 27 | 
             
                  concurrent-ruby (~> 1.0)
         | 
| 28 28 | 
             
                json (2.6.2)
         | 
| @@ -69,7 +69,7 @@ GEM | |
| 69 69 | 
             
                  concurrent-ruby (~> 1.0)
         | 
| 70 70 | 
             
                unicode-display_width (2.3.0)
         | 
| 71 71 | 
             
                vcr (6.1.0)
         | 
| 72 | 
            -
                zeitwerk (2.6. | 
| 72 | 
            +
                zeitwerk (2.6.1)
         | 
| 73 73 |  | 
| 74 74 | 
             
            PLATFORMS
         | 
| 75 75 | 
             
              x86_64-darwin-21
         | 
| @@ -2,20 +2,19 @@ | |
| 2 2 |  | 
| 3 3 | 
             
            module Cin7API
         | 
| 4 4 | 
             
              class CreditNoteResource < Resource
         | 
| 5 | 
            -
                # NOTE: Cin7 is doing a binary OR check for the filter params
         | 
| 6 5 | 
             
                # @client.credit_note.where(sales_reference: "#1050", email: "postco360@example.com")
         | 
| 7 6 | 
             
                def where(**params)
         | 
| 8 | 
            -
                   | 
| 9 | 
            -
                  credit_notes.map { |attributes| CreditNote.new(attributes) }
         | 
| 7 | 
            +
                  response_body = get_request("CreditNotes", params: params).body
         | 
| 8 | 
            +
                  credit_notes = response_body.map { |attributes| CreditNote.new(attributes) }
         | 
| 9 | 
            +
                  # Doing a filter here because Cin7 is doing a binary OR check for the filter params
         | 
| 10 | 
            +
                  credit_notes.filter do |credit_note|
         | 
| 11 | 
            +
                    params.reduce(true) { |acc, (key, value)| acc && credit_note[key] == value }
         | 
| 12 | 
            +
                  end
         | 
| 10 13 | 
             
                end
         | 
| 11 14 |  | 
| 12 15 | 
             
                # @client.credit_note.find_by(sales_reference: "#1050", email: "postco360@example.com")
         | 
| 13 16 | 
             
                def find_by(**params)
         | 
| 14 | 
            -
                   | 
| 15 | 
            -
                    where(**params).find do |p|
         | 
| 16 | 
            -
                      params.reduce(true) { |acc, (key, value)| acc && p[key] == value }
         | 
| 17 | 
            -
                    end
         | 
| 18 | 
            -
                  credit_note ? CreditNote.new(credit_note) : nil
         | 
| 17 | 
            +
                  where(**params).first
         | 
| 19 18 | 
             
                end
         | 
| 20 19 |  | 
| 21 20 | 
             
                # @client.credit_note.find(2223)
         | 
| @@ -2,19 +2,19 @@ | |
| 2 2 |  | 
| 3 3 | 
             
            module Cin7API
         | 
| 4 4 | 
             
              class PaymentResource < Resource
         | 
| 5 | 
            -
                # @client.payment.where(order_id: 2223)
         | 
| 5 | 
            +
                # @client.payment.where(order_id: 2223, order_ref: "CRN-2223")
         | 
| 6 6 | 
             
                def where(**params)
         | 
| 7 | 
            -
                   | 
| 8 | 
            -
                  payments.map { |attributes| Payment.new(attributes) }
         | 
| 7 | 
            +
                  response_body = get_request("Payments", params: params).body
         | 
| 8 | 
            +
                  payments = response_body.map { |attributes| Payment.new(attributes) }
         | 
| 9 | 
            +
                  # Doing a filter here because Cin7 is doing a binary OR check for the filter params
         | 
| 10 | 
            +
                  payments.filter do |payment|
         | 
| 11 | 
            +
                    params.reduce(true) { |acc, (key, value)| acc && payment[key] == value }
         | 
| 12 | 
            +
                  end
         | 
| 9 13 | 
             
                end
         | 
| 10 14 |  | 
| 11 15 | 
             
                # @client.payment.find_by(order_id: 2223, order_ref: "CRN-2223")
         | 
| 12 16 | 
             
                def find_by(**params)
         | 
| 13 | 
            -
                   | 
| 14 | 
            -
                    where(**params).find do |p|
         | 
| 15 | 
            -
                      params.reduce(true) { |acc, (key, value)| acc && p[key] == value }
         | 
| 16 | 
            -
                    end
         | 
| 17 | 
            -
                  payment.present? ? payment : nil
         | 
| 17 | 
            +
                  where(**params).first
         | 
| 18 18 | 
             
                end
         | 
| 19 19 |  | 
| 20 20 | 
             
                # @client.payment.find(698)
         | 
| @@ -2,20 +2,19 @@ | |
| 2 2 |  | 
| 3 3 | 
             
            module Cin7API
         | 
| 4 4 | 
             
              class SalesOrderResource < Resource
         | 
| 5 | 
            -
                # NOTE: Cin7 is doing a binary OR check for the filter params
         | 
| 6 5 | 
             
                # @client.sales_order.where(reference: "#1050", email: "postco360@example.com")
         | 
| 7 6 | 
             
                def where(**params)
         | 
| 8 | 
            -
                   | 
| 9 | 
            -
                  sales_orders.map { |attributes| SalesOrder.new(attributes) }
         | 
| 7 | 
            +
                  response_body = get_request("SalesOrders", params: params).body
         | 
| 8 | 
            +
                  sales_orders = response_body.map { |attributes| SalesOrder.new(attributes) }
         | 
| 9 | 
            +
                  # Doing a filter here because Cin7 is doing a binary OR check for the filter params
         | 
| 10 | 
            +
                  sales_orders.filter do |sales_order|
         | 
| 11 | 
            +
                    params.reduce(true) { |acc, (key, value)| acc && sales_order[key] == value }
         | 
| 12 | 
            +
                  end
         | 
| 10 13 | 
             
                end
         | 
| 11 14 |  | 
| 12 15 | 
             
                # @client.sales_order.find_by(reference: "#1050", email: "postco360@example.com")
         | 
| 13 16 | 
             
                def find_by(**params)
         | 
| 14 | 
            -
                   | 
| 15 | 
            -
                    where(**params).find do |p|
         | 
| 16 | 
            -
                      params.reduce(true) { |acc, (key, value)| acc && p[key] == value }
         | 
| 17 | 
            -
                    end
         | 
| 18 | 
            -
                  sales_order ? SalesOrder.new(sales_order) : nil
         | 
| 17 | 
            +
                  where(**params).first
         | 
| 19 18 | 
             
                end
         | 
| 20 19 |  | 
| 21 20 | 
             
                # @client.sales_order.find(2218)
         | 
    
        data/lib/cin7_api/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: cin7_api
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.0. | 
| 4 | 
            +
              version: 1.0.4
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Wei Zhe Heng
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2022- | 
| 11 | 
            +
            date: 2022-10-11 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: activesupport
         |