taboola_api 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +8 -0
- data/LICENSE.txt +21 -0
- data/README.md +131 -0
- data/bin/console +7 -0
- data/lib/taboola_api/client.rb +123 -0
- data/lib/taboola_api/error.rb +22 -0
- data/lib/taboola_api/resources/account.rb +10 -0
- data/lib/taboola_api/resources/base.rb +11 -0
- data/lib/taboola_api/resources/campaign.rb +15 -0
- data/lib/taboola_api/resources/campaign_item.rb +25 -0
- data/lib/taboola_api/resources/motion_ads.rb +48 -0
- data/lib/taboola_api/resources/operations.rb +18 -0
- data/lib/taboola_api/resources/reportings.rb +25 -0
- data/lib/taboola_api/version.rb +3 -0
- data/lib/taboola_api.rb +7 -0
- metadata +212 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA256:
         | 
| 3 | 
            +
              metadata.gz: c8017c93b8fcd0f4d2be7a9ac58c67b245c3d9f472253beaf67c12688ed57ff0
         | 
| 4 | 
            +
              data.tar.gz: fbe4747b6344732927fe384d8df466d8bef193baa5440a03baf1f8c69748e2f4
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: 4ea087721692d0f309ea50c98a594038e2858abb07bbfbffec37253c54d0fc9d6438829cf15242df5929aff8c93e90b280541a6986d626a8d2168bc4da8fa7d0
         | 
| 7 | 
            +
              data.tar.gz: ef14758c41af0b780413d5f1893022f123997c0297b61a56755c923fda90aeb73ad864567811192ec62fbeef31309e8306450a88780843b1308717a55bed198a
         | 
    
        data/CHANGELOG.md
    ADDED
    
    | @@ -0,0 +1,8 @@ | |
| 1 | 
            +
            # Changelog
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            ## [0.1.1](https://github.com/k0va1/taboola_api/compare/taboola_api-v0.1.0...taboola_api/v0.1.1) (2025-05-17)
         | 
| 4 | 
            +
             | 
| 5 | 
            +
             | 
| 6 | 
            +
            ### Features
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            * add realtime stats methods ([3cd5236](https://github.com/k0va1/taboola_api/commit/3cd5236dcb4f9e93f84d81380952db4dae65c25b))
         | 
    
        data/LICENSE.txt
    ADDED
    
    | @@ -0,0 +1,21 @@ | |
| 1 | 
            +
            The MIT License (MIT)
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Copyright (c) 2025 Alex Koval
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Permission is hereby granted, free of charge, to any person obtaining a copy
         | 
| 6 | 
            +
            of this software and associated documentation files (the "Software"), to deal
         | 
| 7 | 
            +
            in the Software without restriction, including without limitation the rights
         | 
| 8 | 
            +
            to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         | 
| 9 | 
            +
            copies of the Software, and to permit persons to whom the Software is
         | 
| 10 | 
            +
            furnished to do so, subject to the following conditions:
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            The above copyright notice and this permission notice shall be included in
         | 
| 13 | 
            +
            all copies or substantial portions of the Software.
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         | 
| 16 | 
            +
            IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         | 
| 17 | 
            +
            FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         | 
| 18 | 
            +
            AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         | 
| 19 | 
            +
            LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         | 
| 20 | 
            +
            OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
         | 
| 21 | 
            +
            THE SOFTWARE.
         | 
    
        data/README.md
    ADDED
    
    | @@ -0,0 +1,131 @@ | |
| 1 | 
            +
            # Taboola API Client
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            A comprehensive Ruby client for interacting with the Taboola API.
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            ## Installation
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            Install the gem and add to the application's Gemfile by executing:
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            ```bash
         | 
| 10 | 
            +
            $ bundle add taboola_api
         | 
| 11 | 
            +
            ```
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            If bundler is not being used to manage dependencies, install the gem by executing:
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            ```bash
         | 
| 16 | 
            +
            $ gem install taboola_api
         | 
| 17 | 
            +
            ```
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            ## Usage
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            ### Creating a Client
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            ```ruby
         | 
| 24 | 
            +
            require 'taboola_api'
         | 
| 25 | 
            +
             | 
| 26 | 
            +
            client = TaboolaApi::Client.new(
         | 
| 27 | 
            +
              client_id: "your-client-id",
         | 
| 28 | 
            +
              client_secret: "your-client-secret",
         | 
| 29 | 
            +
              access_token: "your-access-token"
         | 
| 30 | 
            +
            )
         | 
| 31 | 
            +
            ```
         | 
| 32 | 
            +
             | 
| 33 | 
            +
            ### Accounts
         | 
| 34 | 
            +
             | 
| 35 | 
            +
            ```ruby
         | 
| 36 | 
            +
            # List all allowed accounts
         | 
| 37 | 
            +
            accounts = client.accounts.list_all
         | 
| 38 | 
            +
            puts accounts
         | 
| 39 | 
            +
            ```
         | 
| 40 | 
            +
             | 
| 41 | 
            +
            ### Campaigns
         | 
| 42 | 
            +
             | 
| 43 | 
            +
            ```ruby
         | 
| 44 | 
            +
            # List all campaigns
         | 
| 45 | 
            +
            campaigns = client.campaigns.list_all("account-id")
         | 
| 46 | 
            +
            puts campaigns
         | 
| 47 | 
            +
             | 
| 48 | 
            +
            # Get a specific campaign
         | 
| 49 | 
            +
            campaign = client.campaigns.get("account-id", "campaign-id")
         | 
| 50 | 
            +
            puts campaign
         | 
| 51 | 
            +
            ```
         | 
| 52 | 
            +
             | 
| 53 | 
            +
            ### Campaign Items
         | 
| 54 | 
            +
             | 
| 55 | 
            +
            ```ruby
         | 
| 56 | 
            +
            # List all campaign items
         | 
| 57 | 
            +
            campaign_items = client.campaign_items.list_all("account-id", "campaign-id")
         | 
| 58 | 
            +
            puts campaign_items
         | 
| 59 | 
            +
             | 
| 60 | 
            +
            # Get a specific campaign item
         | 
| 61 | 
            +
            campaign_item = client.campaign_items.get("account-id", "campaign-id", "item-id")
         | 
| 62 | 
            +
            puts campaign_item
         | 
| 63 | 
            +
             | 
| 64 | 
            +
            # Create a new campaign item
         | 
| 65 | 
            +
            new_campaign_item = client.campaign_items.create("account-id", "campaign-id", {
         | 
| 66 | 
            +
              name: "New Campaign Item",
         | 
| 67 | 
            +
              url: "https://example.com"
         | 
| 68 | 
            +
            })
         | 
| 69 | 
            +
            puts new_campaign_item
         | 
| 70 | 
            +
             | 
| 71 | 
            +
            # Update an existing campaign item
         | 
| 72 | 
            +
            updated_campaign_item = client.campaign_items.update("account-id", "campaign-id", "item-id", {
         | 
| 73 | 
            +
              name: "Updated Campaign Item"
         | 
| 74 | 
            +
            })
         | 
| 75 | 
            +
            puts updated_campaign_item
         | 
| 76 | 
            +
            ```
         | 
| 77 | 
            +
             | 
| 78 | 
            +
            ### Motion Ads
         | 
| 79 | 
            +
             | 
| 80 | 
            +
            ```ruby
         | 
| 81 | 
            +
            # List all motion ads
         | 
| 82 | 
            +
            motion_ads = client.motion_ads.list_all("account-id", "campaign-id")
         | 
| 83 | 
            +
            puts motion_ads
         | 
| 84 | 
            +
             | 
| 85 | 
            +
            # Get a specific motion ad
         | 
| 86 | 
            +
            motion_ad = client.motion_ads.get("account-id", "campaign-id", "item-id")
         | 
| 87 | 
            +
            puts motion_ad
         | 
| 88 | 
            +
             | 
| 89 | 
            +
            # Create a new motion ad
         | 
| 90 | 
            +
            video_file = File.open("path/to/video.mp4")
         | 
| 91 | 
            +
            fallback_file = File.open("path/to/fallback.jpg")
         | 
| 92 | 
            +
            new_motion_ad = client.motion_ads.create("account-id", "campaign-id", video_file: video_file, fallback_file: fallback_file, {
         | 
| 93 | 
            +
              name: "New Motion Ad"
         | 
| 94 | 
            +
            })
         | 
| 95 | 
            +
            puts new_motion_ad
         | 
| 96 | 
            +
             | 
| 97 | 
            +
            # Update an existing motion ad
         | 
| 98 | 
            +
            updated_motion_ad = client.motion_ads.update("account-id", "campaign-id", "item-id", {
         | 
| 99 | 
            +
              name: "Updated Motion Ad"
         | 
| 100 | 
            +
            })
         | 
| 101 | 
            +
            puts updated_motion_ad
         | 
| 102 | 
            +
            ```
         | 
| 103 | 
            +
             | 
| 104 | 
            +
            ### Operations
         | 
| 105 | 
            +
             | 
| 106 | 
            +
            ```ruby
         | 
| 107 | 
            +
            # Upload an image
         | 
| 108 | 
            +
            image_file = File.open("path/to/image.jpg")
         | 
| 109 | 
            +
            uploaded_image = client.operations.upload_image(image_file)
         | 
| 110 | 
            +
            puts uploaded_image
         | 
| 111 | 
            +
            ```
         | 
| 112 | 
            +
             | 
| 113 | 
            +
            ### Reportings
         | 
| 114 | 
            +
             | 
| 115 | 
            +
            ```ruby
         | 
| 116 | 
            +
            # Get top campaign content report
         | 
| 117 | 
            +
            report = client.reportings.top_campaign_content_report(
         | 
| 118 | 
            +
              account_id: "account-id",
         | 
| 119 | 
            +
              start_date: "2023-01-01",
         | 
| 120 | 
            +
              end_date: "2023-01-31"
         | 
| 121 | 
            +
            )
         | 
| 122 | 
            +
            puts report
         | 
| 123 | 
            +
            ```
         | 
| 124 | 
            +
             | 
| 125 | 
            +
            ## Development
         | 
| 126 | 
            +
             | 
| 127 | 
            +
            After checking out the repo, run `make install` to install dependencies. Then, run `make test` to run the tests. You can also run `bin/console` for an interactive prompt.
         | 
| 128 | 
            +
             | 
| 129 | 
            +
            ## License
         | 
| 130 | 
            +
             | 
| 131 | 
            +
            The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
         | 
    
        data/bin/console
    ADDED
    
    
| @@ -0,0 +1,123 @@ | |
| 1 | 
            +
            require "faraday"
         | 
| 2 | 
            +
            require "faraday/multipart"
         | 
| 3 | 
            +
            require "faraday/follow_redirects"
         | 
| 4 | 
            +
            require "faraday/retry"
         | 
| 5 | 
            +
            require "taboola_api/error"
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            module TaboolaApi
         | 
| 8 | 
            +
              class Client
         | 
| 9 | 
            +
                HOST = "https://backstage.taboola.com/backstage"
         | 
| 10 | 
            +
                CURRENT_API_PATH = "api/1.0"
         | 
| 11 | 
            +
                DEFAULT_URL = "#{HOST}/#{CURRENT_API_PATH}"
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                def initialize(client_id:, client_secret:, access_token:)
         | 
| 14 | 
            +
                  @client_id = client_id
         | 
| 15 | 
            +
                  @client_secret = client_secret
         | 
| 16 | 
            +
                  @access_token = access_token
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                def connection
         | 
| 20 | 
            +
                  @connection ||= Faraday.new(url: DEFAULT_URL) do |conn|
         | 
| 21 | 
            +
                    conn.headers["Authorization"] = "Bearer #{@access_token}"
         | 
| 22 | 
            +
                    conn.headers["Content-Type"] = "application/json"
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                    conn.options.timeout = 60
         | 
| 25 | 
            +
                    conn.options.open_timeout = 30
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                    conn.request :multipart
         | 
| 28 | 
            +
                    conn.use Faraday::FollowRedirects::Middleware
         | 
| 29 | 
            +
                    conn.use Faraday::Retry::Middleware, max: 3
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                    conn.response :json
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                    conn.adapter Faraday.default_adapter
         | 
| 34 | 
            +
                  end
         | 
| 35 | 
            +
                end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                def request(method, path, params = {}, headers = {})
         | 
| 38 | 
            +
                  url = File.join(DEFAULT_URL, path)
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                  response = connection.run_request(method, url, nil, headers) do |req|
         | 
| 41 | 
            +
                    case method
         | 
| 42 | 
            +
                    when :get, :delete
         | 
| 43 | 
            +
                      req.params = params
         | 
| 44 | 
            +
                    when :post, :put
         | 
| 45 | 
            +
                      if headers["Content-Type"] == "multipart/form-data"
         | 
| 46 | 
            +
                        req.options.timeout = 120
         | 
| 47 | 
            +
                        req.body = {}
         | 
| 48 | 
            +
                        params.each do |key, value|
         | 
| 49 | 
            +
                          req.body[key.to_sym] = value
         | 
| 50 | 
            +
                        end
         | 
| 51 | 
            +
                      else
         | 
| 52 | 
            +
                        req.body = JSON.generate(params) unless params.empty?
         | 
| 53 | 
            +
                      end
         | 
| 54 | 
            +
                    end
         | 
| 55 | 
            +
                  end
         | 
| 56 | 
            +
             | 
| 57 | 
            +
                  handle_response(response)
         | 
| 58 | 
            +
                end
         | 
| 59 | 
            +
             | 
| 60 | 
            +
                def handle_response(response)
         | 
| 61 | 
            +
                  return response if response.success?
         | 
| 62 | 
            +
             | 
| 63 | 
            +
                  status = response.status
         | 
| 64 | 
            +
                  body = response.body
         | 
| 65 | 
            +
                  error_message = body.is_a?(Hash) ? body&.dig("message") : body
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                  klass = case status
         | 
| 68 | 
            +
                  when 401
         | 
| 69 | 
            +
                    TaboolaApi::AuthenticationError
         | 
| 70 | 
            +
                  when 403
         | 
| 71 | 
            +
                    TaboolaApi::AuthorizationError
         | 
| 72 | 
            +
                  when 429
         | 
| 73 | 
            +
                    TaboolaApi::RateLimitError
         | 
| 74 | 
            +
                  when 400..499
         | 
| 75 | 
            +
                    TaboolaApi::InvalidRequestError
         | 
| 76 | 
            +
                  when 500..599
         | 
| 77 | 
            +
                    TaboolaApi::ApiError
         | 
| 78 | 
            +
                  else
         | 
| 79 | 
            +
                    TaboolaApi::Error
         | 
| 80 | 
            +
                  end
         | 
| 81 | 
            +
             | 
| 82 | 
            +
                  raise klass.new(error_message || "HTTP #{status}", status, body)
         | 
| 83 | 
            +
                end
         | 
| 84 | 
            +
             | 
| 85 | 
            +
                def update_access_token
         | 
| 86 | 
            +
                  response = Faraday.post("#{HOST}/oauth/token") do |req|
         | 
| 87 | 
            +
                    req.headers["Content-Type"] = "application/x-www-form-urlencoded"
         | 
| 88 | 
            +
                    req.body = URI.encode_www_form(
         | 
| 89 | 
            +
                      client_id: @client_id,
         | 
| 90 | 
            +
                      client_secret: @client_secret,
         | 
| 91 | 
            +
                      grant_type: "client_credentials"
         | 
| 92 | 
            +
                    )
         | 
| 93 | 
            +
                  end
         | 
| 94 | 
            +
                  data = JSON.parse(response.body)
         | 
| 95 | 
            +
             | 
| 96 | 
            +
                  @access_token = data["access_token"]
         | 
| 97 | 
            +
                end
         | 
| 98 | 
            +
             | 
| 99 | 
            +
                def accounts
         | 
| 100 | 
            +
                  @accounts ||= TaboolaApi::Resources::Account.new(self)
         | 
| 101 | 
            +
                end
         | 
| 102 | 
            +
             | 
| 103 | 
            +
                def campaigns
         | 
| 104 | 
            +
                  @campaigns ||= TaboolaApi::Resources::Campaign.new(self)
         | 
| 105 | 
            +
                end
         | 
| 106 | 
            +
             | 
| 107 | 
            +
                def campaign_items
         | 
| 108 | 
            +
                  @campaign_items ||= TaboolaApi::Resources::CampaignItem.new(self)
         | 
| 109 | 
            +
                end
         | 
| 110 | 
            +
             | 
| 111 | 
            +
                def motion_ads
         | 
| 112 | 
            +
                  @motion_ads ||= TaboolaApi::Resources::MotionAds.new(self)
         | 
| 113 | 
            +
                end
         | 
| 114 | 
            +
             | 
| 115 | 
            +
                def operations
         | 
| 116 | 
            +
                  @operations ||= TaboolaApi::Resources::Operations.new(self)
         | 
| 117 | 
            +
                end
         | 
| 118 | 
            +
             | 
| 119 | 
            +
                def reportings
         | 
| 120 | 
            +
                  @reportings ||= TaboolaApi::Resources::Reportings.new(self)
         | 
| 121 | 
            +
                end
         | 
| 122 | 
            +
              end
         | 
| 123 | 
            +
            end
         | 
| @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            module TaboolaApi
         | 
| 2 | 
            +
              class Error < StandardError
         | 
| 3 | 
            +
                attr_reader :status_code
         | 
| 4 | 
            +
                attr_reader :body
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                def initialize(message = nil, status_code = nil, body = nil)
         | 
| 7 | 
            +
                  @status_code = status_code
         | 
| 8 | 
            +
                  @body = body
         | 
| 9 | 
            +
                  super(message)
         | 
| 10 | 
            +
                end
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              class AuthenticationError < Error; end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              class AuthorizationError < Error; end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
              class InvalidRequestError < Error; end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
              class ApiError < Error; end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              class RateLimitError < Error; end
         | 
| 22 | 
            +
            end
         | 
| @@ -0,0 +1,15 @@ | |
| 1 | 
            +
            module TaboolaApi
         | 
| 2 | 
            +
              module Resources
         | 
| 3 | 
            +
                class Campaign < Base
         | 
| 4 | 
            +
                  def list_all(account_id, params: {})
         | 
| 5 | 
            +
                    response = client.request(:get, "#{account_id}/campaigns", params)
         | 
| 6 | 
            +
                    response.body
         | 
| 7 | 
            +
                  end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                  def get(account_id, campaign_id)
         | 
| 10 | 
            +
                    response = client.request(:get, "#{account_id}/campaigns/#{campaign_id}")
         | 
| 11 | 
            +
                    response.body
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
                end
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
            end
         | 
| @@ -0,0 +1,25 @@ | |
| 1 | 
            +
            module TaboolaApi
         | 
| 2 | 
            +
              module Resources
         | 
| 3 | 
            +
                class CampaignItem < Base
         | 
| 4 | 
            +
                  def get(account_id, campaign_id, item_id)
         | 
| 5 | 
            +
                    response = client.request(:get, "#{account_id}/campaigns/#{campaign_id}/items/#{item_id}")
         | 
| 6 | 
            +
                    response.body
         | 
| 7 | 
            +
                  end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                  def list_all(account_id, campaign_id, params: {})
         | 
| 10 | 
            +
                    response = client.request(:get, "#{account_id}/campaigns/#{campaign_id}/items", params)
         | 
| 11 | 
            +
                    response.body
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                  def create(account_id, campaign_id, params: {})
         | 
| 15 | 
            +
                    response = client.request(:post, "#{account_id}/campaigns/#{campaign_id}/items", params)
         | 
| 16 | 
            +
                    response.body
         | 
| 17 | 
            +
                  end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                  def update(account_id, campaign_id, item_id, params: {})
         | 
| 20 | 
            +
                    response = client.request(:post, "#{account_id}/campaigns/#{campaign_id}/items/#{item_id}", params)
         | 
| 21 | 
            +
                    response.body
         | 
| 22 | 
            +
                  end
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
            end
         | 
| @@ -0,0 +1,48 @@ | |
| 1 | 
            +
            require "mime/types"
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module TaboolaApi
         | 
| 4 | 
            +
              module Resources
         | 
| 5 | 
            +
                class MotionAds < Base
         | 
| 6 | 
            +
                  def get(account_id, campaign_id, item_id)
         | 
| 7 | 
            +
                    response = client.request(:get, "#{account_id}/campaigns/#{campaign_id}/performance-video/items/#{item_id}")
         | 
| 8 | 
            +
                    response.body
         | 
| 9 | 
            +
                  end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                  def list_all(account_id, campaign_id, params: {})
         | 
| 12 | 
            +
                    response = client.request(:get, "#{account_id}/campaigns/#{campaign_id}/performance-video/items", params)
         | 
| 13 | 
            +
                    response.body
         | 
| 14 | 
            +
                  end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                  def create(account_id, campaign_id, video_file:, fallback_file:, params: {})
         | 
| 17 | 
            +
                    raise ArgumentError, "Video file must be provided" unless video_file.is_a?(File) || video_file.is_a?(Tempfile)
         | 
| 18 | 
            +
                    raise ArgumentError, "Fallback image file must be provided" unless fallback_file.is_a?(File) || fallback_file.is_a?(Tempfile)
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                    video_mime_type = MIME::Types.type_for(video_file.path).first.to_s
         | 
| 21 | 
            +
                    fallback_mime_type = MIME::Types.type_for(fallback_file.path).first.to_s
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                    payload = {
         | 
| 24 | 
            +
                      new_item: Faraday::Multipart::ParamPart.new(
         | 
| 25 | 
            +
                        JSON.generate(params),
         | 
| 26 | 
            +
                        "application/json"
         | 
| 27 | 
            +
                      ),
         | 
| 28 | 
            +
                      video_file: Faraday::Multipart::FilePart.new(
         | 
| 29 | 
            +
                        video_file,
         | 
| 30 | 
            +
                        video_mime_type
         | 
| 31 | 
            +
                      ),
         | 
| 32 | 
            +
                      fallback_file: Faraday::Multipart::FilePart.new(
         | 
| 33 | 
            +
                        fallback_file,
         | 
| 34 | 
            +
                        fallback_mime_type
         | 
| 35 | 
            +
                      )
         | 
| 36 | 
            +
                    }
         | 
| 37 | 
            +
                    headers = {"Content-Type" => "multipart/form-data"}
         | 
| 38 | 
            +
                    response = client.request(:post, "#{account_id}/campaigns/#{campaign_id}/performance-video/items", payload, headers)
         | 
| 39 | 
            +
                    response.body
         | 
| 40 | 
            +
                  end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                  def update(account_id, campaign_id, item_id, params: {})
         | 
| 43 | 
            +
                    response = client.request(:put, "#{account_id}/campaigns/#{campaign_id}/performance-video/items/#{item_id}", params)
         | 
| 44 | 
            +
                    response.body
         | 
| 45 | 
            +
                  end
         | 
| 46 | 
            +
                end
         | 
| 47 | 
            +
              end
         | 
| 48 | 
            +
            end
         | 
| @@ -0,0 +1,18 @@ | |
| 1 | 
            +
            require "mime/types"
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module TaboolaApi
         | 
| 4 | 
            +
              module Resources
         | 
| 5 | 
            +
                class Operations < Base
         | 
| 6 | 
            +
                  def upload_image(file)
         | 
| 7 | 
            +
                    raise ArgumentError, "File must be provided" unless file.is_a?(File) || file.is_a?(Tempfile)
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                    mime_type = MIME::Types.type_for(file.path).first.to_s
         | 
| 10 | 
            +
                    payload = {
         | 
| 11 | 
            +
                      file: Faraday::Multipart::FilePart.new(file, mime_type)
         | 
| 12 | 
            +
                    }
         | 
| 13 | 
            +
                    response = client.request(:post, "operations/upload-image", payload, "Content-Type" => "multipart/form-data")
         | 
| 14 | 
            +
                    response.body
         | 
| 15 | 
            +
                  end
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
            end
         | 
| @@ -0,0 +1,25 @@ | |
| 1 | 
            +
            module TaboolaApi
         | 
| 2 | 
            +
              module Resources
         | 
| 3 | 
            +
                class Reportings < Base
         | 
| 4 | 
            +
                  def top_campaign_content_report(account_id:, start_date:, end_date:, campaign: nil)
         | 
| 5 | 
            +
                    params = {start_date: start_date, end_date: end_date, campaign: campaign}.compact
         | 
| 6 | 
            +
                    response = client.request(:get, "#{account_id}/reports/top-campaign-content/dimensions/item_breakdown", params)
         | 
| 7 | 
            +
                    response.body
         | 
| 8 | 
            +
                  end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                  def realtime_campaign_report(account_id:, dimension:, params: {})
         | 
| 11 | 
            +
                    raise ArgumentError, "start_date and end_date params are required" unless params[:start_date] && params[:end_date]
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                    response = client.request(:get, "#{account_id}/reports/reports/realtime-campaign-summary/dimensions/#{dimension}", params)
         | 
| 14 | 
            +
                    response.body
         | 
| 15 | 
            +
                  end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                  def realtime_ads_report(account_id:, dimension:, params: {})
         | 
| 18 | 
            +
                    raise ArgumentError, "start_date and end_date params are required" unless params[:start_date] && params[:end_date]
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                    response = client.request(:get, "#{account_id}/reports/reports/realtime-top-campaign-content/dimensions/#{dimension}", params)
         | 
| 21 | 
            +
                    response.body
         | 
| 22 | 
            +
                  end
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
            end
         | 
    
        data/lib/taboola_api.rb
    ADDED
    
    
    
        metadata
    ADDED
    
    | @@ -0,0 +1,212 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: taboola_api
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.1.1
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Alex Koval
         | 
| 8 | 
            +
            bindir: exe
         | 
| 9 | 
            +
            cert_chain: []
         | 
| 10 | 
            +
            date: 1980-01-02 00:00:00.000000000 Z
         | 
| 11 | 
            +
            dependencies:
         | 
| 12 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 13 | 
            +
              name: faraday
         | 
| 14 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 15 | 
            +
                requirements:
         | 
| 16 | 
            +
                - - "~>"
         | 
| 17 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 18 | 
            +
                    version: '2.0'
         | 
| 19 | 
            +
              type: :runtime
         | 
| 20 | 
            +
              prerelease: false
         | 
| 21 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 22 | 
            +
                requirements:
         | 
| 23 | 
            +
                - - "~>"
         | 
| 24 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 25 | 
            +
                    version: '2.0'
         | 
| 26 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 27 | 
            +
              name: faraday-multipart
         | 
| 28 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 29 | 
            +
                requirements:
         | 
| 30 | 
            +
                - - "~>"
         | 
| 31 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 32 | 
            +
                    version: '1.0'
         | 
| 33 | 
            +
              type: :runtime
         | 
| 34 | 
            +
              prerelease: false
         | 
| 35 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 36 | 
            +
                requirements:
         | 
| 37 | 
            +
                - - "~>"
         | 
| 38 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 39 | 
            +
                    version: '1.0'
         | 
| 40 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 41 | 
            +
              name: faraday-follow_redirects
         | 
| 42 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 43 | 
            +
                requirements:
         | 
| 44 | 
            +
                - - "~>"
         | 
| 45 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 46 | 
            +
                    version: '0.3'
         | 
| 47 | 
            +
              type: :runtime
         | 
| 48 | 
            +
              prerelease: false
         | 
| 49 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 50 | 
            +
                requirements:
         | 
| 51 | 
            +
                - - "~>"
         | 
| 52 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 53 | 
            +
                    version: '0.3'
         | 
| 54 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 55 | 
            +
              name: faraday-retry
         | 
| 56 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 57 | 
            +
                requirements:
         | 
| 58 | 
            +
                - - "~>"
         | 
| 59 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 60 | 
            +
                    version: '2.0'
         | 
| 61 | 
            +
              type: :runtime
         | 
| 62 | 
            +
              prerelease: false
         | 
| 63 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 64 | 
            +
                requirements:
         | 
| 65 | 
            +
                - - "~>"
         | 
| 66 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 67 | 
            +
                    version: '2.0'
         | 
| 68 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 69 | 
            +
              name: mime-types
         | 
| 70 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 71 | 
            +
                requirements:
         | 
| 72 | 
            +
                - - "~>"
         | 
| 73 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 74 | 
            +
                    version: '3.1'
         | 
| 75 | 
            +
              type: :runtime
         | 
| 76 | 
            +
              prerelease: false
         | 
| 77 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 78 | 
            +
                requirements:
         | 
| 79 | 
            +
                - - "~>"
         | 
| 80 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 81 | 
            +
                    version: '3.1'
         | 
| 82 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 83 | 
            +
              name: zeitwerk
         | 
| 84 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 85 | 
            +
                requirements:
         | 
| 86 | 
            +
                - - "~>"
         | 
| 87 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 88 | 
            +
                    version: '2.6'
         | 
| 89 | 
            +
              type: :runtime
         | 
| 90 | 
            +
              prerelease: false
         | 
| 91 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 92 | 
            +
                requirements:
         | 
| 93 | 
            +
                - - "~>"
         | 
| 94 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 95 | 
            +
                    version: '2.6'
         | 
| 96 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 97 | 
            +
              name: bundler
         | 
| 98 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 99 | 
            +
                requirements:
         | 
| 100 | 
            +
                - - "~>"
         | 
| 101 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 102 | 
            +
                    version: '2.0'
         | 
| 103 | 
            +
              type: :development
         | 
| 104 | 
            +
              prerelease: false
         | 
| 105 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 106 | 
            +
                requirements:
         | 
| 107 | 
            +
                - - "~>"
         | 
| 108 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 109 | 
            +
                    version: '2.0'
         | 
| 110 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 111 | 
            +
              name: rake
         | 
| 112 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 113 | 
            +
                requirements:
         | 
| 114 | 
            +
                - - "~>"
         | 
| 115 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 116 | 
            +
                    version: '13.0'
         | 
| 117 | 
            +
              type: :development
         | 
| 118 | 
            +
              prerelease: false
         | 
| 119 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 120 | 
            +
                requirements:
         | 
| 121 | 
            +
                - - "~>"
         | 
| 122 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 123 | 
            +
                    version: '13.0'
         | 
| 124 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 125 | 
            +
              name: rspec
         | 
| 126 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 127 | 
            +
                requirements:
         | 
| 128 | 
            +
                - - "~>"
         | 
| 129 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 130 | 
            +
                    version: '3.0'
         | 
| 131 | 
            +
              type: :development
         | 
| 132 | 
            +
              prerelease: false
         | 
| 133 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 134 | 
            +
                requirements:
         | 
| 135 | 
            +
                - - "~>"
         | 
| 136 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 137 | 
            +
                    version: '3.0'
         | 
| 138 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 139 | 
            +
              name: standard
         | 
| 140 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 141 | 
            +
                requirements:
         | 
| 142 | 
            +
                - - '='
         | 
| 143 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 144 | 
            +
                    version: 1.49.0
         | 
| 145 | 
            +
              type: :development
         | 
| 146 | 
            +
              prerelease: false
         | 
| 147 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 148 | 
            +
                requirements:
         | 
| 149 | 
            +
                - - '='
         | 
| 150 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 151 | 
            +
                    version: 1.49.0
         | 
| 152 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 153 | 
            +
              name: webmock
         | 
| 154 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 155 | 
            +
                requirements:
         | 
| 156 | 
            +
                - - "~>"
         | 
| 157 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 158 | 
            +
                    version: '3.0'
         | 
| 159 | 
            +
              type: :development
         | 
| 160 | 
            +
              prerelease: false
         | 
| 161 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 162 | 
            +
                requirements:
         | 
| 163 | 
            +
                - - "~>"
         | 
| 164 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 165 | 
            +
                    version: '3.0'
         | 
| 166 | 
            +
            description: A comprehensive Ruby client for interacting with the Taboola API
         | 
| 167 | 
            +
            email:
         | 
| 168 | 
            +
            - al3xander.koval@gmail.com
         | 
| 169 | 
            +
            executables: []
         | 
| 170 | 
            +
            extensions: []
         | 
| 171 | 
            +
            extra_rdoc_files: []
         | 
| 172 | 
            +
            files:
         | 
| 173 | 
            +
            - CHANGELOG.md
         | 
| 174 | 
            +
            - LICENSE.txt
         | 
| 175 | 
            +
            - README.md
         | 
| 176 | 
            +
            - bin/console
         | 
| 177 | 
            +
            - lib/taboola_api.rb
         | 
| 178 | 
            +
            - lib/taboola_api/client.rb
         | 
| 179 | 
            +
            - lib/taboola_api/error.rb
         | 
| 180 | 
            +
            - lib/taboola_api/resources/account.rb
         | 
| 181 | 
            +
            - lib/taboola_api/resources/base.rb
         | 
| 182 | 
            +
            - lib/taboola_api/resources/campaign.rb
         | 
| 183 | 
            +
            - lib/taboola_api/resources/campaign_item.rb
         | 
| 184 | 
            +
            - lib/taboola_api/resources/motion_ads.rb
         | 
| 185 | 
            +
            - lib/taboola_api/resources/operations.rb
         | 
| 186 | 
            +
            - lib/taboola_api/resources/reportings.rb
         | 
| 187 | 
            +
            - lib/taboola_api/version.rb
         | 
| 188 | 
            +
            homepage: https://github.com/k0va1/taboola_api
         | 
| 189 | 
            +
            licenses:
         | 
| 190 | 
            +
            - MIT
         | 
| 191 | 
            +
            metadata:
         | 
| 192 | 
            +
              homepage_uri: https://github.com/k0va1/taboola_api
         | 
| 193 | 
            +
              source_code_uri: https://github.com/k0va1/taboola_api
         | 
| 194 | 
            +
              changelog_uri: https://github.com/k0va1/taboola_api/blob/main/CHANGELOG.md
         | 
| 195 | 
            +
            rdoc_options: []
         | 
| 196 | 
            +
            require_paths:
         | 
| 197 | 
            +
            - lib
         | 
| 198 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 199 | 
            +
              requirements:
         | 
| 200 | 
            +
              - - ">="
         | 
| 201 | 
            +
                - !ruby/object:Gem::Version
         | 
| 202 | 
            +
                  version: 3.2.0
         | 
| 203 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 204 | 
            +
              requirements:
         | 
| 205 | 
            +
              - - ">="
         | 
| 206 | 
            +
                - !ruby/object:Gem::Version
         | 
| 207 | 
            +
                  version: '0'
         | 
| 208 | 
            +
            requirements: []
         | 
| 209 | 
            +
            rubygems_version: 3.6.7
         | 
| 210 | 
            +
            specification_version: 4
         | 
| 211 | 
            +
            summary: A Ruby client for the Taboola API
         | 
| 212 | 
            +
            test_files: []
         |