<commit_before>module Meli
  class Shipment < Meli::Base
    self.use_oauth = true
    self.prefix= "/orders/:order_id/"

    cattr_accessor :possible_status
    self.possible_status = %w(pending handling ready_to_ship shipped delivered not_delivered cancelled )

    belongs_to :order, class_name: "Meli::Order"


    def order=(order)
      self.prefix_options[:order_id] = order.id
    end

    # override by instantiate_record
    def self.instantiate_collection(record, original_params = {}, prefix_options = {})
      puts "\n"
      puts " ==> instantiate_collection \n -> #{record}\n -> #{prefix_options}"
      puts "\n"

      instantiate_record record, prefix_options
    end

  end
end<commit_msg>Implements '/shipments/{shipment_id}' and '/order/{order_id}/shipments' Mercadolibre endpoints<commit_after>module Meli
  class Shipment < Meli::Base
    self.use_oauth = true
    self.prefix= "/orders/:order_id/"

    cattr_accessor :options
    cattr_accessor :possible_status
    self.possible_status = %w(pending handling ready_to_ship shipped delivered not_delivered cancelled )

    belongs_to :order, class_name: "Meli::Order"


    def order=(order)
      self.prefix_options[:order_id] = order.id
    end

    # override by instantiate_record
    def self.instantiate_collection(record, original_params = {}, prefix_options = {})
      puts "\n"
      puts " ==> instantiate_collection \n -> #{record}\n -> #{prefix_options}"
      puts "\n"

      instantiate_record record, prefix_options
    end

    def self.find(shipment_id)
      path = "/shipments/#{shipment_id}"
      data = format.decode(connection.get(path, headers).body)
      instantiate_record data
    end

    def self.find_by_order_id(order_id)
      path = "/orders/#{order_id}/shipments"
      data = format.decode(connection.get(path, headers).body)
      instantiate_record data
    end

  end
end


# Meli::Shipment.find
# orders/{Order_id}/shipments ---- /shipments/{Shipment_id}
# Meli::Shipment.by_order_id
{'fraction_non_alphanumeric': 0.111944027986007, 'fraction_numerical': 0.0, 'mean_word_length': 3.4887892376681613, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '1417069', 'n_tokens_mistral': 643, 'n_tokens_neox': 628, 'n_words': 130}