<commit_before>module GoogleCalendarApiV2
  class Event
    include Base

    attr_reader :client, :connection

    def initialize(client)
      @client = client
      @connection = client.discovered_api('calendar', 'v3')
    end

    def list(calendar)
    end

    def find(calendar, query)

    end

    def create(calendar, attrs)
      @client.execute(api_method: @connection.events.insert, parameters: { 'calendarId' => calendar.id }, body: [JSON.dump(attrs)], headers: {'Content-Type' => 'application/json'})
    end

    def update(calendar, event_id, attrs)
      @client.execute(api_method: @connection.events.insert, parameters: { 'calendarId' => calendar.id, 'eventId' => event_id }, body: [JSON.dump(attrs)], headers: {'Content-Type' => 'application/json'})
    end
  end
end<commit_msg>building list and find methods<commit_after>module GoogleCalendarApiV2
  class Event
    include Base

    attr_reader :client, :connection

    def initialize(client)
      @client = client
      @connection = client.discovered_api('calendar', 'v3')
    end

    def list(calendar)
      list = @client.execute(api_method: @connection.events.list, parameters: { 'calendarId' => calendar.id })
      list.data.items
    end

    def find(calendar, query)
      list.each do |event|
        if event.summary == query
          return @event = event
        end
      end
      @event
    end

    def create(calendar, attrs)
      @client.execute(api_method: @connection.events.insert, parameters: { 'calendarId' => calendar.id }, body: [JSON.dump(attrs)], headers: {'Content-Type' => 'application/json'})
    end

    def update(calendar, event_id, attrs)
      @client.execute(api_method: @connection.events.update, parameters: { 'calendarId' => calendar.id, 'eventId' => event_id }, body: [JSON.dump(attrs)], headers: {'Content-Type' => 'application/json'})
    end
  end
end
{'fraction_non_alphanumeric': 0.13159296750133193, 'fraction_numerical': 0.002131060202450719, 'mean_word_length': 3.4397163120567376, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, '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': '1767897', 'n_tokens_mistral': 567, 'n_tokens_neox': 553, 'n_words': 136}