Skip to content
This repository was archived by the owner on Jul 16, 2025. It is now read-only.

Commit fd12b35

Browse files
authored
Merge pull request #2 from TI-Sin-Problemas/feature/python35-support
Add python 3.5 support
2 parents d5ec2e1 + b6d8758 commit fd12b35

5 files changed

Lines changed: 64 additions & 31 deletions

File tree

pyproject.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "facturapi-python"
7-
version = "0.1.0"
7+
version = "0.1.1"
88
authors = [{ name = "TI Sin Problemas", email = "pypi@tisinproblemas.com" }]
99
description = "Unofficial Facturapi.io Python client"
1010
readme = "README.md"
1111
license = { file = "LICENSE" }
12-
requires-python = ">=3.7"
13-
dependencies = ["requests>=2.28, <3"]
12+
requires-python = ">=3.5"
13+
dependencies = ["requests>=2.20, <3"]
1414
keywords = ["cfdi", "factura", "mexico", "sat"]
1515
classifiers = [
1616
"Programming Language :: Python :: 3",
17+
"Programming Language :: Python :: 3.5",
18+
"Programming Language :: Python :: 3.6",
1719
"Programming Language :: Python :: 3.7",
1820
"Programming Language :: Python :: 3.8",
1921
"Programming Language :: Python :: 3.9",

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
requests==2.28.1
1+
requests==2.20.0

src/facturapi/enums.py

Lines changed: 47 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Enum constants"""
22

33
from enum import Enum
4-
from typing import NamedTuple
4+
from collections import namedtuple
55

66

77
class PaymentForm(Enum):
@@ -448,25 +448,49 @@ class ReceiptPeriodicity(Enum):
448448
TWO_MONTHS = "two_months"
449449

450450

451-
class Catalogs(NamedTuple):
452-
"""Catalog codes"""
453-
454-
payment_forms = PaymentForm
455-
payment_methods = PaymentMethod
456-
invoice_use = InvoiceUse
457-
invoice_relations = InvoiceRelation
458-
tax_systems = TaxSystem
459-
months = Month
460-
contract_types = ContractType
461-
working_day_types = WorkingDayType
462-
tax_system_types = TaxSystemType
463-
job_risks = JobRisk
464-
payment_frequencies = PaymentFrecuency
465-
perception_types = PerceptionType
466-
hour_types = HourType
467-
deduction_types = DeductionType
468-
other_payment_types = OtherPaymentType
469-
disability_types = DisabilityType
470-
withholding_keys = WithholdingKey
471-
cancellation_reasons = CancellationReason
472-
receipt_periodicity = ReceiptPeriodicity
451+
def Catalogs():
452+
catalogs = namedtuple(
453+
"Catalogs",
454+
[
455+
"payment_forms",
456+
"payment_methods",
457+
"invoice_use",
458+
"invoice_relations",
459+
"tax_systems",
460+
"months",
461+
"contract_types",
462+
"working_day_types",
463+
"tax_system_types",
464+
"job_risks",
465+
"payment_frequencies",
466+
"perception_types",
467+
"hour_types",
468+
"deduction_types",
469+
"other_payment_types",
470+
"disability_types",
471+
"withholding_keys",
472+
"cancellation_reasons",
473+
"receipt_periodicity",
474+
],
475+
)
476+
return catalogs(
477+
PaymentForm,
478+
PaymentMethod,
479+
InvoiceUse,
480+
InvoiceRelation,
481+
TaxSystem,
482+
Month,
483+
ContractType,
484+
WorkingDayType,
485+
TaxSystemType,
486+
JobRisk,
487+
PaymentFrecuency,
488+
PerceptionType,
489+
HourType,
490+
DeductionType,
491+
OtherPaymentType,
492+
DisabilityType,
493+
WithholdingKey,
494+
CancellationReason,
495+
ReceiptPeriodicity,
496+
)

src/facturapi/http.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,12 @@ def _get_request_url(self, path_params: list = None) -> str:
6464
"""
6565
version = self._get_api_version()
6666
param_string = "/".join(path_params) if path_params else ""
67-
return f"{self.BASE_URL}{version}/{self._get_endpoint()}/{param_string}"
67+
return "{url}{api_version}/{endpoint}/{param_string}".format(
68+
url=self.BASE_URL,
69+
api_version=version,
70+
endpoint=self._get_endpoint(),
71+
param_string=param_string,
72+
)
6873

6974
def _execute_request(
7075
self, method: str, url: str, query_params: dict = None, json_data: dict = None
@@ -90,12 +95,14 @@ def _execute_request(
9095
request = method_switch.get(method.upper(), None)
9196

9297
if not request:
93-
raise FacturapiException(f"Method {method} not defined")
98+
message = "Method {} not defined".format(method)
99+
raise FacturapiException(message)
94100

95101
try:
96102
response = request[0](url, **request[1])
97103
except Exception as error:
98-
raise FacturapiException(f"Request error: {error}") from error
104+
message = "Request error: {}".format(error)
105+
raise FacturapiException(message) from error
99106

100107
self.last_status = response.status_code
101108

src/facturapi/wrapper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Facturapi:
1818
catalogs = Catalogs()
1919

2020
def __repr__(self) -> str:
21-
return f"<{self.__class__.__name__}: {self}>"
21+
return "<{}: {}>".format(self.__class__.__name__, self)
2222

2323
def __str__(self) -> str:
2424
healthcheck = self.healthcheck.check_status()

0 commit comments

Comments
 (0)