Package: drivelinepy
DrivelinepyInstallationpip install drivelinepy.env example for credentialsIf interested in using a.envfile,pip install python-dotenvin your root application.To load your.envfile in the application code.from dotenv import load_dotenv
load_dotenv()Example contents of.envVIRTUAGYM_API_KEY = "redacted"
VIRTUAGYM_CLUB_SECRET = "redacted"
VIRTUAGYM_SCHEDULE_ID = "redacted"
VIRTUAGYM_CLUB_ID = "redacted"

ZOHO_ORGANIZATION_ID = "redacted"
ZOHO_REFRESH_TOKEN = "redacted"
ZOHO_ACCESS_TOKEN = "redacted"
ZOHO_CLIENT_SECRET = "redacted"
ZOHO_CLIENT_ID = "redacted"
ZOHO_BILLINGS_REDIRECT_URI = "www.zohoapis.com/subscriptions"
ZOHO_GRANT_TYPE = "refresh_token"

SLACK_API_TOKEN = "redacted"
SLACK_API_CHANNEL = "redacted"
SLACK_UPLOAD_FILE_API_URL = "https://slack.com/api/files.upload"VirtuagymAPIusing v1https://github.com/virtuagym/Virtuagym-Public-API/wikiVirtuagymAPIextendsBaseAPIWrapperto interact with the Virtuagym API. Initialize it with your API key and club secret:Initialization Exampleimport os
from drivelinepy import VirtuagymAPI 

from dotenv import load_dotenv
load_dotenv()

import logging
logging.basicConfig(
    level=logging.INFO,
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
)

#=================================================================
# Function Definition 
#=================================================================

def main():
    
    #-----------------------------------------------------------------
    # Initialize logging and variables
    #-----------------------------------------------------------------
    logging.info("Initializing...")
    vg_api_key = os.getenv("VIRTUAGYM_API_KEY")
    vg_club_secret = os.getenv("VIRTUAGYM_CLUB_SECRET")

    #-----------------------------------------------------------------
    # Initialize Virtuagym Object
    #-----------------------------------------------------------------

    vg_client = VirtuagymAPI(vg_api_key, vg_club_secret)

    logging.info("Initialization complete!")

    #-----------------------------------------------------------------
    # Do Something...
    #-----------------------------------------------------------------
    
#=================================================================
# Main
#=================================================================

if __name__ == "__main__":
    main()Get Club Eventsclub_id = "your_club_id"  # Replace with the actual club ID
timestamp_start = 1704355200  # Replace with the start timestamp in milliseconds
timestamp_end = 1704441599  # Replace with the end timestamp in milliseconds

club_events = vg_client.get_club_events(club_id, timestamp_start, timestamp_end)
print("Club Events:", club_events)Get Event Participantsclub_id = "your_club_id"
event_id = "your_event_id"

event_participants = vg_client.get_event_participants(club_id, event_id=event_id)
print("Event Participants:", event_participants)Get Club Membersclub_id = "your_club_id"

# Fetch all members
all_members = vg_client.get_club_members(club_id)
print("All Club Members:", all_members)

# Fetch a specific member by their club member ID
club_member_id = "member_id"  # Replace with the specific club member ID
specific_member = vg_client.get_club_members(club_id, club_member_id=club_member_id)
print("Specific Member Details:", specific_member)Zoho APIDeveloper ConsoleBefore working with Zoho APIs, you will need to obtain access to a Zoho Account to access the Developer Consolehttps://api-console.zoho.com/A common scope string belowZohoCRM.modules.READ,ZohoSubscriptions.customers.READ,ZohoSubscriptions.subscriptions.READ,ZohoSubscriptions.invoices.READ,ZohoSubscriptions.creditnotes.READZoho Billing APIhttps://www.zoho.com/billing/api/v1/introduction/#overviewZohoBillingAPIis tailored for the Zoho Billing API. This class extends theBaseAPIWrapperto specifically handle the authentication and request patterns for Zoho's Billing services. Key functionalities include refreshing OAuth tokens, fetching subscription data, and handling Zoho-specific API requests.InitializationTo initialize and useZohoBillingAPI, provide your client ID, client secret, refresh token, and organization ID:import os
from drivelinepy import ZohoBillingAPI

from dotenv import load_dotenv
load_dotenv()

import logging
logging.basicConfig(level=logging.INFO)

#=================================================================
# Function Definition 
#=================================================================

def main():
    #-----------------------------------------------------------------
    # Initialize logging and variables
    #-----------------------------------------------------------------
    client_id = os.getenv("ZOHO_CLIENT_ID")  
    client_secret = os.getenv("ZOHO_CLIENT_SECRET")
    refresh_token = os.getenv("ZOHO_REFRESH_TOKEN")
    organization_id = os.getenv("ZOHO_ORGANIZATION_ID")

    #-----------------------------------------------------------------
    # Initialize Virtuagym Object
    #-----------------------------------------------------------------
    zoho_billing_api = ZohoBillingAPI(client_id, client_secret, refresh_token, organization_id)

#=================================================================
# Main
#=================================================================
if __name__ == "__main__":
    main()Get CustomersTheget_customers()method is an essential feature of the API interface, allowing for the retrieval of customer data from the Zoho Billing API.Parameterscustomer_id: (Optional) A unique identifier for a specific customer.name: (Optional) The name of the customer to be fetched.email: (Optional) The email address of the customer to be fetched.phone: (Optional) The phone number of the customer to be fetched.filter_by: (Optional) A string to filter customers by specific criteria, such as 'Status.Active'.page: (Optional) The page number for pagination, defaulting to the first page.UsageGet all customerscustomer_details = zoho_billing_api.get_customers()Get customer by customer idcustomer_id = "customer-id-here"
customer_details = zoho_billing_api.get_customers(customer_id=customer_id)Get customers by name - note the API is usingdisplay_name_containsvs using an exact matchcustomer_name = "insert-name-here"
customers = zoho_billing_api.get_customers(name=customer_name)Get customer by emailcustomer_email = "insertemail@gmail.com"
customers = zoho_billing_api.get_customers(email=customer_email)Get customer by phonecustomer_phone = "4255551234"
customers = zoho_billing_api.get_customers(phone=customer_phone)Get customers with filtercustomer_filter = "Active"
filtered_customers = zoho_billing_api.get_customers(filter=customer_filter)Available Filtershttps://www.zoho.com/billing/api/v1/customers/#list-all-customersGet SubscriptionsTheget_subscriptions()method is designed to fetch subscription data from the Zoho Billing API.Parameterssubscription_id: (Optional) A unique identifier for a specific subscription.customer_id: (Optional) A unique identifier for a customer. Used to fetch subscriptions associated with this customer.filter_by: (Optional) A status value to filter subscriptions. Examples include "Active", "Expired", etc.page: (Optional) Page number for pagination, defaulting to the first page.UsageGet all subscriptionssubscriptions = zoho_billing_api.get_subscriptions()Get subscriptions by subscription idsubscription_id = "insert-sub-id-here"
subscriptions = zoho_billing_api.get_subscriptions(subscription_id=subscription_id)Get subscriptions by customer idcustomer_id = "insert-customer-id"
subscriptions = zoho_billing_api.get_subscriptions(customer_id=customer_id)Get subscriptions with filtersubscription_filter = 'ACTIVE'
subscriptions = zoho_billing_api.get_subscriptions(filter_by=subscription_filter)Available filtershttps://www.zoho.com/billing/api/v1/subscription/#list-all-subscriptionsGet InvoicesTheget_invoices()method allows for fetching invoices from the Zoho Billing API based on specified criteria.Parameters:invoice_id(optional): Fetches a specific invoice.customer_id(optional): Filters invoices for a specific customer.subscription_id(optional): Filters invoices for a specific subscription.filter_by(optional): Filters invoices by their status.page(optional, default=1): Specifies the page number of results.UsageGet all invoicesinvoices = zoho_billing_api.get_invoices()Get invoice by invoice idinvoice_id = "insert-invoice-id"
invoices = zoho_billing_api.get_invoices(invoice_id=invoice_id)Get invoice by customer idcustomer_id = "insert-customer-id"
invoices = zoho_billing_api.get_invoices(customer_id=customer_id)Get invoice by subscription idsubscription_id = "insert-subs-id"
invoices = zoho_billing_api.get_invoices(subscription_id=subscription_id)Get invoice with filterinvoice_filter = "Paid"
invoices = zoho_billing_api.get_invoices(filter_by=invoice_filter)Get Credit NotesTheget_credit_notes()method is a part of our API interface to interact with the Zoho Billing API, specifically designed to retrieve credit note data.Parameterscredit_note_id: (Optional) A unique identifier for a specific credit note.customer_id: (Optional) A unique identifier for a customer, used to filter credit notes associated with this customer.customer_name: (Optional) The name of the customer, used to fetch credit notes associated with this customer.filter_by: (Optional) A string to filter credit notes by specific criteria, such as 'Status.Active'.page: (Optional) The page number for pagination, defaulting to the first page.UsageGet all credit notescredit_notes = zoho_billing_api.get_credit_notes()Get credit notes by customer idcustomer_id = "insert-customer-id"
credit_notes = zoho_billing_api.get_credit_notes(customer_id=customer_id)Get credit notes by customer namecustomer_name = "John Doe"
credit_notes = zoho_billing_api.get_credit_notes(customer_name=customer_name)Get credit notes with filtercredit_note_filter = "Open"
credit_notes = zoho_billing_api.get_credit_notes(filter_by=credit_note_filter)Clarifying FiltersIf you do not feel like looking through the code to find the filters available you can use the following methodsGet valid subscription filterssubscription_filters = zoho_billing_api.get_subscription_filters()Get valid customer status filterscustomer_status_filters = zoho_billing_api.get_customer_status_filters()Get valid invoice filtersinvoice_filters = zoho_billing_api.get_invoice_filters()Get valid credit note status filterscredit_note_status_filters = zoho_billing_api.get_credit_note_status_filters()A check occurs when you call the respective get data method so you do not have to add checks for valid filter in the application code. These are purely nice-to-haves.Zoho CRM APIZohoCrmAPIis designed for interacting with Zoho's Customer Relationship Management (CRM) services. This class extends theBaseAPIWrapper, handling authentication and specific request patterns for Zoho CRM. It primarily focuses on fetching customer records from different modules like Contacts and Leads. It manages OAuth tokens, supports pagination, and can fetch specific fields from the CRM records.InitializationTo useZohoCrmAPI, provide your client ID, client secret, refresh token, and organization ID:import os
from drivelinepy import ZohoCrmAPI

from dotenv import load_dotenv
load_dotenv()

import logging
logging.basicConfig(level=logging.INFO)

#=================================================================
# Function Definition 
#=================================================================

def main():
    #-----------------------------------------------------------------
    # Initialize logging and variables
    #-----------------------------------------------------------------
    client_id = os.getenv("ZOHO_CLIENT_ID")  
    client_secret = os.getenv("ZOHO_CLIENT_SECRET")
    refresh_token = os.getenv("ZOHO_REFRESH_TOKEN")
    organization_id = os.getenv("ZOHO_ORGANIZATION_ID")

    #-----------------------------------------------------------------
    # Initialize Zoho CRM Object
    #-----------------------------------------------------------------
    zoho_crm_api = ZohoCrmAPI(client_id, client_secret, refresh_token, organization_id)

#=================================================================
# Main
#=================================================================
if __name__ == "__main__":
    main()Get Customer RecordsTheget_customer_records()method fetches customer records from the specified module in Zoho CRM. It supports searching by customer ID, first name, last name, or email. By default, it fetches predefined fields from the Contacts module but can be customized for other supported modules.Parametersmodule: The module to fetch records from (e.g., "Contacts", "Leads").customer_id: (Optional) The ID of the customer to fetch specific records.first_name: (Optional) The first name of the customer for searching.last_name: (Optional) The last name of the customer for searching.email: (Optional) The email of the customer for searching.page: (Optional) The page number for pagination, defaulting to the first page.UsageFetch all records from Contacts module:customer_records = zoho_crm_api.get_customer_records(module="Contacts")Fetch a specific customer by ID:customer_id = "customer-id-here"
specific_customer = zoho_crm_api.get_customer_records(module="Contacts", customer_id=customer_id)Search customer by first name:customer_first_name = "John"
customers_by_name = zoho_crm_api.get_customer_records(module="Contacts", first_name=customer_first_name)Search customer by last name:customer_last_name = "Doe"
customers_by_last_name = zoho_crm_api.get_customer_records(module="Contacts", last_name=customer_last_name)Search customer by email:customer_email = "example@example.com"
customers_by_email = zoho_crm_api.get_customer_records(module="Contacts", email=customer_email)Get Supported Modules
The get_supported_modules() method returns the list of modules supported by ZohoCrmAPI. Currently, it supports "Contacts" and "Leads".supported_modules = zoho_crm_api.get_supported_modules()Slack APISlackAPIis designed to interact with the Slack API. It extendsBaseAPIWrapperto provide easy methods for sending messages and performing other actions on Slack. The key feature of this class is the ability to post messages to specified channels in your Slack workspace.PrerequisitesBefore usingSlackAPI, you need to create a Slack app and obtain an OAuth access token with the necessary permissions. You can create a Slack app from theYour Appspage on the Slack API site.Slack API InitializationsTo use SlackAPI, initialize it with your Slack API token:import os
    from drivelinepy import SlackAPI

    from dotenv import load_dotenv
    load_dotenv()

    import logging
    logging.basicConfig(level=logging.INFO)

    #=================================================================
    # Function Definition 
    #=================================================================

    def main():
        #-----------------------------------------------------------------
        # Initialize logging and variables
        #-----------------------------------------------------------------
        slack_api_token = os.getenv("SLACK_API_TOKEN")

        #-----------------------------------------------------------------
        # Initialize Slack API Object
        #-----------------------------------------------------------------
        slack_api = SlackAPI(slack_api_token)

        logging.info("Initialization complete!")

        #-----------------------------------------------------------------
        # Do Something...
        #-----------------------------------------------------------------
        
    #=================================================================
    # Main
    #=================================================================

    if __name__ == "__main__":
        main()Post a MessageThepost_message()method allows you to send a message to a specific channel on Slack. Note, the channel id is a C-code found in the URL of a specific channel in the browser. For example, the following URL was copied when viewing a slack channel in Chromehttps://app.slack.com/client/T03B4SBKE/C01AL24207R-- the slack channel id in this example isC01AL24207R.channel_id = "your-slack-channel-id"
message = "Hello from SlackAPI!"

response = slack_api.post_message(channel_id, message)
print("Response from Slack API:", response)This method takes the channel ID and the message text as parameters and posts the message to the specified Slack channel.TRAQ APITheTRAQAPIclass is designed to interact with the TRAQ API provided by Driveline Baseball. It extendsBaseAPIWrapperand provides functionalities for authenticating and retrieving user information from the TRAQ API.PrerequisitesBefore usingTRAQAPI, you need to obtain your client ID and client secret from TRAQ. These credentials are necessary for authenticating with the TRAQ API.TRAQAPI InitializationInitialize TRAQAPI with your client ID and client secret:import os
from drivelinepy import TRAQAPI

from dotenv import load_dotenv
load_dotenv()

import logging
logging.basicConfig(level=logging.INFO)

#=================================================================
# Function Definition 
#=================================================================

def main():
    #-----------------------------------------------------------------
    # Initialize logging and variables
    #-----------------------------------------------------------------
    traq_client_id = os.getenv("TRAQ_CLIENT_ID")
    traq_client_secret = os.getenv("TRAQ_CLIENT_SECRET")

    #-----------------------------------------------------------------
    # Initialize TRAQ API Object
    #-----------------------------------------------------------------
    traq_api = TRAQAPI(traq_client_id, traq_client_secret)

    logging.info("Initialization complete!")

    #-----------------------------------------------------------------
    # Do Something...
    #-----------------------------------------------------------------
    
#=================================================================
# Main
#=================================================================

if __name__ == "__main__":
    main()Get UsersUse the get_users method to retrieve user information from the TRAQ API. You can search for users by TRAQ ID or email. If both parameters are provided, the method prioritizes the TRAQ ID. One parameter is required.# Retrieve user data by TRAQ ID
traq_id = 6183  # Replace with the actual TRAQ ID
user_data_by_id = traq_api.get_users(traq_id=traq_id)
print("User Data by TRAQ ID:", user_data_by_id)

# Retrieve user data by Email
email = "user@example.com"  # Replace with the actual email address
user_data_by_email = traq_api.get_users(email=email)
print("User Data by Email:", user_data_by_email)This method returns user data in a structured format, providing detailed information about each user.