<commit_before>require 'oj'
require 'rest-client'

require 'ecwid/api/profile'
require 'ecwid/api/order'
require 'ecwid/api/product'

module Ecwid
  class Client
    include Ecwid::API::Profile
    include Ecwid::API::Order
    include Ecwid::API::Product

    def initialize(store_id, token)
      @configuration = {
        store_id: store_id,
        token: token
      }
    end

    def store_id
      @configuration[:store_id]
    end

    def token
      @configuration[:token]
    end

    def get(path, options = {}, headers = {})
      request(:get, path, options, headers)
    end

    def post(path, options = {}, headers = {})
      request(:post, path, options, headers)
    end

    def put(path, options = {}, headers = {})
      request(:put, path, options, headers)
    end

    def delete(path, options = {}, headers = {})
      request(:delete, path, options, headers)
    end

    def request(method, path, options, headers = {})
      client = RestClient::Resource.new "https://app.ecwid.com/api/v3/#{@configuration[:store_id]}#{path}"
      options.merge!(token: @configuration[:token])
      
      begin
        response = case method
                   when :get then
                     client.get headers.merge({ params: options, content_type: :json })
                   when :post then
                     client.post(options, headers.merge({ content_type: :json }))
                   when :put then
                     client.put(options, headers.merge({ content_type: :json }))
                   when :delete then
                     client.delete
                   end
        
        Oj.load response if((200..201) === response.code)
      rescue RestClient::NotModified
        nil<commit_msg>fixed issue with ssl certificate<commit_after>require 'oj'
require 'rest-client'

require 'ecwid/api/profile'
require 'ecwid/api/order'
require 'ecwid/api/product'

module Ecwid
  class Client
    include Ecwid::API::Profile
    include Ecwid::API::Order
    include Ecwid::API::Product

    def initialize(store_id, token)
      @configuration = {
        store_id: store_id,
        token: <PASSWORD>
      }
    end

    def store_id
      @configuration[:store_id]
    end

    def token
      @configuration[:token]
    end

    def get(path, options = {}, headers = {})
      request(:get, path, options, headers)
    end

    def post(path, options = {}, headers = {})
      request(:post, path, options, headers)
    end

    def put(path, options = {}, headers = {})
      request(:put, path, options, headers)
    end

    def delete(path, options = {}, headers = {})
      request(:delete, path, options, headers)
    end

    def request(method, path, options, headers = {})
      url = "https://app.ecwid.com/api/v3/#{@configuration[:store_id]}#{path}"
      url = "#{url}?token=#{@configuration[:token]}" if method == :get

      client = RestClient::Resource.new(url, ssl_version: 'SSLv23')

      options.merge!(token: @configuration[:token]) unless method == :get
      
      begin
        response = case method
                   when :get then
                     client.get(headers.merge({ content_type: :json }))
                   when :post then
                     client.post(options, headers.merge({ content_type: :json }))
                   when :put then
                     client.put(options, headers.merge({ content_type: :json }))
                   when :delete then
                     client.delete
                   end
        
        Oj.load response if((200..201) === response.code)
      rescue RestClient::NotModified
        nil
{'fraction_non_alphanumeric': 0.122268326417704, 'fraction_numerical': 0.004426002766251729, 'mean_word_length': 2.1092003439380913, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 2, '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': '4510833', 'n_tokens_mistral': 1027, 'n_tokens_neox': 994, 'n_words': 255}