taboola_api 0.1.1 → 0.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c8017c93b8fcd0f4d2be7a9ac58c67b245c3d9f472253beaf67c12688ed57ff0
4
- data.tar.gz: fbe4747b6344732927fe384d8df466d8bef193baa5440a03baf1f8c69748e2f4
3
+ metadata.gz: 61117a9e74b19a41fdef87294884ef1f2999df682c82c0240c47eeedc81498a7
4
+ data.tar.gz: 7f1d05f7534cc8842f574a463389e5c70dbed074162e5b6e33f0805fd04cf66d
5
5
  SHA512:
6
- metadata.gz: 4ea087721692d0f309ea50c98a594038e2858abb07bbfbffec37253c54d0fc9d6438829cf15242df5929aff8c93e90b280541a6986d626a8d2168bc4da8fa7d0
7
- data.tar.gz: ef14758c41af0b780413d5f1893022f123997c0297b61a56755c923fda90aeb73ad864567811192ec62fbeef31309e8306450a88780843b1308717a55bed198a
6
+ metadata.gz: 8a6fb345d613139d0c772ad0aaa56eb632f0a9e40a78091a5935faec6702b4ec902381aa80cf0a471b2da539e56087233913876770d10b149d122964c180793a
7
+ data.tar.gz: 796dab6bd02222bc0e8df2b8f42fa9f630fb812bfe8ca3188c5ffc60270f2c0b965a8172d7b4f8a12e178e2243839ce71d17a4f2f00c64f087593f95f46c6dd0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.4](https://github.com/k0va1/taboola_api/compare/v0.1.3...v0.1.4) (2026-11-23)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * raise typed errors when the access token request fails ([011c01c](https://github.com/k0va1/taboola_api/commit/011c01c5a4aeb0b92d804bc1da121fa83168207b))
9
+
10
+ ## [0.1.3](https://github.com/k0va1/taboola_api/compare/v0.1.2...v0.1.3) (2025-05-18)
11
+
12
+
13
+ ### Features
14
+
15
+ * allow to delete campaign items ([50b2d66](https://github.com/k0va1/taboola_api/commit/50b2d666f82229c49b0381454452a802e42350f2))
16
+
17
+ ## [0.1.2](https://github.com/k0va1/taboola_api/compare/v0.1.1...v0.1.2) (2025-05-18)
18
+
19
+
20
+ ### Features
21
+
22
+ * add realtime stats methods ([3cd5236](https://github.com/k0va1/taboola_api/commit/3cd5236dcb4f9e93f84d81380952db4dae65c25b))
23
+
3
24
  ## [0.1.1](https://github.com/k0va1/taboola_api/compare/taboola_api-v0.1.0...taboola_api/v0.1.1) (2025-05-17)
4
25
 
5
26
 
@@ -9,6 +9,7 @@ module TaboolaApi
9
9
  HOST = "https://backstage.taboola.com/backstage"
10
10
  CURRENT_API_PATH = "api/1.0"
11
11
  DEFAULT_URL = "#{HOST}/#{CURRENT_API_PATH}"
12
+ TOKEN_REJECTED_STATUSES = [400, 401, 403].freeze
12
13
 
13
14
  def initialize(client_id:, client_secret:, access_token:)
14
15
  @client_id = client_id
@@ -64,22 +65,7 @@ module TaboolaApi
64
65
  body = response.body
65
66
  error_message = body.is_a?(Hash) ? body&.dig("message") : body
66
67
 
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)
68
+ raise error_class_for(status).new(error_message || "HTTP #{status}", status, body)
83
69
  end
84
70
 
85
71
  def update_access_token
@@ -91,9 +77,19 @@ module TaboolaApi
91
77
  grant_type: "client_credentials"
92
78
  )
93
79
  end
94
- data = JSON.parse(response.body)
95
80
 
96
- @access_token = data["access_token"]
81
+ status = response.status
82
+ data = parse_token_body(response.body)
83
+ access_token = data["access_token"]
84
+
85
+ unless response.success? && access_token
86
+ klass = TOKEN_REJECTED_STATUSES.include?(status) ? TaboolaApi::AuthenticationError : error_class_for(status)
87
+ message = data["error_description"] || data["error"] || "Access token request failed with HTTP #{status}"
88
+ raise klass.new(message, status, response.body)
89
+ end
90
+
91
+ @connection = nil
92
+ @access_token = access_token
97
93
  end
98
94
 
99
95
  def accounts
@@ -119,5 +115,31 @@ module TaboolaApi
119
115
  def reportings
120
116
  @reportings ||= TaboolaApi::Resources::Reportings.new(self)
121
117
  end
118
+
119
+ private
120
+
121
+ def error_class_for(status)
122
+ case status
123
+ when 401
124
+ TaboolaApi::AuthenticationError
125
+ when 403
126
+ TaboolaApi::AuthorizationError
127
+ when 429
128
+ TaboolaApi::RateLimitError
129
+ when 400..499
130
+ TaboolaApi::InvalidRequestError
131
+ when 500..599
132
+ TaboolaApi::ApiError
133
+ else
134
+ TaboolaApi::Error
135
+ end
136
+ end
137
+
138
+ def parse_token_body(body)
139
+ data = JSON.parse(body.to_s)
140
+ data.is_a?(Hash) ? data : {}
141
+ rescue JSON::ParserError
142
+ {}
143
+ end
122
144
  end
123
145
  end
@@ -20,6 +20,11 @@ module TaboolaApi
20
20
  response = client.request(:post, "#{account_id}/campaigns/#{campaign_id}/items/#{item_id}", params)
21
21
  response.body
22
22
  end
23
+
24
+ def delete(account_id, campaign_id, item_id)
25
+ response = client.request(:delete, "#{account_id}/campaigns/#{campaign_id}/items/#{item_id}")
26
+ response.body
27
+ end
23
28
  end
24
29
  end
25
30
  end
@@ -1,3 +1,3 @@
1
1
  module TaboolaApi
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: taboola_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Koval
@@ -206,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
206
206
  - !ruby/object:Gem::Version
207
207
  version: '0'
208
208
  requirements: []
209
- rubygems_version: 3.6.7
209
+ rubygems_version: 3.6.9
210
210
  specification_version: 4
211
211
  summary: A Ruby client for the Taboola API
212
212
  test_files: []