<commit_before>
module ClarifaiRuby
  class Client
    include HTTParty
    base_uri 'https://api.clarifai.com'

    def initialize
      #get access token with client_id and client_secret & put access token in heade
      @options = {
        :headers => {
          "Authorization" => "Bearer #{Token.new.token}"
        }
      }
    end

    def info
      info_request = InfoRequest.new(@options)
      info_response = InfoResponse.new(info_request.get)
      # Info.new(opts)
    end

    def tag(opts)
      # Tag.new(opts)
    end

    def feedback(opts)
      # Feedback.new(opts)
    end

    def color(opts)
      # Color.new(opts)
    end
  end
end

# module ClarifaiRuby
#   class TagRequest
#     def initialize
#
#     end
#
#     def client
#       ClarifaiRuby.client
#     end
#
#     def get
#       query = { "url" => img_url }
#     end
#
#   end
# end
#
#
# ClarifaiRuby::TagRequest.new(image_url, options)
# # ClarifaiRuby::TagRequest.new(image_url, options)
# => ClarifaiRuby::TagResponse
# - tags, probs






# ClarifaiRuby::InfoRequest.new(options).get

module ClarifaiRuby
  class InfoRequest
    include HTTParty
    base_uri 'https://api.clarifai.com'

    def initialize(options)
      @options = options
      @request_path = '/info'
    end

    def get_request_url
      build_request_url
    end

    def get
      #do the actual GET
      response = self.class.get(build_request_url, :headers => @options[:headers])
    end
    #
    # def post
    #   #do the actual POST
    #   response = #something
    #   response = JSON.parse(response)
    #   return ClarifaiRuby::InfoResponse.new(response)
    # end
    #
    # def client
    #   ClarifaiRuby::Client.new
    # end
    #
    private
    #
    def build_request_url
      ClarifaiRuby.configuration.api_url + @request_path
    end
  end
end

module ClarifaiRuby
  class InfoResponse #parse the json response anmake it available
    attr_reader :max_image_size, :default_model, :max_video_size

    def initialize(json_response)
      @raw_response = json_response
      @max_image_size = json_response['results']['max_image_size']
      @max_video_size = json_response['results']['max_video_size']
      @default_model = json_response['results']['default_model']
    end

    def status_code
      # self.get["status_code"]
    end
  end
end


module ClarifaiRuby
  class Token
    include HTTParty
    base_uri 'https://api.clarifai.com'

    attr_reader :token

    def initialize
      @token = get_token
    end

    private
    def get_token
      C<PASSWORD>.generate_token
    end
  end
end

# ClarifaiRuby::InfoResponse.new(response)
#<commit_msg>Dynamic setters/getters<commit_after>
module ClarifaiRuby
  class Client
    include HTTParty
    base_uri 'https://api.clarifai.com'

    attr_reader :info_response

    def initialize
      #get access token with client_id and client_secret & put access token in heade
      @options = {
        :headers => {
          "Authorization" => "Bearer #{Token.new.token}"
        }
      }
    end

    def info
      info_request = InfoRequest.new(@options)
      @info_response = InfoResponse.new(info_request.get, 0)
      # Info.new(opts)
    end

    # def tag(opts)
    #   # Tag.new(opts)
    # end
    #
    # def feedback(opts)
    #   # Feedback.new(opts)
    # end
    #
    # def color(opts)
    #   # Color.new(opts)
    # end
  end
end

# module ClarifaiRuby
#   class TagRequest
#     def initialize
#
#     end
#
#     def client
#       ClarifaiRuby.client
#     end
#
#     def get
#       query = { "url" => img_url }
#     end
#
#   end
# end
#
#
# ClarifaiRuby::TagRequest.new(image_url, options)
# # ClarifaiRuby::TagRequest.new(image_url, options)
# => ClarifaiRuby::TagResponse
# - tags, probs






# ClarifaiRuby::InfoRequest.new(options).get

module ClarifaiRuby
  class InfoRequest
    include HTTParty
    base_uri 'https://api.clarifai.com'

    def initialize(options)
      @options = options
      @request_path = '/info'
    end

    def get_request_url
      build_request_url
    end

    def get
      #do the actual GET
      response = self.class.get(build_request_url, :headers => @options[:headers])
    end
    #
    # def post
    #   #do the actual POST
    #   response = #something
    #   response = JSON.parse(response)
    #   return ClarifaiRuby::InfoResponse.new(response)
    # end
    #
    # def client
    #   ClarifaiRuby::Client.new
    # end
    #
    private
    #
    def build_request_url
      ClarifaiRuby.configuration.api_url + @request_path
    end
  end
end

module ClarifaiRuby
  class InfoResponse #parse the json response anmake it available
    # attr_reader :max_image_size, :default_model, :max_video_size

    def initialize(json_response, recursion)

      json_response.each do |name, value|
        if value.is_a? Hash
          initialize(value, recursion+1)
        else
          self.class.send(:attr_reader, name)
          instance_variable_set("@#{name}", value)
        end
      end


      # @raw_response = json_response.parsed_response
      #
      # print "\n" + @raw_response.to_s + "\n"
      # @response = @raw_response['results']
      # print "\n" + @response.to_s + "\n"
      #
      # @max_image_size = json_response['results']['max_image_size']
      # @max_video_size = json_response['results']['max_video_size']
      # @default_model = json_response['results']['default_model']
    end

    def status_code
      # self.get["status_code"]
    end
  end
end


module ClarifaiRuby
  class Token
    include HTTParty
    base_uri 'https://api.clarifai.com'

    attr_reader :token

    def initialize
      @token = get_token
    end

    private
    def get_token
      C<PASSWORD>Ruby.generate_token
    end
  end
end

# ClarifaiRuby::InfoResponse.new(response)
#
{'fraction_non_alphanumeric': 0.09893324156916725, 'fraction_numerical': 0.00034411562284927734, 'mean_word_length': 2.493389423076923, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 6, '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': '5420117', 'n_tokens_mistral': 1995, 'n_tokens_neox': 1899, 'n_words': 407}