urlpipe 0.2.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4bfaf07a0fb70edbee60c2467ec2f6123bc8c879c4eced1567f9ecbd51cf26d7
4
- data.tar.gz: fc6ad0f280bc76a769a38383b4848ab98cf578360a7cbbb74a793dd94910571f
3
+ metadata.gz: 53c82122c9c87b3c9d3d8e38f7778ecf84f5fd3ca00ebf3db1e5e00abcf5b43c
4
+ data.tar.gz: 178ba8a0c503ee130a32a6203675d92b14a17a63a96ca8caa37ae8f3d831a156
5
5
  SHA512:
6
- metadata.gz: 6f8edccde9e41a55d017aa54c7d9da319212b6c074f37cc405d3efa37387345dc1ee956d690bf9d12cf840dbd5721f962cf233e491981b31f404836e8a58e0f5
7
- data.tar.gz: fd35420d0c9087f63e65431b3c06092619201b538569a7d608b9c89559d6c7ba038a9712f16d6b5beae6563fa3d37002405154c04d66ea07c9686ca44c7930b9
6
+ metadata.gz: 658218d2666297e85fb0799ec523f03dc202a2fa8acb62cb9a39d199863c3cc4c057c72e44e834d1614f6c78c16897e4042f60a65c6562061300695f619caf9b
7
+ data.tar.gz: 976a9cc22127aac89c5d7bc8ff0d59cf9f100cb3050ed5338ddd86209263684e2ff8e002940e971ca7241b0998ab84177302821c609eb7b193f23214ab65fa5f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.1
4
+
5
+ - `QuotaExceededError` and `ConcurrencyLimitError` carry `next_plan` and `upgrade_url`: the plan that lifts the limit, as a Hash with `name`, `monthly_price_cents`, `monthly_credits` and `max_concurrent_requests`, and the page to upgrade on. Both are `nil` when there is no plan to move to.
6
+
3
7
  ## 0.2.0
4
8
 
5
9
  - `pdf` returns the whole rendered page as a PDF (`POST /pdf`): a `Urlpipe::Pdf` with the decoded bytes, `mime_type`, `result_url` and `save`. `pdf_options:` choose the paper, orientation, margins, scale, backgrounds, the print or screen stylesheet and `single_page`.
data/README.md CHANGED
@@ -55,7 +55,7 @@ Every method takes the URL first. These options work on all of them and are sent
55
55
  | `labels:` | Your own ids for the request, e.g. `{ client: "acme" }`. Returned with the result and the webhook. |
56
56
  | `residential:` | `true` fetches the page from a home broadband address. |
57
57
  | `report_to:` | A webhook URL the result is POSTed to (async calls). |
58
- | `page_options:` | `wait_for_selector`, `delay`, `block_ads`, `block_cookie_banners`, `block_popups`, `remove_selectors`. Not on `lighthouse`. |
58
+ | `page_options:` | `wait_for_selector`, `scroll_to_bottom`, `delay`, `block_ads`, `block_cookie_banners`, `block_popups`, `remove_selectors`. Not on `lighthouse`. |
59
59
  | `idempotency_key:` | Sent as the `Idempotency-Key` header. |
60
60
  | `extra:` | A Hash merged into the request body, for API options this version doesn't name yet. |
61
61
 
@@ -233,8 +233,8 @@ Everything raised is a `Urlpipe::Error`, with `status`, `code` (the API's error
233
233
  | `Urlpipe::EmailUnverifiedError` | 403: confirm the email address on the account. |
234
234
  | `Urlpipe::InvalidRequestError` | 422 with a code: `invalid_url`, `invalid_max_age`, `invalid_options`, `invalid_labels`, `invalid_idempotency_key`, `idempotency_key_reused`, or a `report_to` the API won't deliver to. |
235
235
  | `Urlpipe::AnalysisFailedError` | 422: the page couldn't be analysed; the message says why. A scrape where every operation failed keeps the scrape on `body`. |
236
- | `Urlpipe::QuotaExceededError` | 429 on the Free plan: `limit`, `used`, `needed`, `resets_at`. |
237
- | `Urlpipe::ConcurrencyLimitError` | 429: `limit` requests already `running`. |
236
+ | `Urlpipe::QuotaExceededError` | 429 on the Free plan: `limit`, `used`, `needed`, `resets_at`; `next_plan` (a Hash: `name`, `monthly_price_cents`, `monthly_credits`, `max_concurrent_requests`) and `upgrade_url`, or `nil`. |
237
+ | `Urlpipe::ConcurrencyLimitError` | 429: `limit` requests already `running`; `next_plan` and `upgrade_url`, or `nil`. |
238
238
  | `Urlpipe::RateLimitedError` | 429: sending too fast; `retry_after` seconds. |
239
239
  | `Urlpipe::NotFoundError` | 404: no result for this token in this project. |
240
240
  | `Urlpipe::StaleResultError` | 410: the result is past the 30-day window. |
@@ -44,25 +44,30 @@ module Urlpipe
44
44
 
45
45
  # 429 quota_exceeded (Free plan only): the month's credits are spent.
46
46
  class QuotaExceededError < Error
47
- attr_reader :limit, :used, :needed, :resets_at
47
+ attr_reader :limit, :used, :needed, :resets_at, :next_plan, :upgrade_url
48
48
 
49
- def initialize(message = nil, limit: nil, used: nil, needed: nil, resets_at: nil, **rest)
49
+ def initialize(message = nil, limit: nil, used: nil, needed: nil, resets_at: nil, next_plan: nil,
50
+ upgrade_url: nil, **rest)
50
51
  super(message, **rest)
51
52
  @limit = limit
52
53
  @used = used
53
54
  @needed = needed
54
55
  @resets_at = resets_at
56
+ @next_plan = next_plan
57
+ @upgrade_url = upgrade_url
55
58
  end
56
59
  end
57
60
 
58
61
  # 429 concurrency_limit: too many of your requests are already running.
59
62
  class ConcurrencyLimitError < Error
60
- attr_reader :limit, :running
63
+ attr_reader :limit, :running, :next_plan, :upgrade_url
61
64
 
62
- def initialize(message = nil, limit: nil, running: nil, **rest)
65
+ def initialize(message = nil, limit: nil, running: nil, next_plan: nil, upgrade_url: nil, **rest)
63
66
  super(message, **rest)
64
67
  @limit = limit
65
68
  @running = running
69
+ @next_plan = next_plan
70
+ @upgrade_url = upgrade_url
66
71
  end
67
72
  end
68
73
 
@@ -160,9 +165,12 @@ module Urlpipe
160
165
  case code
161
166
  when "quota_exceeded"
162
167
  [QuotaExceededError,
163
- { limit: hash["limit"], used: hash["used"], needed: hash["needed"], resets_at: hash["resets_at"] }]
168
+ { limit: hash["limit"], used: hash["used"], needed: hash["needed"], resets_at: hash["resets_at"],
169
+ next_plan: hash["next_plan"], upgrade_url: hash["upgrade_url"] }]
164
170
  when "concurrency_limit"
165
- [ConcurrencyLimitError, { limit: hash["limit"], running: hash["running"] }]
171
+ [ConcurrencyLimitError,
172
+ { limit: hash["limit"], running: hash["running"], next_plan: hash["next_plan"],
173
+ upgrade_url: hash["upgrade_url"] }]
166
174
  when "rate_limited"
167
175
  [RateLimitedError, { retry_after: retry_after(headers, hash) }]
168
176
  else
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Urlpipe
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: urlpipe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - URLpipe