Sha256: b91da662fa465893ccd4e97be21d25cdf9cfe6306bd7d20e697e490bc6030ddd

Contents?: true

Size: 960 Bytes

Versions: 1

Compression:

Stored size: 960 Bytes

Contents

module Wing
  module Actions
    module Orders
      def list_orders(options = { page: 1, limit: 20, createdBefore: nil, createdAfter: nil, sort: nil })
        get("/order", query: prepare_query(options)).parsed_response
      end

      def get_order(order_id)
        get("/order/#{order_id}").parsed_response
      end

      def create_order(data, options = {})
        post("/order", data, options).parsed_response
      end

      def generate_return_sticker(order_id:)
        post("/a/awb/#{order_id}?returnLabel=true").parsed_response
      end

      private

      def prepare_query(options = { page: 1, limit: 20, createdBefore: nil, createdAfter: nil, sort: nil })
        {
          page: options[:page],
          limit: options[:limit],
          createdBefore: options[:createdBefore],
          createdAfter: options[:createdAfter],
          sort: options[:sort]
        }.delete_if { |key, value| value.nil? }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wing.rb-0.1.1 lib/wing/actions/orders.rb