Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.1.1 #24

Merged
merged 3 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.1.1]
### Fixed
- Percent-encoding was not applied on texts entered by the user. [#22](https://github.com/docentYT/osm_easy_api/issues/22)

## [2.1.0]
#### Added
### Added
- `TooManyRequests` exception.
- Support for `429` status code in `api.changeset.discussion.comment()`.

Expand Down
2 changes: 2 additions & 0 deletions src/osm_easy_api/api/_URLs.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# REMEMBER TO ADD urllib.parse.quote WHEN FORMATTING TEXT PROVIDED BY USER!!!

from typing import Dict

class URLs:
Expand Down
4 changes: 3 additions & 1 deletion src/osm_easy_api/api/endpoints/changeset_discussion.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

from ...api import exceptions

import urllib.parse

class Changeset_Discussion_Container:
def __init__(self, outer):
self.outer: "Api" = outer
Expand All @@ -18,7 +20,7 @@ def comment(self, changeset_id: int, text: str) -> None:
Raises:
exceptions.ChangesetNotClosed: Changeset must be closed to add comment.
"""
response = self.outer._request(self.outer._RequestMethods.POST, self.outer._url.changeset_discussion["comment"].format(id=changeset_id, text=text), self.outer._Requirement.YES, auto_status_code_handling=False)
response = self.outer._request(self.outer._RequestMethods.POST, self.outer._url.changeset_discussion["comment"].format(id=changeset_id, text=urllib.parse.quote(text)), self.outer._Requirement.YES, auto_status_code_handling=False)

match response.status_code:
case 200: pass
Expand Down
7 changes: 4 additions & 3 deletions src/osm_easy_api/api/endpoints/notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from ...data_classes import User, Note, Comment

from copy import deepcopy
import urllib.parse
from xml.etree import ElementTree

class Notes_Container:
Expand Down Expand Up @@ -131,7 +132,7 @@ def create(self, latitude: str, longitude: str, text: str) -> Note:
Note: Object of newly created note.
"""
generator = self.outer._post_generator(
url=self.outer._url.note["create"].format(latitude=latitude, longitude=longitude, text=text),
url=self.outer._url.note["create"].format(latitude=latitude, longitude=longitude, text=urllib.parse.quote(text)),
auth_requirement=self.outer._Requirement.OPTIONAL,
auto_status_code_handling=True)

Expand All @@ -152,7 +153,7 @@ def comment(self, id: int, text: str) -> Note:
Note: Note object of commented note
"""
status_code, generator = self.outer._post_generator(
url=self.outer._url.note["comment"].format(id=id, text=text),
url=self.outer._url.note["comment"].format(id=id, text=urllib.parse.quote(text)),
auth_requirement=self.outer._Requirement.YES,
auto_status_code_handling=False)

Expand Down Expand Up @@ -274,7 +275,7 @@ def search(self, text: str, limit: int = 100, closed_days: int = 7, user_id: int
Returns:
list[Note]: List of notes objects.
"""
url=self.outer._url.note["search"].format(text=text, limit=limit, closed=closed_days)
url=self.outer._url.note["search"].format(text=urllib.parse.quote(text), limit=limit, closed=closed_days)
if user_id: url += f"&user={user_id}"
if from_date: url += f"&from={from_date}"
if to_date: url += f"&from={to_date}"
Expand Down
Loading