Skip to content

Commit

Permalink
fix(repo): replace .io with .com, update failing test when running vi…
Browse files Browse the repository at this point in the history
  • Loading branch information
AJCJ1 committed Oct 14, 2024
1 parent 8d4541c commit a821b49
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 26 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
![Tests](https://github.com/urlbox/urlbox-python/actions/workflows/tests.yml/badge.svg)
![Linter](https://github.com/urlbox/urlbox-python/actions/workflows/linters.yml/badge.svg)

The Urlbox Python library provides easy access to the <a href="https://urlbox.io/" target="_blank">Urlbox website screenshot API</a> from your Python application.
The Urlbox Python library provides easy access to the <a href="https://urlbox.com/" target="_blank">Urlbox website screenshot API</a> from your Python application.

Now there's no need to muck around with http clients, etc...

Expand All @@ -14,7 +14,7 @@ Just initialise the UrlboxClient and make a screenshot of a URL in seconds.

## Documentation

See the <a href=https://urlbox.io/docs/overview target="_blank">Urlbox API Docs</a>.
See the <a href=https://urlbox.com/docs/overview target="_blank">Urlbox API Docs</a>.

## Requirements

Expand All @@ -27,7 +27,7 @@ Python 3.x

## Usage

First, grab your Urlbox API key* found in your <a href="https://urlbox.io/dashboard/api" target="_blank">Urlbox Dashboard</a>, to initialise the UrlboxClient instance.
First, grab your Urlbox API key* found in your <a href="https://urlbox.com/dashboard/api" target="_blank">Urlbox Dashboard</a>, to initialise the UrlboxClient instance.

*\* and grab your API secret - if you want to make authenticated requests. Requests will be automatically authenticated when you supply YOUR_API_SECRET.
So you really should.*
Expand Down Expand Up @@ -76,7 +76,7 @@ Additional options in the dictionary include:
"format" can be either: png, jpg or jpeg, avif, webp ,pdf, svg, html *(defaults to png if not provided).*

"full_page", "width", and many more.
See all available options here: https://urlbox.io/docs/options
See all available options here: https://urlbox.com/docs/options

eg:
```python
Expand Down Expand Up @@ -172,7 +172,7 @@ Give it a couple of seconds, and you should receive, posted to the webhook_url s
"event": "render.succeeded",
"renderId": "2cf5ffe2-7736-4d41-8c30-f13e16d35248",
"result": {
"renderUrl": "https://renders.urlbox.io/urlbox1/renders/61431b47b8538a00086c29dd/2021/11/25/e2dcec18-8353-435c-ba17-b549c849eec5.png"
"renderUrl": "https://renders.urlbox.com/urlbox1/renders/61431b47b8538a00086c29dd/2021/11/25/e2dcec18-8353-435c-ba17-b549c849eec5.png"
},
"meta": {
"startTime": "2021-11-25T16:32:32.453Z",
Expand Down Expand Up @@ -203,7 +203,7 @@ payload = {
"event": "render.succeeded",
"renderId": "794383cd-b09e-4aef-a12b-fadf8aad9d63",
"result": {
"renderUrl": "https://renders.urlbox.io/urlbox1/renders/foo.png"
"renderUrl": "https://renders.urlbox.com/urlbox1/renders/foo.png"
},
"meta": {
"startTime": "2021-11-24T16:49:48.307Z",
Expand All @@ -224,4 +224,4 @@ webhook_validator.call(header_signature, payload, webhook_secret)
## Feedback


Feel free to contact us if you spot a bug or have any suggestions at: support`[at]`urlbox.io.
Feel free to contact us if you spot a bug or have any suggestions at: support`[at]`urlbox.com.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
name="urlbox",
version="1.0.6",
author="Urlbox",
author_email="support@urlbox.io",
author_email="support@urlbox.com",
description="Official Python client for the Ulrbox API",
license="MIT",
long_description=long_description,
Expand Down
15 changes: 8 additions & 7 deletions tests/test_urlbox_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ def test_api_key_not_provided():
with pytest.raises(TypeError) as type_error:
UrlboxClient()

# Required UrlboxClient. as prefix to pass tests locally for [email protected]
assert (
str(type_error.value)
== "__init__() missing 1 required keyword-only argument: 'api_key'"
== "UrlboxClient.__init__() missing 1 required keyword-only argument: 'api_key'"
)


Expand Down Expand Up @@ -340,7 +341,7 @@ def test_get_invalid_url():


def test_get_with_different_host_name():
api_host_name = random.choice(["api-eu.urlbox.io", "api-direct.urlbox.io"])
api_host_name = random.choice(["api-eu.urlbox.com", "api-direct.urlbox.com"])
api_key = fake.pystr()

format = random.choice(
Expand Down Expand Up @@ -515,7 +516,7 @@ def test_head_request():


def test_head_with_different_host_name():
api_host_name = random.choice(["api-eu.urlbox.io", "api-direct.urlbox.io"])
api_host_name = random.choice(["api-eu.urlbox.com", "api-direct.urlbox.com"])
api_key = fake.pystr()

format = random.choice(
Expand Down Expand Up @@ -580,7 +581,7 @@ def test_post_request_successful():
with requests_mock.Mocker() as requests_mocker:
requests_mocker.post(
urlbox_request_url,
content=b'{"status":"created","renderId":"47dd4b7b-1eea-437c-ade0-f2d1cd7bf5a1","statusUrl":"https://api.urlbox.io/render/47dd4b7b-1eea-437c-ade0-f2d1cd7bf5a1"}',
content=b'{"status":"created","renderId":"47dd4b7b-1eea-437c-ade0-f2d1cd7bf5a1","statusUrl":"https://api.urlbox.com/render/47dd4b7b-1eea-437c-ade0-f2d1cd7bf5a1"}',
headers={"content-type": "application/json"},
status_code=201,
)
Expand All @@ -593,7 +594,7 @@ def test_post_request_successful():


def test_post_with_different_host_name():
api_host_name = random.choice(["api-eu.urlbox.io", "api-direct.urlbox.io"])
api_host_name = random.choice(["api-eu.urlbox.com", "api-direct.urlbox.com"])
api_key = fake.pystr()
api_secret = fake.pystr()

Expand Down Expand Up @@ -621,7 +622,7 @@ def test_post_with_different_host_name():
with requests_mock.Mocker() as requests_mocker:
requests_mocker.post(
urlbox_request_url,
content=b'{"status":"created","renderId":"47dd4b7b-1eea-437c-ade0-f2d1cd7bf5a1","statusUrl":"https://api.urlbox.io/render/47dd4b7b-1eea-437c-ade0-f2d1cd7bf5a1"}',
content=b'{"status":"created","renderId":"47dd4b7b-1eea-437c-ade0-f2d1cd7bf5a1","statusUrl":"https://api.urlbox.com/render/47dd4b7b-1eea-437c-ade0-f2d1cd7bf5a1"}',
headers={"content-type": "application/json"},
status_code=201,
)
Expand Down Expand Up @@ -655,7 +656,7 @@ def test_post_request_successful_missing_webhook_url():
with requests_mock.Mocker() as requests_mocker:
requests_mocker.post(
urlbox_request_url,
content=b'{"status":"created","renderId":"47dd4b7b-1eea-437c-ade0-f2d1cd7bf5a1","statusUrl":"https://api.urlbox.io/render/47dd4b7b-1eea-437c-ade0-f2d1cd7bf5a1"}',
content=b'{"status":"created","renderId":"47dd4b7b-1eea-437c-ade0-f2d1cd7bf5a1","statusUrl":"https://api.urlbox.com/render/47dd4b7b-1eea-437c-ade0-f2d1cd7bf5a1"}',
headers={"content-type": "application/json"},
status_code=201,
)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_webhook_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"event": "render.succeeded",
"renderId": "794383cd-b09e-4aef-a12b-fadf8aad9d63",
"result": {
"renderUrl": "https://renders.urlbox.io/urlbox1/renders/61431b47b8538a00086c29dd/2021/11/24/bee42850-bab6-43c6-bd9d-e614581d31b4.png"
"renderUrl": "https://renders.urlbox.com/urlbox1/renders/61431b47b8538a00086c29dd/2021/11/24/bee42850-bab6-43c6-bd9d-e614581d31b4.png"
},
"meta": {
"startTime": "2021-11-24T16:49:48.307Z",
Expand Down
18 changes: 9 additions & 9 deletions urlbox/urlbox_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ class UrlboxClient:
The core client object used to interact with the Urlbox API
:param api_key: Your API key found in your Urlbox Dashboard
`https://urlbox.io/dashboard/api`
`https://urlbox.com/dashboard/api`
:param api_secret: (Optional) Your API secret found in your Urlbox
Dashboard`https://urlbox.io/dashboard/api`
Dashboard`https://urlbox.com/dashboard/api`
Required for authenticated requests.
"""

BASE_API_URL = "https://api.urlbox.io/v1/"
BASE_API_URL = "https://api.urlbox.com/v1/"
POST_END_POINT = "render"

def __init__(self, *, api_key, api_secret=None, api_host_name=None):
Expand All @@ -38,8 +38,8 @@ def get(self, options):
format: can be either "png", "jpg", "jpeg", "avif", "webp", "pdf", "svg", "html". Defaults to "png".
Example: urlbox_client.get({"url": "http://example.com/", "format": "png", "full_page": True, "width": 300})
API example: https://urlbox.io/docs/getting-started
Full options reference: https://urlbox.io/docs/options
API example: https://urlbox.com/docs/getting-started
Full options reference: https://urlbox.com/docs/options
"""

return requests.get(
Expand Down Expand Up @@ -78,8 +78,8 @@ def head(self, options):
format: can be either "png", "jpg", "jpeg", "avif", "webp", "pdf", "svg", "html". Defaults to "png".
Example: urlbox_client.get({"url": "http://example.com/", "format": "png", "full_page": True, "width": 300})
API example: https://urlbox.io/docs/getting-started
Full options reference: https://urlbox.io/docs/options
API example: https://urlbox.com/docs/getting-started
Full options reference: https://urlbox.com/docs/options
"""

processed_options, format = self._process_options(options)
Expand All @@ -104,7 +104,7 @@ def post(self, options):
format: can be either "png", "jpg", "jpeg", "avif", "webp", "pdf", "svg", "html". Defaults to "png".
Example: urlbox_client.post({"url": "http://example.com/", "webhook_url": "http://yoursite.com/webhook", "format": "png", "full_page": True, "width": 300})
Full options reference: https://urlbox.io/docs/options
Full options reference: https://urlbox.com/docs/options
"""

if "webhook_url" not in options:
Expand Down Expand Up @@ -147,7 +147,7 @@ def generate_url(self, options):
In your html template:
<img src="{{ screenshot_url }}"/>
Full options reference: https://urlbox.io/docs/options
Full options reference: https://urlbox.com/docs/options
"""

processed_options, format = self._process_options(options)
Expand Down
2 changes: 1 addition & 1 deletion urlbox/webhook_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def call(header_signature, payload, webhook_secret):
:param payload: json body of the webhook request.
:param webhook_secret: Your webhook secret found in your Urlbox (NB: NOT the api secret - that's a different secret)
Dashboard`https://urlbox.io/dashboard/api`
Dashboard`https://urlbox.com/dashboard/api`
This function parses the signature value to determine if it's part of a valid Urlbox webhook request.
"""
Expand Down

0 comments on commit a821b49

Please sign in to comment.