-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
387 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
# To get started with Dependabot version updates, you'll need to specify which | ||
# package ecosystems to update and where the package manifests are located. | ||
# Please see the documentation for all configuration options: | ||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
# # To get started with Dependabot version updates, you'll need to specify which | ||
# # package ecosystems to update and where the package manifests are located. | ||
# # Please see the documentation for all configuration options: | ||
# # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: "pip" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
allow: | ||
- dependency-type: "all" | ||
assignees: | ||
- "mariofix" | ||
commit-message: | ||
prefix: "poetry prod" | ||
prefix-development: "poetry dev" | ||
include: "scope" | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
allow: | ||
- dependency-type: "all" | ||
commit-message: | ||
prefix: "actions prod" | ||
prefix-development: "actions dev" | ||
include: "scope" | ||
# version: 2 | ||
# updates: | ||
# - package-ecosystem: "pip" | ||
# directory: "/" | ||
# schedule: | ||
# interval: "weekly" | ||
# allow: | ||
# - dependency-type: "all" | ||
# assignees: | ||
# - "mariofix" | ||
# commit-message: | ||
# prefix: "poetry prod" | ||
# prefix-development: "poetry dev" | ||
# include: "scope" | ||
# - package-ecosystem: "github-actions" | ||
# directory: "/" | ||
# schedule: | ||
# interval: "weekly" | ||
# allow: | ||
# - dependency-type: "all" | ||
# commit-message: | ||
# prefix: "actions prod" | ||
# prefix-development: "actions dev" | ||
# include: "scope" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,41 @@ | ||
name: Tests&Coverage | ||
# name: Tests&Coverage | ||
|
||
on: | ||
push: | ||
branches: ["sandbox"] | ||
pull_request: | ||
branches: ["main"] | ||
# on: | ||
# push: | ||
# branches: ["sandbox"] | ||
# pull_request: | ||
# branches: ["main"] | ||
|
||
jobs: | ||
tests: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ["3.9", "3.10", "3.11", "3.12"] | ||
poetry-version: ["1.8.3"] | ||
os: [ubuntu-latest] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Set Up Poetry | ||
uses: abatilo/actions-poetry@v2 | ||
with: | ||
poetry-version: ${{ matrix.poetry-version }} | ||
- name: Install merchants | ||
run: poetry install --with dev | ||
- name: Run Tests and coverage | ||
run: poetry run coverage run -m pytest | ||
- name: Coverage report (xml) | ||
run: poetry run coverage xml | ||
- name: Coveralls GitHub Action | ||
uses: coverallsapp/github-action@v2 | ||
- name: Run codacy-coverage-reporter | ||
uses: codacy/codacy-coverage-reporter-action@v1 | ||
with: | ||
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} | ||
coverage-reports: "coverage.xml" | ||
language: "python" | ||
# jobs: | ||
# tests: | ||
# strategy: | ||
# fail-fast: false | ||
# matrix: | ||
# python-version: ["3.9", "3.10", "3.11", "3.12"] | ||
# poetry-version: ["1.8.3"] | ||
# os: [ubuntu-latest] | ||
# runs-on: ${{ matrix.os }} | ||
# steps: | ||
# - uses: actions/checkout@v4 | ||
# - name: Set up Python ${{ matrix.python-version }} | ||
# uses: actions/setup-python@v4 | ||
# with: | ||
# python-version: ${{ matrix.python-version }} | ||
# - name: Set Up Poetry | ||
# uses: abatilo/actions-poetry@v2 | ||
# with: | ||
# poetry-version: ${{ matrix.poetry-version }} | ||
# - name: Install merchants | ||
# run: poetry install --with dev | ||
# - name: Run Tests and coverage | ||
# run: poetry run coverage run -m pytest | ||
# - name: Coverage report (xml) | ||
# run: poetry run coverage xml | ||
# - name: Coveralls GitHub Action | ||
# uses: coverallsapp/github-action@v2 | ||
# - name: Run codacy-coverage-reporter | ||
# uses: codacy/codacy-coverage-reporter-action@v1 | ||
# with: | ||
# project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} | ||
# coverage-reports: "coverage.xml" | ||
# language: "python" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from decimal import Decimal | ||
|
||
from fastapi import FastAPI | ||
from icecream import ic | ||
from sqlalchemy import create_engine | ||
from sqlalchemy.orm import Mapped, declarative_base, mapped_column, sessionmaker | ||
from starlette_admin.contrib.sqla import Admin, ModelView | ||
|
||
from merchants.orm.sqla import PaymentMixin | ||
|
||
SQLALCHEMY_DATABASE_URL = "sqlite:///./examples/fastapi_sqla/merchants.sqlite3" | ||
|
||
engine = create_engine(SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False}) | ||
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) | ||
|
||
Base = declarative_base() | ||
|
||
|
||
class Payment(PaymentMixin, Base): | ||
__tablename__ = "payments" | ||
|
||
id: Mapped[int] = mapped_column(primary_key=True) | ||
|
||
def make_payment(self): | ||
ic(self) | ||
|
||
|
||
Base.metadata.create_all(engine) | ||
|
||
session = SessionLocal() | ||
|
||
payment = Payment(account="timestamp_test", amount=Decimal("100.00"), currency="USD", status="CREATED") | ||
|
||
session.add(payment) | ||
session.commit() | ||
|
||
|
||
app = FastAPI() | ||
admin = Admin(engine, title="merchants: SQLAlchemy") | ||
admin.add_view(ModelView(Payment)) | ||
admin.mount_to(app) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[tool.poetry] | ||
name = "fastapi-sqla" | ||
version = "0.1.0" | ||
description = "Example for FastAPI using SQLAlchemy" | ||
authors = ["Mario Hernandez <mariofix@proton.me>"] | ||
license = "MIT" | ||
readme = "README.md" | ||
|
||
|
||
[tool.poetry.dependencies] | ||
python = "^3.10" | ||
fastapi = "^0.111.0" | ||
sqlalchemy = "^2.0.31" | ||
|
||
[build-system] | ||
requires = ["poetry-core"] | ||
build-backend = "poetry.core.masonry.api" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
from .config import base_settings as settings | ||
from .config import default_settings as settings | ||
|
||
__all__ = ["settings"] |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import httpx | ||
|
||
# Cliente httpx para definir parametros especificos | ||
client = httpx.Client(headers={"user-agent": "merchants/2024.6"}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from fastapi import APIRouter | ||
|
||
merchants = APIRouter() | ||
|
||
|
||
# Acá irán las URL para los callbacks | ||
# Dejar así hasta llegar a esa etapa | ||
@merchants.get("/") | ||
async def default_root(): | ||
return {"Hello": "World"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
from dataclasses import dataclass | ||
from enum import Enum | ||
|
||
|
||
@dataclass | ||
class ModelStatus: | ||
CREATED: str = "Created" | ||
PROCESSING: str = "Processing" | ||
ERROR: str = "Error" | ||
REJECTED: str = "Rejected" | ||
COMPLETED: str = "Completed" | ||
REFUNDED: str = "Refunded" | ||
REVERSED: str = "Reversed" | ||
class ModelStatus(Enum): | ||
""" | ||
Enumeration of possible payment statuses. | ||
""" | ||
|
||
CREATED = "CREATED" | ||
PROCESSING = "PROCESSING" | ||
ERROR = "ERROR" | ||
REJECTED = "REJEDTED" | ||
COMPLETED = "COMPLETED" | ||
FULL_REFUND = "FULL_REFUND" | ||
PARTIAL_REFUND = "PARTIAL_REFUND" | ||
REVERSED = "REVERSED" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
from ..config import base_settings | ||
from ..config import default_settings | ||
|
||
|
||
def local_factory(slug: str): | ||
if slug not in base_settings.available_providers: | ||
if slug not in default_settings.available_providers: | ||
raise NotImplementedError(f"The provider {slug} is not supported.") | ||
|
||
return slug | ||
|
||
|
||
def create_provider(slug: str): | ||
if slug not in base_settings.available_providers: | ||
if slug not in default_settings.available_providers: | ||
raise NotImplementedError(f"The provider {slug} is not supported.") | ||
|
||
return slug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,12 @@ | ||
from dataclasses import dataclass | ||
from .settings import settings | ||
|
||
__version__ = "0.1.0" | ||
__merchants_name__ = "dummy" | ||
__merchants_slug__ = "dummy" | ||
|
||
|
||
@dataclass | ||
class Settings: | ||
endpoint: str = "https://api.example.com" | ||
api_key: str = "key_123456" | ||
api_secret: str = "secret_123456" | ||
|
||
|
||
settings = Settings() | ||
__all__ = [ | ||
"__version__", | ||
"__merchants_name__", | ||
"__merchants_slug__", | ||
"settings", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import uuid | ||
|
||
from pydantic import BaseModel | ||
|
||
# from .settings import settings | ||
|
||
|
||
class DummyPayment(BaseModel): | ||
transaction_id: uuid.UUID | ||
|
||
|
||
def create_payment() -> DummyPayment: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from dataclasses import dataclass | ||
|
||
|
||
@dataclass | ||
class Settings: | ||
endpoint: str = "https://api.example.com" | ||
api_key: str = "key_123456" | ||
api_secret: str = "secret_123456" | ||
|
||
|
||
settings = Settings() |
Oops, something went wrong.