<commit_before>require_relative '../touts'
require_relative '../users'
require_relative '../utils'

# todo: all api modules should simply return responses

module ReTout
  module API
    module Touts

      # http://developer.tout.com/api/touts-api/apimethod/retrieve-list-featured-touts
      def featured_touts(per_page=nil, page=nil)
        response = get("featured", query: {per_page: per_page, page: page})
        ReTout::Touts.new.from_response(response)
      end

      # implements http://developer.tout.com/api/touts-api/apimethod/retrieve-list-users-who-have-liked-tout
      def tout_liked_by(uid, order=nil, per_page=nil, page=nil)
        response = get("touts/#{uid}/liked_by", query: {order: order, per_page: per_page, page: page})
        ReTout::Users.new.from_response(response)
      end

      # implements http://developer.tout.com/api/touts-api/apimethod/retrieve-tout
      def retrieve_tout(uid)
        response = get("touts/#{uid}")
        ReTout::Tout.new.from_response(response)
      end

      # implements http://developer.tout.com/api/touts-api/apimethod/retrieve-touts-conversation
      def retrieve_tout_conversation(uid)
        response = get("touts/#{uid}/conversation")
        ReTout::Conversation.new(JSON.parse(response.body)["conversation"])
      end

      # implements http://developer.tout.com/api/touts-api/apimethod/retrieve-latest-touts
      def latest_touts(per_page=nil, page=nil)
        response = get("latest", query: {per_page: per_page, page: page})
        ReTout::Touts.new.from_response(response)
      end

      # implements http://developer.tout.com/api/touts-api/apimethod/retrieve-touts-hashtags-and-users-followed-given-user
      # ToDo: is this api call documented in the right place?
      def retrieve_updates(order=nil, per_page=nil, page=nil)
        response = get("me/updates",query: {order: order, per_page: per_page, page: page})
        ReTout::Utils::Collection.new.from_response(response)
      end

      # implements http://developer.tout.com/api/touts-api/apimethod/create-tout
      def create_tout(params={})
        response = if params[:url].nil?
          params[:data] = params[:tout].delete(:data)
          multipart_post("touts", params)
        else
          post("touts", params)
        end

        ReTout::Utils.tout_from_response(response)
      end

      # implements http://developer.tout.com/api/touts-api/apimethod/delete-tout
      def delete_tout(uid)
        response = post("touts/#{uid}")
        raise "Not implemented"
      end

      # implements http://developer.tout.com/api/touts-api/apimethod/tout
      def like_tout(uid)
        response = post("touts/#{uid}/likes")
        raise "Not implemented"
      end

      # implements http://developer.tout.com/api/touts-api/apimethod/share-tout
      def share_tout(uid)
        response = post("touts/#{uid}/share")
        raise "Not implemented"
      end

      # implements http://developer.tout.com/api/touts-api/apimethod/unlike-tout
      def unlike_tout(uid)
        response = post("touts/#{uid}/likes")
        raise "Not implemented"
      end

      # implements http://developer.tout.com/api/touts-api/apimethod/update-touts-text
      def update_tout_text(uid)
        response = put("touts/#{uid}.json?")
        raise "Not implemented"
      end
    end
  end
end
<commit_msg>adjusting to refactor<commit_after>require_relative '../touts'
require_relative '../users'
require_relative '../utils'

# todo: all api modules should simply return responses

module ReTout
  module API
    module Touts

      # http://developer.tout.com/api/touts-api/apimethod/retrieve-list-featured-touts
      def featured_touts(per_page=nil, page=nil)
        response = get("featured", query: {per_page: per_page, page: page})
        ReTout::Touts.new.from_response(response)
      end

      # implements http://developer.tout.com/api/touts-api/apimethod/retrieve-list-users-who-have-liked-tout
      def tout_liked_by(uid, order=nil, per_page=nil, page=nil)
        response = get("touts/#{uid}/liked_by", query: {order: order, per_page: per_page, page: page})
        ReTout::Users.new.from_response(response)
      end

      # implements http://developer.tout.com/api/touts-api/apimethod/retrieve-tout
      def retrieve_tout(uid)
        response = get("touts/#{uid}")
        ReTout::Tout.new.from_response(response)
      end

      # implements http://developer.tout.com/api/touts-api/apimethod/retrieve-touts-conversation
      def retrieve_tout_conversation(uid)
        response = get("touts/#{uid}/conversation")
        ReTout::Conversation.new(JSON.parse(response.body)["conversation"])
      end

      # implements http://developer.tout.com/api/touts-api/apimethod/retrieve-latest-touts
      def latest_touts(per_page=nil, page=nil)
        response = get("latest", query: {per_page: per_page, page: page})
        ReTout::Touts.new.from_response(response)
      end

      # implements http://developer.tout.com/api/touts-api/apimethod/retrieve-touts-hashtags-and-users-followed-given-user
      # ToDo: is this api call documented in the right place?
      def retrieve_updates(order=nil, per_page=nil, page=nil)
        response = get("me/updates",query: {order: order, per_page: per_page, page: page})
        ReTout::Utils::Collection.new.from_response(response)
      end

      # implements http://developer.tout.com/api/touts-api/apimethod/create-tout
      def create_tout(params={})
        response = if params[:url].nil?
          params[:data] = params[:tout].delete(:data)
          multipart_post("touts", params)
        else
          post("touts", params)
        end

        ReTout::Tout.new.from_response(response)
      end

      # implements http://developer.tout.com/api/touts-api/apimethod/delete-tout
      def delete_tout(uid)
        response = post("touts/#{uid}")
        raise "Not implemented"
      end

      # implements http://developer.tout.com/api/touts-api/apimethod/tout
      def like_tout(uid)
        response = post("touts/#{uid}/likes")
        raise "Not implemented"
      end

      # implements http://developer.tout.com/api/touts-api/apimethod/share-tout
      def share_tout(uid)
        response = post("touts/#{uid}/share")
        raise "Not implemented"
      end

      # implements http://developer.tout.com/api/touts-api/apimethod/unlike-tout
      def unlike_tout(uid)
        response = post("touts/#{uid}/likes")
        raise "Not implemented"
      end

      # implements http://developer.tout.com/api/touts-api/apimethod/update-touts-text
      def update_tout_text(uid)
        response = put("touts/#{uid}.json?")
        raise "Not implemented"
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.13094530321046374, 'fraction_numerical': 0.0, 'mean_word_length': 2.876152073732719, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '202549', 'n_tokens_mistral': 2237, 'n_tokens_neox': 2182, 'n_words': 356}