<commit_before>class MarketplaceWebService
  require 'net/https'
  require 'time'
  require 'cgi'
  require 'openssl'
  require 'base64'
  require 'nokogiri'
  
  @@aws_host = "mws.amazonservices.com"

  def initialize(merchant_id, marketplace_id, credentials)
    @merchant_id = merchant_id
    @marketplace_id = marketplace_id
    @credentials = credentials
  end
  
  def get_report_list
    query = build_query("GetReportList")

    # Make request
    xml = post query
    
    # Get test document.
    # xml = File.open("#{Rails.root}/test/fixtures/get_report_list.xml")
    
    # Return nokogiri object
    doc = Nokogiri::XML(xml)
  end
  
  def get_shipments_data
    doc = get_report_list
    report_id = doc.css("ReportType:contains('_GET_AMAZON_FULFILLED_SHIPMENTS_DATA_')").first.parent().css("ReportId").text

    query = build_query("GetReport", {
      ReportId: report_id
    })

    # Make request - this request returns a CSV document
    csv = post query<commit_msg>Updating credential loading code.<commit_after>class MarketplaceWebService
  require 'net/https'
  require 'time'
  require 'cgi'
  require 'openssl'
  require 'base64'
  require 'nokogiri'
  
  @@aws_host = "mws.amazonservices.com"

  def initialize(h = {})
    @merchant_id = h["merchant_id"]
    @marketplace_id = h["marketplace_id"]
    @credentials = h["credentials"]
  end
  
  def get_report_list
    query = build_query("GetReportList")

    # Make request
    xml = post query
    
    # Get test document.
    # xml = File.open("#{Rails.root}/test/fixtures/get_report_list.xml")
    
    # Return nokogiri object
    doc = Nokogiri::XML(xml)
  end
  
  def get_shipments_data
    doc = get_report_list
    report_id = doc.css("ReportType:contains('_GET_AMAZON_FULFILLED_SHIPMENTS_DATA_')").first.parent().css("ReportId").text

    query = build_query("GetReport", {
      ReportId: report_id
    })

    # Make request - this request returns a CSV document
    csv = post query
{'fraction_non_alphanumeric': 0.10542321338063862, 'fraction_numerical': 0.0020273694880892043, 'mean_word_length': 3.4359550561797754, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, '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': '4094173', 'n_tokens_mistral': 684, 'n_tokens_neox': 664, 'n_words': 136}