cannabis_reports package¶
Subpackages¶
- cannabis_reports.apis package
- Submodules
- cannabis_reports.apis.abstract_entity_endpoint module
- cannabis_reports.apis.abstract_item_endpoint module
- cannabis_reports.apis.abstract_product_endpoint module
- cannabis_reports.apis.dispensaries module
- cannabis_reports.apis.edibles module
- cannabis_reports.apis.extracts module
- cannabis_reports.apis.flowers module
- cannabis_reports.apis.producers module
- cannabis_reports.apis.products module
- cannabis_reports.apis.strains module
- Module contents
- cannabis_reports.models package
- Submodules
- cannabis_reports.models.abstract_item module
- cannabis_reports.models.address module
- cannabis_reports.models.dispensary module
- cannabis_reports.models.edible module
- cannabis_reports.models.effects_flavors module
- cannabis_reports.models.extract module
- cannabis_reports.models.flower module
- cannabis_reports.models.menu_item module
- cannabis_reports.models.producer module
- cannabis_reports.models.product module
- cannabis_reports.models.review module
- cannabis_reports.models.seed_company module
- cannabis_reports.models.strain module
- cannabis_reports.models.user module
- Module contents
- cannabis_reports.request_paginator package
- cannabis_reports.tests package
- Submodules
- cannabis_reports.tests.api_common module
- cannabis_reports.tests.api_entity module
- cannabis_reports.tests.api_product module
- cannabis_reports.tests.test_apis_dispensaries module
- cannabis_reports.tests.test_apis_edibles module
- cannabis_reports.tests.test_apis_extracts module
- cannabis_reports.tests.test_apis_flowers module
- cannabis_reports.tests.test_apis_producer module
- cannabis_reports.tests.test_apis_products module
- cannabis_reports.tests.test_apis_strains module
- cannabis_reports.tests.test_base_api module
- cannabis_reports.tests.test_base_model module
- cannabis_reports.tests.test_cannabis_reports module
- cannabis_reports.tests.test_exceptions module
- cannabis_reports.tests.test_request_paginator module
- Module contents
Submodules¶
cannabis_reports.auth_proxy module¶
-
class
cannabis_reports.auth_proxy.AuthProxy(session, proxy_class)[source]¶ Bases:
objectThis object acts as a transparent authentication proxy for the API.
This is required because the API objects are naive of the authentication that is setup in
CannabisReports, and all of the API interface methods areclassmethodsbecause they are instantiating.-
METHOD_NO_PROXY= ['auth_proxy']¶
-
auth_proxy(method)[source]¶ Authentication proxy for API requests.
This is required because the API objects are naive of
CannabisReports, so they would otherwise be unauthenticated.Parameters: method (callable) – A method call that should be authenticated. It should accept a requests.Sessionas its first parameter, which should be used for the actual API call.Returns: The results of the authenticated callable. Return type: mixed
-
cannabis_reports.base_api module¶
-
class
cannabis_reports.base_api.BaseApi[source]¶ Bases:
objectThis is the API interface object to be implemented by API adapters.
It acts as a collection for the API object that it represents, passing through iteration to the API’s request paginator.
-
BASE_URI¶ str – CannabisReports API URI base.
-
paginator¶ RequestPaginator – Object to use for producing an iterator representing multiple requests (API response pages). Created on init.
-
__object__¶ cannabis_reports.models.BaseModel – Model object that API represents.
-
BASE_URI= 'https://www.cannabisreports.com/api/v1.0'
-
classmethod
get(session, ucpc)[source]¶ Gets an individual object based on the UCPC.
Parameters: Returns: The object that was found.
Return type: cls.__object__
-
classmethod
list(session, sort='created_at', descending=False, limit=None)[source]¶ Return all objects, with optional sorting.
Parameters: Returns: Objects iterator.
Return type: RequestPaginator(output_type=cls.__object__)
-
classmethod
new_object(data)[source]¶ Return a new object of the correct type from the data.
Parameters: data (dict) – Data dictionary that should be converted to an object. It can use either camelCase keys or snake_case. Returns: A model of the type declared in cls.__object__.Return type: BaseModel
-
paginator= None
-
cannabis_reports.base_model module¶
-
class
cannabis_reports.base_model.BaseModel(**kwargs)[source]¶ Bases:
properties.base.base.HasPropertiesThis is the model that all other models inherit from.
It provides some convenience functions, and the standardidproperty.Required Properties:
- created_at (
CustomDateTime): Localized date and time when this record was created., a datetime object - ucpc (
String): UCPC code for this record., a unicode string - updated_at (
CustomDateTime): Localized date and time when this record was modified., a datetime object
-
created_at¶ Localized date and time when this record was created.
-
classmethod
from_api(**kwargs)[source]¶ Create a new instance from API arguments.
This will switch camelCase keys into snake_case for instantiation.
It will also identify any
InstanceorListproperties, and instantiate the proper objects using the values. The end result being a fully Objectified and Pythonified API response.Returns: Instantiated model using the API values. Return type: BaseModel
-
to_api()[source]¶ Return a dictionary to send to the API.
Returns: - Mapping representing this object that can be sent to the
- API.
Return type: dict
-
updated_at¶ Localized date and time when this record was modified.
- created_at (
-
class
cannabis_reports.base_model.BaseModelWithLinks(**kwargs)[source]¶ Bases:
cannabis_reports.base_model.BaseModelRequired Properties:
- created_at (
CustomDateTime): Localized date and time when this record was created., a datetime object - link (
String): Link to the record in the Cannabis Reports API., a unicode string - qr (
String): Link to the QR code for this record., a unicode string - ucpc (
String): UCPC code for this record., a unicode string - updated_at (
CustomDateTime): Localized date and time when this record was modified., a datetime object - url (
String): Link to the record listing on the Cannabis Reports website., a unicode string
-
link¶ Link to the record in the Cannabis Reports API.
-
qr¶ Link to the QR code for this record.
-
url¶ Link to the record listing on the Cannabis Reports website.
- created_at (
-
class
cannabis_reports.base_model.CustomDateTime(doc, **kwargs)[source]¶ Bases:
properties.basic.DateTimeImplementation of DateTime supporting the proper format:
Object containing two strings, “dateTime” and the “timezone” when the strain was added.
-
FORMAT_DT= '%Y-%m-%d %H:%M:%S'¶
-
-
class
cannabis_reports.base_model.GeneralOverview(**kwargs)[source]¶ Bases:
cannabis_reports.base_model.BaseModelObject that holds a general overview of other objects.
This is the object that is typically returned by the API, which holds the high level information & how to access the actual dataset.Required Properties:
- count (
Integer): Total amount of reviews for this record., an integer - created_at (
CustomDateTime): Localized date and time when this record was created., a datetime object - link (
String): Link to the detailed review information in the Cannabis Reports API., a unicode string - ucpc (
String): UCPC code for this record., a unicode string - updated_at (
CustomDateTime): Localized date and time when this record was modified., a datetime object
-
count¶ Total amount of reviews for this record.
-
link¶ Link to the detailed review information in the Cannabis Reports API.
- count (
-
class
cannabis_reports.base_model.LineageModel(**kwargs)[source]¶ Bases:
cannabis_reports.base_model.LinksModelWithImageRequired Properties:
- created_at (
CustomDateTime): Localized date and time when this record was created., a datetime object - image (
String): Link to the full size image for this record on Cannabis Reports., a unicode string - lineage (
Property): Countries of origin for the genetics for the strain. Object keys are the country name and the values are the two character country codes. - link (
String): Link to the record in the Cannabis Reports API., a unicode string - qr (
String): Link to the QR code for this record., a unicode string - ucpc (
String): UCPC code for this record., a unicode string - updated_at (
CustomDateTime): Localized date and time when this record was modified., a datetime object - url (
String): Link to the record listing on the Cannabis Reports website., a unicode string
-
lineage¶ Countries of origin for the genetics for the strain. Object keys are the country name and the values are the two character country codes.
- created_at (
-
class
cannabis_reports.base_model.LinksModelWithImage(**kwargs)[source]¶ Bases:
cannabis_reports.base_model.BaseModelWithLinksRequired Properties:
- created_at (
CustomDateTime): Localized date and time when this record was created., a datetime object - image (
String): Link to the full size image for this record on Cannabis Reports., a unicode string - link (
String): Link to the record in the Cannabis Reports API., a unicode string - qr (
String): Link to the QR code for this record., a unicode string - ucpc (
String): UCPC code for this record., a unicode string - updated_at (
CustomDateTime): Localized date and time when this record was modified., a datetime object - url (
String): Link to the record listing on the Cannabis Reports website., a unicode string
-
image¶ Link to the full size image for this record on Cannabis Reports.
- created_at (
cannabis_reports.exceptions module¶
-
exception
cannabis_reports.exceptions.CannabisReportsException(message)[source]¶ Bases:
exceptions.ExceptionBase exception for CannabisReports library errors.
-
exception
cannabis_reports.exceptions.CannabisReportsRemoteException(status_code, message)[source]¶ Bases:
cannabis_reports.exceptions.CannabisReportsExceptionIndicates that an error occurred when communicating with the remote.
-
exception
cannabis_reports.exceptions.CannabisReportsSecurityException(message)[source]¶ Bases:
cannabis_reports.exceptions.CannabisReportsExceptionIndicates a security error; probably by an invalid web hook signature.
-
exception
cannabis_reports.exceptions.CannabisReportsValidationException(message)[source]¶ Bases:
cannabis_reports.exceptions.CannabisReportsExceptionIndicates an error while validating user-supplied data.
Module contents¶
-
class
cannabis_reports.AuthProxy(session, proxy_class)[source]¶ Bases:
objectThis object acts as a transparent authentication proxy for the API.
This is required because the API objects are naive of the authentication that is setup in
CannabisReports, and all of the API interface methods areclassmethodsbecause they are instantiating.-
METHOD_NO_PROXY= ['auth_proxy']¶
-
auth_proxy(method)[source]¶ Authentication proxy for API requests.
This is required because the API objects are naive of
CannabisReports, so they would otherwise be unauthenticated.Parameters: method (callable) – A method call that should be authenticated. It should accept a requests.Sessionas its first parameter, which should be used for the actual API call.Returns: The results of the authenticated callable. Return type: mixed
-
-
class
cannabis_reports.BaseApi[source]¶ Bases:
objectThis is the API interface object to be implemented by API adapters.
It acts as a collection for the API object that it represents, passing through iteration to the API’s request paginator.
-
BASE_URI¶ str – CannabisReports API URI base.
-
paginator¶ RequestPaginator – Object to use for producing an iterator representing multiple requests (API response pages). Created on init.
-
__object__¶ cannabis_reports.models.BaseModel – Model object that API represents.
-
BASE_URI= 'https://www.cannabisreports.com/api/v1.0'
-
classmethod
get(session, ucpc)[source]¶ Gets an individual object based on the UCPC.
Parameters: Returns: The object that was found.
Return type: cls.__object__
-
classmethod
list(session, sort='created_at', descending=False, limit=None)[source]¶ Return all objects, with optional sorting.
Parameters: Returns: Objects iterator.
Return type: RequestPaginator(output_type=cls.__object__)
-
classmethod
new_object(data)[source]¶ Return a new object of the correct type from the data.
Parameters: data (dict) – Data dictionary that should be converted to an object. It can use either camelCase keys or snake_case. Returns: A model of the type declared in cls.__object__.Return type: BaseModel
-
paginator= None
-
-
class
cannabis_reports.BaseModel(**kwargs)[source]¶ Bases:
properties.base.base.HasPropertiesThis is the model that all other models inherit from.
It provides some convenience functions, and the standardidproperty.Required Properties:
- created_at (
CustomDateTime): Localized date and time when this record was created., a datetime object - ucpc (
String): UCPC code for this record., a unicode string - updated_at (
CustomDateTime): Localized date and time when this record was modified., a datetime object
-
created_at¶ Localized date and time when this record was created.
-
classmethod
from_api(**kwargs)[source]¶ Create a new instance from API arguments.
This will switch camelCase keys into snake_case for instantiation.
It will also identify any
InstanceorListproperties, and instantiate the proper objects using the values. The end result being a fully Objectified and Pythonified API response.Returns: Instantiated model using the API values. Return type: BaseModel
-
to_api()[source]¶ Return a dictionary to send to the API.
Returns: - Mapping representing this object that can be sent to the
- API.
Return type: dict
-
updated_at¶ Localized date and time when this record was modified.
- created_at (
-
class
cannabis_reports.CannabisReports(api_key=None)[source]¶ Bases:
objectThis object is the primary point of interaction with CannabisReports.
Properties will be set on this
CannabisReportsinstance that will mirror the class names of APIs in thecannabis_reports.apimodule.These API classes are naive of authentication, so the actual properties set will be using the
AuthProxyclass, which will transparently inject authentication into the API requests while still allowing for a naive API object.This allows for the
CannabisReportsinstance to act as a container for all of the authenticated API objects.Examples:
from cannabis_reports import CannabisReports cr = CannabisReports('api_key') for strain in cr.Strains.list(): print(strain.serialize())