<commit_before>module SolidusShipwire
  module Shipment
    prepend SolidusShipwire::Proxy

    def to_shipwire
      {
        orderId: id,
        orderNo: number,
        processAfterDate: process_after_date,
        options: {
          warehouseId: warehouse_id,
          currency: shipwire_currency,
          canSplit: shipwire_can_split?,
          hold: shipwire_hold?,
          server: shipwire_server
        },
        items: shipping_manifest_to_shipwire,
        shipTo: order.ship_address.to_shipwire.merge(email: order.email)
      }
    end

    def shipwire_inventory_units?
      shipwire_inventory_units.any?
    end

    def shipping_manifest_to_shipwire
      Spree::ShippingManifest.
        new(inventory_units: shipwire_inventory_units).
        items.map(&:to_shipwire)
    end

    def to_shipwire_object(hash)
      SolidusShipwire::ShipwireObjects::Shipment.new(hash['id'], self, hash)
    end

    def shipwire_can_split?
      1
    end

    def shipwire_hold?
      0
    end

    def shipwire_currency
      'USD'
    end

    def shipwire_server
      'Production'
    end

    def process_after_date
      nil
    end

    private

    def shipwire_inventory_units
      @shipwire_inventory_units = inventory_units.eligible_for_shipwire
    end

    def shipwire_instance
      Shipwire::Orders.new
    end

    def warehouse_id
      Spree::ShipwireConfig.default_warehouse_id
    end
  end
end

Spree::Shipment.prepend SolidusShipwire::Shipment<commit_msg>Use Shipwireable module on Spree::Shipment<commit_after>module SolidusShipwire
  module ShipmentDecorator
    def self.prepended(base)
      base.acts_as_shipwireable api_class: Shipwire::Orders
    end

    def to_shipwire
      {
        orderId: id,
        orderNo: number,
        processAfterDate: process_after_date,
        options: {
          warehouseId: warehouse_id,
          currency: shipwire_currency,
          canSplit: shipwire_can_split?,
          hold: shipwire_hold?,
          server: shipwire_server
        },
        items: shipping_manifest_to_shipwire,
        shipTo: order.ship_address.to_shipwire.merge(email: order.email)
      }
    end

    def shipwire_inventory_units?
      shipwire_inventory_units.any?
    end

    def shipping_manifest_to_shipwire
      Spree::ShippingManifest.
        new(inventory_units: shipwire_inventory_units).
        items.map(&:to_shipwire)
    end

    def shipwire_can_split?
      1
    end

    def shipwire_hold?
      0
    end

    def shipwire_currency
      'USD'
    end

    def shipwire_server
      'Production'
    end

    def process_after_date
      nil
    end

    private

    def shipwire_inventory_units
      @shipwire_inventory_units = inventory_units.eligible_for_shipwire
    end

    def warehouse_id
      Spree::ShipwireConfig.default_warehouse_id
    end

    Spree::Shipment.prepend self
  end
end
{'fraction_non_alphanumeric': 0.05636237897648686, 'fraction_numerical': 0.0013831258644536654, 'mean_word_length': 2.4729891956782715, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5302286', 'n_tokens_mistral': 924, 'n_tokens_neox': 900, 'n_words': 169}