active_fulfillment 3.0.1 → 3.0.2
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/active_fulfillment/services/amazon_mws.rb +1 -1
 - data/lib/active_fulfillment/services/shipwire.rb +5 -1
 - data/lib/active_fulfillment/services/shopify_api.rb +1 -1
 - data/lib/active_fulfillment/version.rb +1 -1
 - data/test/test_helper.rb +0 -1
 - data/test/unit/services/shipwire_test.rb +52 -19
 - metadata +10 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: c0398fdadc0a5d2c85eda230851fe5727c07b63e
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: c3084c84d669ea956856716bc0f32388d27039d7
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 86f6821811d3c3b32b83bb29ec9b1e49f2a45ede0d2296f72940a732dec6f773aa3835b2e691421aef1f44b0654fdff32be8feb5da4afbe6e49202453d005435
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: f35bcd2587f11e1ebc2e0e5189cfe9dbb373ed26db88b6773de13a906d3b2cf7c9d9b2911ae94fbabb18a8e2dc77b3dff5dd264c280a67a8211ff7904ba6e606
         
     | 
| 
         @@ -168,7 +168,7 @@ module ActiveFulfillment 
     | 
|
| 
       168 
168 
     | 
    
         
             
                  query = build_full_query(verb, uri, params)
         
     | 
| 
       169 
169 
     | 
    
         
             
                  headers = build_headers(query)
         
     | 
| 
       170 
170 
     | 
    
         
             
                  log_query = query.dup
         
     | 
| 
       171 
     | 
    
         
            -
                  [@options[:login], @options[:app_id], @mws_auth_token].each { |key| log_query.gsub!( 
     | 
| 
      
 171 
     | 
    
         
            +
                  [@options[:login], @options[:app_id], @mws_auth_token].each { |key| log_query.gsub!(key.to_s, '[filtered]') if key.present? }
         
     | 
| 
       172 
172 
     | 
    
         | 
| 
       173 
173 
     | 
    
         
             
                  logger.info "[#{self.class}][#{action}] query=#{log_query}"
         
     | 
| 
       174 
174 
     | 
    
         
             
                  data = ssl_post(uri.to_s, query, headers)
         
     | 
| 
         @@ -171,7 +171,11 @@ module ActiveFulfillment 
     | 
|
| 
       171 
171 
     | 
    
         
             
                end
         
     | 
| 
       172 
172 
     | 
    
         | 
| 
       173 
173 
     | 
    
         
             
                def commit(action, request)
         
     | 
| 
      
 174 
     | 
    
         
            +
                  log_query = request.dup
         
     | 
| 
      
 175 
     | 
    
         
            +
                  [@options[:password], affiliate_id].each { |key| log_query.gsub!(key.to_s, '[filtered]') if key.present? }
         
     | 
| 
      
 176 
     | 
    
         
            +
                  logger.info "[#{self.class}][#{SERVICE_URLS[action]}][#{POST_VARS[action]}] query=#{log_query}"
         
     | 
| 
       174 
177 
     | 
    
         
             
                  data = ssl_post(SERVICE_URLS[action], "#{POST_VARS[action]}=#{CGI.escape(request)}")
         
     | 
| 
      
 178 
     | 
    
         
            +
                  logger.info "[#{self.class}][result] #{data}"
         
     | 
| 
       175 
179 
     | 
    
         | 
| 
       176 
180 
     | 
    
         
             
                  response = parse_response(action, data)
         
     | 
| 
       177 
181 
     | 
    
         
             
                  Response.new(response[:success], response[:message], response, :test => test?)
         
     | 
| 
         @@ -220,8 +224,8 @@ module ActiveFulfillment 
     | 
|
| 
       220 
224 
     | 
    
         
             
                  response = { stock_levels: {} }
         
     | 
| 
       221 
225 
     | 
    
         
             
                  Parsing.with_xml_document(xml, response) do |document|
         
     | 
| 
       222 
226 
     | 
    
         
             
                    status = document.at_xpath('//Status'.freeze).child.content
         
     | 
| 
       223 
     | 
    
         
            -
                    total_products = document.at_xpath('//TotalProducts'.freeze).child.content
         
     | 
| 
       224 
227 
     | 
    
         
             
                    success = test? ? status == 'Test'.freeze : status == '0'.freeze
         
     | 
| 
      
 228 
     | 
    
         
            +
                    total_products = success ? document.at_xpath('//TotalProducts'.freeze).child.content : 0
         
     | 
| 
       225 
229 
     | 
    
         
             
                    message = success ? 'Successfully received the stock levels'.freeze : document.at_xpath('//ErrorMessage'.freeze).child.content
         
     | 
| 
       226 
230 
     | 
    
         | 
| 
       227 
231 
     | 
    
         
             
                    {
         
     | 
| 
         @@ -51,7 +51,7 @@ module ActiveFulfillment 
     | 
|
| 
       51 
51 
     | 
    
         
             
                end
         
     | 
| 
       52 
52 
     | 
    
         | 
| 
       53 
53 
     | 
    
         
             
                def fetch_tracking_data(order_numbers, options = {})
         
     | 
| 
       54 
     | 
    
         
            -
                  options.merge!({: 
     | 
| 
      
 54 
     | 
    
         
            +
                  options.merge!({:order_names => order_numbers})
         
     | 
| 
       55 
55 
     | 
    
         
             
                  response = send_app_request('fetch_tracking_numbers'.freeze, options.delete(:headers), options)
         
     | 
| 
       56 
56 
     | 
    
         
             
                  if response
         
     | 
| 
       57 
57 
     | 
    
         
             
                    tracking_numbers = parse_response(response, 'TrackingNumbers'.freeze, 'Order'.freeze, 'ID'.freeze, 'Tracking'.freeze) { |o| o }
         
     | 
    
        data/test/test_helper.rb
    CHANGED
    
    
| 
         @@ -3,12 +3,14 @@ require 'test_helper' 
     | 
|
| 
       3 
3 
     | 
    
         
             
            class ShipwireTest < Minitest::Test
         
     | 
| 
       4 
4 
     | 
    
         
             
              include ActiveFulfillment::Test::Fixtures
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
      
 6 
     | 
    
         
            +
              PASSWORD = 'test_password'
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
       6 
8 
     | 
    
         
             
              def setup
         
     | 
| 
       7 
9 
     | 
    
         
             
                ActiveFulfillment::Base.mode = :test
         
     | 
| 
       8 
10 
     | 
    
         | 
| 
       9 
11 
     | 
    
         
             
                @shipwire = ActiveFulfillment::ShipwireService.new(
         
     | 
| 
       10 
12 
     | 
    
         
             
                              :login => 'cody@example.com',
         
     | 
| 
       11 
     | 
    
         
            -
                              :password =>  
     | 
| 
      
 13 
     | 
    
         
            +
                              :password => PASSWORD
         
     | 
| 
       12 
14 
     | 
    
         
             
                            )
         
     | 
| 
       13 
15 
     | 
    
         | 
| 
       14 
16 
     | 
    
         
             
                @options = {
         
     | 
| 
         @@ -32,7 +34,7 @@ class ShipwireTest < Minitest::Test 
     | 
|
| 
       32 
34 
     | 
    
         | 
| 
       33 
35 
     | 
    
         
             
              def test_missing_login
         
     | 
| 
       34 
36 
     | 
    
         
             
                assert_raises(ArgumentError) do
         
     | 
| 
       35 
     | 
    
         
            -
                  ActiveFulfillment::ShipwireService.new(:password =>  
     | 
| 
      
 37 
     | 
    
         
            +
                  ActiveFulfillment::ShipwireService.new(:password => PASSWORD)
         
     | 
| 
       36 
38 
     | 
    
         
             
                end
         
     | 
| 
       37 
39 
     | 
    
         
             
              end
         
     | 
| 
       38 
40 
     | 
    
         | 
| 
         @@ -44,20 +46,20 @@ class ShipwireTest < Minitest::Test 
     | 
|
| 
       44 
46 
     | 
    
         | 
| 
       45 
47 
     | 
    
         
             
              def test_missing_credentials
         
     | 
| 
       46 
48 
     | 
    
         
             
                assert_raises(ArgumentError) do
         
     | 
| 
       47 
     | 
    
         
            -
                  ActiveFulfillment::ShipwireService.new(:password =>  
     | 
| 
      
 49 
     | 
    
         
            +
                  ActiveFulfillment::ShipwireService.new(:password => PASSWORD)
         
     | 
| 
       48 
50 
     | 
    
         
             
                end
         
     | 
| 
       49 
51 
     | 
    
         
             
              end
         
     | 
| 
       50 
52 
     | 
    
         | 
| 
       51 
53 
     | 
    
         
             
              def test_credentials_present
         
     | 
| 
       52 
54 
     | 
    
         
             
                assert ActiveFulfillment::ShipwireService.new(
         
     | 
| 
       53 
55 
     | 
    
         
             
                  :login    => 'cody',
         
     | 
| 
       54 
     | 
    
         
            -
                  :password =>  
     | 
| 
      
 56 
     | 
    
         
            +
                  :password => PASSWORD
         
     | 
| 
       55 
57 
     | 
    
         
             
                )
         
     | 
| 
       56 
58 
     | 
    
         
             
              end
         
     | 
| 
       57 
59 
     | 
    
         | 
| 
       58 
60 
     | 
    
         
             
              def test_country_format
         
     | 
| 
       59 
     | 
    
         
            -
                xml =  
     | 
| 
       60 
     | 
    
         
            -
                country_node =  
     | 
| 
      
 61 
     | 
    
         
            +
                xml = Nokogiri::XML(@shipwire.send(:build_fulfillment_request, '123456', @address, @line_items, @options))
         
     | 
| 
      
 62 
     | 
    
         
            +
                country_node = xml.at_xpath(xml, "//Country")
         
     | 
| 
       61 
63 
     | 
    
         
             
                assert_equal 'US', country_node.text
         
     | 
| 
       62 
64 
     | 
    
         
             
              end
         
     | 
| 
       63 
65 
     | 
    
         | 
| 
         @@ -71,6 +73,36 @@ class ShipwireTest < Minitest::Test 
     | 
|
| 
       71 
73 
     | 
    
         
             
                assert_equal 677, response.stock_levels['KingMonkey']
         
     | 
| 
       72 
74 
     | 
    
         
             
              end
         
     | 
| 
       73 
75 
     | 
    
         | 
| 
      
 76 
     | 
    
         
            +
              def test_stock_levels_parses_invalid_credentials
         
     | 
| 
      
 77 
     | 
    
         
            +
                @shipwire.expects(:ssl_post).returns(xml_fixture('shipwire/invalid_login_inventory_update_response'))
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
                response = @shipwire.fetch_stock_levels
         
     | 
| 
      
 80 
     | 
    
         
            +
                refute response.success?
         
     | 
| 
      
 81 
     | 
    
         
            +
                assert_equal 'Error with Valid Username/EmailAddress and Password Required. There is an error in XML document.', response.message
         
     | 
| 
      
 82 
     | 
    
         
            +
              end
         
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
      
 84 
     | 
    
         
            +
              def test_stock_levels_logs_request_and_response
         
     | 
| 
      
 85 
     | 
    
         
            +
                @shipwire.class.logger.expects(:info).with do |message|
         
     | 
| 
      
 86 
     | 
    
         
            +
                  assert_match /InventoryUpdate/, message unless message.include?('InventoryUpdateResponse')
         
     | 
| 
      
 87 
     | 
    
         
            +
                  refute message.include?(PASSWORD)
         
     | 
| 
      
 88 
     | 
    
         
            +
                  true
         
     | 
| 
      
 89 
     | 
    
         
            +
                end.twice
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
                @shipwire.expects(:ssl_post).returns(xml_fixture('shipwire/inventory_get_response'))
         
     | 
| 
      
 92 
     | 
    
         
            +
                response = @shipwire.fetch_stock_levels
         
     | 
| 
      
 93 
     | 
    
         
            +
              end
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
              def test_logging_with_specific_passwords
         
     | 
| 
      
 96 
     | 
    
         
            +
                @shipwire = ActiveFulfillment::ShipwireService.new(login: 'cody@example.com', password: 345)
         
     | 
| 
      
 97 
     | 
    
         
            +
                @shipwire.class.logger.expects(:info).with do |message|
         
     | 
| 
      
 98 
     | 
    
         
            +
                  refute message.include?('345')
         
     | 
| 
      
 99 
     | 
    
         
            +
                  true
         
     | 
| 
      
 100 
     | 
    
         
            +
                end.twice
         
     | 
| 
      
 101 
     | 
    
         
            +
             
     | 
| 
      
 102 
     | 
    
         
            +
                @shipwire.stubs(:ssl_post).returns(xml_fixture('shipwire/inventory_get_response'))
         
     | 
| 
      
 103 
     | 
    
         
            +
                response = @shipwire.fetch_stock_levels
         
     | 
| 
      
 104 
     | 
    
         
            +
              end
         
     | 
| 
      
 105 
     | 
    
         
            +
             
     | 
| 
       74 
106 
     | 
    
         
             
              def test_stock_levels_include_pending_when_set
         
     | 
| 
       75 
107 
     | 
    
         
             
                @shipwire = ActiveFulfillment::ShipwireService.new(
         
     | 
| 
       76 
108 
     | 
    
         
             
                              :login => 'cody@example.com',
         
     | 
| 
         @@ -93,8 +125,8 @@ class ShipwireTest < Minitest::Test 
     | 
|
| 
       93 
125 
     | 
    
         
             
                              :password => 'test',
         
     | 
| 
       94 
126 
     | 
    
         
             
                              :include_empty_stock => true
         
     | 
| 
       95 
127 
     | 
    
         
             
                            )
         
     | 
| 
       96 
     | 
    
         
            -
                xml =  
     | 
| 
       97 
     | 
    
         
            -
                assert  
     | 
| 
      
 128 
     | 
    
         
            +
                xml = Nokogiri::XML(@shipwire.send(:build_inventory_request, {}))
         
     | 
| 
      
 129 
     | 
    
         
            +
                assert xml.at_xpath(xml, '//IncludeEmpty')
         
     | 
| 
       98 
130 
     | 
    
         
             
              end
         
     | 
| 
       99 
131 
     | 
    
         | 
| 
       100 
132 
     | 
    
         
             
              def test_no_tracking_numbers_available
         
     | 
| 
         @@ -164,29 +196,30 @@ class ShipwireTest < Minitest::Test 
     | 
|
| 
       164 
196 
     | 
    
         | 
| 
       165 
197 
     | 
    
         
             
              def test_affiliate_id
         
     | 
| 
       166 
198 
     | 
    
         
             
                ActiveFulfillment::ShipwireService.affiliate_id = 'affiliate_id'
         
     | 
| 
       167 
     | 
    
         
            -
             
     | 
| 
       168 
     | 
    
         
            -
                 
     | 
| 
       169 
     | 
    
         
            -
                affiliate_id = REXML::XPath.first(xml, "//AffiliateId")
         
     | 
| 
      
 199 
     | 
    
         
            +
                xml = Nokogiri::XML(@shipwire.send(:build_fulfillment_request, '123456', @address, @line_items, @options))
         
     | 
| 
      
 200 
     | 
    
         
            +
                affiliate_id = xml.at_xpath(xml, "//AffiliateId")
         
     | 
| 
       170 
201 
     | 
    
         
             
                assert_equal 'affiliate_id', affiliate_id.text
         
     | 
| 
       171 
202 
     | 
    
         
             
              end
         
     | 
| 
       172 
203 
     | 
    
         | 
| 
       173 
204 
     | 
    
         
             
              def test_company_name_in_request
         
     | 
| 
       174 
     | 
    
         
            -
                xml =  
     | 
| 
       175 
     | 
    
         
            -
                company_node =  
     | 
| 
      
 205 
     | 
    
         
            +
                xml = Nokogiri::XML(@shipwire.send(:build_fulfillment_request, '123456', @address, @line_items, @options))
         
     | 
| 
      
 206 
     | 
    
         
            +
                company_node = xml.at_xpath(xml, "//Company")
         
     | 
| 
       176 
207 
     | 
    
         
             
                assert_equal 'MyCorp', company_node.text
         
     | 
| 
       177 
208 
     | 
    
         
             
              end
         
     | 
| 
       178 
209 
     | 
    
         | 
| 
       179 
210 
     | 
    
         
             
              def test_order_excludes_note_by_default
         
     | 
| 
       180 
     | 
    
         
            -
                xml =  
     | 
| 
       181 
     | 
    
         
            -
                note_node =  
     | 
| 
       182 
     | 
    
         
            -
                 
     | 
| 
      
 211 
     | 
    
         
            +
                xml = Nokogiri::XML(@shipwire.send(:build_fulfillment_request, '123456', @address, @line_items, @options))
         
     | 
| 
      
 212 
     | 
    
         
            +
                note_node = xml.at_xpath(xml, "//Note")
         
     | 
| 
      
 213 
     | 
    
         
            +
                assert_equal 0, note_node.children.select { |child| child.cdata? }.size
         
     | 
| 
      
 214 
     | 
    
         
            +
                assert_equal false, note_node.cdata?
         
     | 
| 
       183 
215 
     | 
    
         
             
              end
         
     | 
| 
       184 
216 
     | 
    
         | 
| 
       185 
217 
     | 
    
         
             
              def test_order_includes_note_when_present
         
     | 
| 
       186 
218 
     | 
    
         
             
                @options[:note] = "A test note"
         
     | 
| 
       187 
     | 
    
         
            -
                xml =  
     | 
| 
       188 
     | 
    
         
            -
                note_node =  
     | 
| 
       189 
     | 
    
         
            -
                assert_equal "A test note", note_node. 
     | 
| 
      
 219 
     | 
    
         
            +
                xml = Nokogiri::XML(@shipwire.send(:build_fulfillment_request, '123456', @address, @line_items, @options))
         
     | 
| 
      
 220 
     | 
    
         
            +
                note_node = xml.at_xpath(xml, "//Note")
         
     | 
| 
      
 221 
     | 
    
         
            +
                assert_equal "A test note", note_node.text.strip
         
     | 
| 
      
 222 
     | 
    
         
            +
                assert_equal note_node.children.select { |child| child.cdata? }.size, 1
         
     | 
| 
       190 
223 
     | 
    
         
             
              end
         
     | 
| 
       191 
224 
     | 
    
         | 
| 
       192 
225 
     | 
    
         
             
              def test_error_response_cdata_parsing
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: active_fulfillment
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 3.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 3.0.2
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Cody Fauser
         
     | 
| 
         @@ -9,7 +9,7 @@ authors: 
     | 
|
| 
       9 
9 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       10 
10 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
11 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
     | 
    
         
            -
            date: 2016- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2016-07-06 00:00:00.000000000 Z
         
     | 
| 
       13 
13 
     | 
    
         
             
            dependencies:
         
     | 
| 
       14 
14 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       15 
15 
     | 
    
         
             
              name: activesupport
         
     | 
| 
         @@ -18,6 +18,9 @@ dependencies: 
     | 
|
| 
       18 
18 
     | 
    
         
             
                - - ">="
         
     | 
| 
       19 
19 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       20 
20 
     | 
    
         
             
                    version: 3.2.9
         
     | 
| 
      
 21 
     | 
    
         
            +
                - - "<"
         
     | 
| 
      
 22 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 23 
     | 
    
         
            +
                    version: 5.1.0
         
     | 
| 
       21 
24 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       22 
25 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       23 
26 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -25,6 +28,9 @@ dependencies: 
     | 
|
| 
       25 
28 
     | 
    
         
             
                - - ">="
         
     | 
| 
       26 
29 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       27 
30 
     | 
    
         
             
                    version: 3.2.9
         
     | 
| 
      
 31 
     | 
    
         
            +
                - - "<"
         
     | 
| 
      
 32 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 33 
     | 
    
         
            +
                    version: 5.1.0
         
     | 
| 
       28 
34 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       29 
35 
     | 
    
         
             
              name: builder
         
     | 
| 
       30 
36 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -154,7 +160,8 @@ files: 
     | 
|
| 
       154 
160 
     | 
    
         
             
            - test/unit/services/shopify_api_test.rb
         
     | 
| 
       155 
161 
     | 
    
         
             
            - test/unit/services/webgistix_test.rb
         
     | 
| 
       156 
162 
     | 
    
         
             
            homepage: http://github.com/shopify/active_fulfillment
         
     | 
| 
       157 
     | 
    
         
            -
            licenses: 
     | 
| 
      
 163 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 164 
     | 
    
         
            +
            - MIT
         
     | 
| 
       158 
165 
     | 
    
         
             
            metadata: {}
         
     | 
| 
       159 
166 
     | 
    
         
             
            post_install_message: 
         
     | 
| 
       160 
167 
     | 
    
         
             
            rdoc_options: []
         
     |