Skip to content

Commit

Permalink
first
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasalves0 committed Sep 12, 2023
0 parents commit ae9f254
Show file tree
Hide file tree
Showing 98 changed files with 2,076 additions and 0 deletions.
172 changes: 172 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

/env/
/responses/
/moorse/.git/

testes_webhooks.py
testes_billing.py
testes_login.py
testes_reports.py
testes_integration.py
testes_template.py
testes_mensagens.py

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
17 changes: 17 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
MIT License
Copyright (c) 2018 YOUR NAME
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Documentação
1 change: 1 addition & 0 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from moorse import Moorse
3 changes: 3 additions & 0 deletions moorse/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.analysis.typeCheckingMode": "off"
}
11 changes: 11 additions & 0 deletions moorse/clients/auth_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from enums.url import URL
from dto.authorization.login_response import LoginResponse
import requests
import json

class AuthClient:

def login(self, email: str, password: str) -> LoginResponse:
data: dict[str, str] = { 'login': email, 'senha': password }
response = requests.post(URL.AUTH_LOGIN.value, json=data).json()
return LoginResponse(response)
21 changes: 21 additions & 0 deletions moorse/clients/billing_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from dto.billing.billing_dto import BillingDto
from dto.moorse_error import MoorseError
from enums.url import URL
import requests
import json

class BillingClient:

def get_credits(self, token: str, integration_id: str):
response = requests.get(
URL.BILLING.value.format(integration_id),
headers = {'Authorization': f"Bearer {token}"}
)
try:
response = response.json()
except:
response = {
"data": None,
"errors": ["Integração não encontrada"]
}
return BillingDto(response)
37 changes: 37 additions & 0 deletions moorse/clients/integration_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import requests
from enums.url import URL
from dto.integration.delete.integration_deletion_data import IntegrationDeletionData
from dto.integration.get_one.integration_data import IntegrationData
from dto.integration.get_all.integrations_data import IntegrationsData
from dto.integration.get_status.integration_status_data import IntegrationStatusData
import json

class IntegrationClient:

def delete(self, token: str, integration_id: str) -> IntegrationDeletionData:
response = requests.delete(
URL.SEARCH_INTEGRATION.value.format(integration_id),
headers = {'Authorization': f"Bearer {token}"}
).json()
return IntegrationDeletionData(response)

def get_one(self, token: str, integration_id: str) -> IntegrationData:
response = requests.get(
URL.SEARCH_INTEGRATION.value.format(integration_id),
headers = {'Authorization': f"Bearer {token}"}
).json()
return IntegrationData(response)

def get_all(self, token: str) -> IntegrationsData:
response = requests.get(
URL.INTEGRATION.value,
headers = {'Authorization': f"Bearer {token}"}
).json()
return IntegrationsData(response)

def get_status(self, token: str, integration_id: str) -> IntegrationStatusData:
response = requests.get(
URL.SEARCH_INTEGRATION_STATUS.value.format(integration_id),
headers = {'Authorization': f"Bearer {token}"}
).json()
return IntegrationStatusData(response)
13 changes: 13 additions & 0 deletions moorse/clients/message/instagram_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import requests
from enums.url import URL
from dto.message.message_sent_response import MessageSentResponse

class InstagramClient:

def send_text(self, token: str, integration_id: str, to: str, body: str):
response = requests.post(
URL.INSTAGRAM_TEXT_MESSAGE.value.format(integration_id),
json = {'to': to, 'body': body},
headers = {'Authorization': f"Bearer {token}"}
).json()
return MessageSentResponse(response)
13 changes: 13 additions & 0 deletions moorse/clients/message/sms_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import requests
from enums.url import URL
from dto.message.message_sent_response import MessageSentResponse

class SmsClient:

def send_text(self, token: str, integration_id: str, to: str, body: str):
response = requests.post(
URL.SMS_TEXT_MESSAGE.value.format(integration_id),
json = {'to': to, 'body': body},
headers = {'Authorization': f"Bearer {token}"}
).json()
return MessageSentResponse(response)
48 changes: 48 additions & 0 deletions moorse/clients/message/whatsapp_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import requests
from enums.url import URL
from dto.message.message_sent_response import MessageSentResponse
from dto.message.menu.menu_message_request import MenuMessageRequest
from dto.message.buttons.buttons_message_request import ButtonsMessageRequest
from dto.message.template.template_message_request import TemplateMessageRequest

class WhatsappClient:

def send_text(self, token: str, to: str, body: str, integration_id: str) -> MessageSentResponse:
response = requests.post(
URL.WHATSAPP_TEXT_MESSAGE.value.format(integration_id),
json = {'to': to, 'body': body},
headers = {'Authorization': f"Bearer {token}"}
).json()
return MessageSentResponse(response)

def send_file(self, token: str, to: str, body: str, filename: str, integration_id: str, caption: str = None) -> MessageSentResponse:
response = requests.post(
URL.WHATSAPP_FILE_MESSAGE.value.format(integration_id),
json = {'to': to, 'body': body, 'filename': filename, 'caption': caption},
headers = {'Authorization': f"Bearer {token}"}
).json()
return MessageSentResponse(response)

def send_list_menu(self, token: str, menu: MenuMessageRequest, integration_id: str) -> MessageSentResponse:
response = requests.post(
URL.WHATSAPP_LIST_MENU_MESSAGE.value.format(integration_id),
json = menu.to_json(),
headers = {'Authorization': f"Bearer {token}"}
).json()
return MessageSentResponse(response)

def send_buttons(self, token: str, buttons: ButtonsMessageRequest, integration_id: str) -> MessageSentResponse:
response = requests.post(
URL.WHATSAPP_BUTTONS_MESSAGE.value.format(integration_id),
json = buttons.to_json(),
headers = {'Authorization': f"Bearer {token}"}
).json()
return MessageSentResponse(response)

def send_template(self, token: str, template: TemplateMessageRequest, integration_id: str) -> MessageSentResponse:
response = requests.post(
URL.WHATSAPP_TEMPLATE_MESSAGE.value.format(integration_id),
json = template.to_json(),
headers = {'Authorization': f"Bearer {token}"}
).json()
return MessageSentResponse(response)
29 changes: 29 additions & 0 deletions moorse/clients/report_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from dto.reports.standard.messages_report_dto import MessagesReportDto
from dto.reports.channel.messages_by_channel_report_dto import MessagesByChannelReportDto
from dto.reports.timeline.messages_by_timeline_report_dto import MessagesByTimelineReportDto
from enums.url import URL
import requests
import json

class ReportClient:

def get_messages(self, token: str, begin: str, end: str) -> MessagesReportDto:
response = requests.get(
URL.REPORT.value.format(begin, end),
headers = {'Authorization': f"Bearer {token}"}
).json()
return MessagesReportDto(response)

def get_messages_by_channel(self, token: str, begin: str, end: str) -> MessagesByChannelReportDto:
response = requests.get(
URL.REPORT_BY_CHANNEL.value.format(begin, end),
headers = {'Authorization': f"Bearer {token}"}
).json()
return MessagesByChannelReportDto(response)

def get_messages_by_timeline(self, token: str, begin: str, end: str) -> MessagesByTimelineReportDto:
response = requests.get(
URL.REPORT_BY_TIMELINE.value.format(begin, end),
headers = {'Authorization': f"Bearer {token}"}
).json()
return MessagesByTimelineReportDto(response)
Loading

0 comments on commit ae9f254

Please sign in to comment.