Skip to content

Commit

Permalink
Merge pull request #1 from panosangelopoulos/initial-client
Browse files Browse the repository at this point in the history
Initial client commit
  • Loading branch information
panosangelopoulos authored Sep 16, 2022
2 parents fc65272 + c7be776 commit 0bde870
Show file tree
Hide file tree
Showing 13 changed files with 302 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,10 @@ dmypy.json

# Pyre type checker
.pyre/


settings_testing_locally.py
manage.py
asgi.py
wsgi.py
urls.py
Empty file added django_bitgo/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions django_bitgo/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
6 changes: 6 additions & 0 deletions django_bitgo/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class DjangoBitgoConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "django_bitgo"
33 changes: 33 additions & 0 deletions django_bitgo/client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from re import L
import requests
import os
from django.conf import settings

from django_bitgo.exceptions import BitGoException


class BitGoClient(object):
def __init__(self, access_token) -> None:
"""
Initializes the BitGo Client
:param str access_token: Access Token to authenticate with
"""

self.access_token = access_token or os.env.get("BITGO_ACCESS_TOKEN")

if not self.access_token:
raise BitGoException("Access token is required to create a BitGoClient")

def request(self, method="GET", headers={}, path="", payload={}):
headers["Authorization"] = f"Bearer {self.access_token}"

return requests.request(
method=method,
url=f"{self.get_api_url()}{path}",
headers=headers,
data=payload,
)

def get_api_url(self):
return settings.BITGO_API_URL
2 changes: 2 additions & 0 deletions django_bitgo/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class BitGoException(Exception):
pass
Empty file.
3 changes: 3 additions & 0 deletions django_bitgo/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
3 changes: 3 additions & 0 deletions django_bitgo/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import os

BITGO_API_URL = os.environ.get("BITGO_API_URL", "https://app.bitgo-test.com/")
3 changes: 3 additions & 0 deletions django_bitgo/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
3 changes: 3 additions & 0 deletions django_bitgo/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.shortcuts import render

# Create your views here.
221 changes: 221 additions & 0 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[tool.poetry]
name = "django_bitgo"
version = "0.1.0"
description = "Django app for bitGo"
authors = ["panosangelopoulos <panos.angelopoulos@outlook.com>"]
license = "MIT"

[tool.poetry.dependencies]
python = "^3.10"
Django = "^4.1.1"
requests = "^2.28.1"
black = "^22.8.0"

[tool.poetry.dev-dependencies]

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

0 comments on commit 0bde870

Please sign in to comment.