forked from Bloomstack/python-metrc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmetrc.py
More file actions
37 lines (24 loc) · 870 Bytes
/
metrc.py
File metadata and controls
37 lines (24 loc) · 870 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# -*- coding: utf-8 -*-
"""Main module."""
import copy
from hammock import Hammock, bind_method
class METRC(Hammock):
"""Class for wrapping requests to the METRC Web API"""
def __init__(self, base_path, vendor_key, user_key,
license_number, api_version="v1", **kwargs):
kwargs.update({
"auth": (vendor_key, user_key),
"params": {"licenseNumber": license_number},
})
super(METRC, self).__init__(base_path, **kwargs)
self.api_version = api_version
def _spawn(self, name):
child = copy.copy(self)
if not child._parent:
child._name = name + "/" + self.api_version
else:
child._name = name
child._parent = self
return child
for method in ["get", "post", "delete"]:
setattr(METRC, method, bind_method(method))