<commit_before>package facebook4s.api

import facebook4s.request.{FacebookBatchRequestBuilder, FacebookGetRequest}
import http.client.request.HttpRequestHelpers

object FacebookMarketingApi extends HttpRequestHelpers {

  import FacebookApiConstants._

  implicit class FacebookAdsInsightsApiImplicits(requestBuilder: FacebookBatchRequestBuilder) {
    def adInsights(
      adId:        String,
      metric:      Option[String]      = None,
      period:      Option[String]      = None,
      since:       Option[Long]        = None,
      until:       Option[Long]        = None,
      accessToken: Option[AccessToken] = None) = {
      val relativeUrl = buildRelativeUrl(adId, "insights", metric)
      val modifiers = buildModifiers("period" → period)
      requestBuilder.add(FacebookGetRequest(relativeUrl, None, Seq.empty, modifiers, accessToken), since, until)
    }

    def adAccount(
      adAccountId: String,
      accessToken: Option[AccessToken] = None) = {
      val relativeUrl = buildRelativeUrl(s"act_$adAccountId")
      val modifiers = buildModifiers(
        "fields" → Some("name,age,business,created_time,currency,timezone_name"))
      requestBuilder.add(FacebookGetRequest(relativeUrl, None, Seq.empty, modifiers, accessToken), paginated = true)
    }

    def adCampaigns(
      adAccountId: String,
      limit:       Option[Int]         = None,
      accessToken: Option[AccessToken] = None) = {
      val relativeUrl = buildRelativeUrl(s"act_$adAccountId/campaigns")
      val modifiers = buildModifiers(
        "limit" → limit,
        "fields" → Some("id,name,account_id,buying_type,adlabels,objective,start_time,stop_time"))
      requestBuilder.add(FacebookGetRequest(relativeUrl, None, Seq.empty, modifiers, accessToken), paginated = true)
    }

    def adCampaign(
      adCampaignId: String,
      accessToken:  Option[AccessToken] = None) = {
      val relativeUrl = buildRelativeUrl(adCampaignId)
      val modifiers = buildModifiers("fields" → Some("name,created_time"))
      requestBuilder.add(FacebookGetRequest(relativeUrl, None, Seq.empty, modifiers, accessToken), paginated = false)
    }
  }
}<commit_msg>Switch adCampaigns call to use v2.6 of the FB API (deprecation).<commit_after>package facebook4s.api

import facebook4s.request.{FacebookBatchRequestBuilder, FacebookGetRequest}
import http.client.request.HttpRequestHelpers

object FacebookMarketingApi extends HttpRequestHelpers {

  import FacebookApiConstants._

  implicit class FacebookAdsInsightsApiImplicits(requestBuilder: FacebookBatchRequestBuilder) {
    def adInsights(
      adId:        String,
      metric:      Option[String]      = None,
      period:      Option[String]      = None,
      since:       Option[Long]        = None,
      until:       Option[Long]        = None,
      accessToken: Option[AccessToken] = None) = {
      val relativeUrl = buildRelativeUrl(adId, "insights", metric)
      val modifiers = buildModifiers("period" → period)
      requestBuilder.add(FacebookGetRequest(relativeUrl, None, Seq.empty, modifiers, accessToken), since, until)
    }

    def adAccount(
      adAccountId: String,
      accessToken: Option[AccessToken] = None) = {
      val relativeUrl = buildRelativeUrl(s"act_$adAccountId")
      val modifiers = buildModifiers(
        "fields" → Some("name,age,business,created_time,currency,timezone_name"))
      requestBuilder.add(FacebookGetRequest(relativeUrl, None, Seq.empty, modifiers, accessToken), paginated = true)
    }

    def adCampaigns(
      adAccountId: String,
      limit:       Option[Int]         = None,
      accessToken: Option[AccessToken] = None) = {
      val relativeUrl = buildRelativeUrl(s"v2.6/act_$adAccountId/campaigns")
      val modifiers = buildModifiers(
        "limit" → limit,
        "fields" → Some("id,name,account_id,buying_type,adlabels,objective,start_time,stop_time"))
      requestBuilder.add(FacebookGetRequest(relativeUrl, None, Seq.empty, modifiers, accessToken), paginated = true)
    }

    def adCampaign(
      adCampaignId: String,
      accessToken:  Option[AccessToken] = None) = {
      val relativeUrl = buildRelativeUrl(adCampaignId)
      val modifiers = buildModifiers("fields" → Some("name,created_time"))
      requestBuilder.add(FacebookGetRequest(relativeUrl, None, Seq.empty, modifiers, accessToken), paginated = false)
    }
  }
}
{'fraction_non_alphanumeric': 0.0989010989010989, 'fraction_numerical': 0.0018315018315018315, 'mean_word_length': 3.6232804232804234, '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': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6000497', 'n_tokens_mistral': 1285, 'n_tokens_neox': 1262, 'n_words': 264}