Giter Club home page Giter Club logo

connectpyse's People

Contributors

aidenwebb avatar bzoel avatar emichaud avatar joshuamsmith avatar markciecior avatar nwilkens avatar philipprieth avatar wesgann avatar zebble avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

connectpyse's Issues

_info object doesn't work with Django template system

Hey there,
###kudos for a nice implementation of the CW api's.

I'm building an app with Django and I've had issues with their template system when trying to extract elements from an _info object.

Accessing this object in Python is straightforward, but retrieving it via Django template fails.

** works fine **
def get_ticket_by_id(ticket_id):
api = tickets_api.TicketsAPI(url=BASE_URL, auth=AUTH)
ticket = api.get_ticket_by_id(ticket_id)
return ticket

t = get_ticket_by_id('442996')
print(t._info['lastUpdated'])

** fails **
{{ t._info['lastUpdated'] }}

My work around was to simply load the object into a separate dictionary and pass that along with the ticket object to the template system.

context = {}
ticket = cwapi.get_ticket_by_id(item)
info = ticket._info
if ticket:
context.update({'ticket':ticket})
context.update({'info':info})

return render(request, page_url, context)

While it seems obvious now, it wasn't at first and took me a bit to figure out what was going on. Maybe this will be helpful to someone else.

Support for customFields or configuration questions

I'm wondering if there is support for custom fields, or in particular for what I'm working on right now configuration questions?

If I'm understanding things correctly, these are both presented as lists of dictionaries, compared to things like company and site that are presenting as a dictionary and where the "sub-attributes" are used.
For example printing out custom fields shows:
customFields: [{'id': 7, 'caption': 'Link', 'type': 'Hyperlink', 'entryMethod': 'EntryField', 'numberOfDecimals': 0, 'value': 'https://www.example.net/1234}]
... and configuration questions similarly as:
questions: [{'answerId': 1014, 'questionId': 502, 'question': 'What is the IP address?', 'answer': '192.168.1.66', 'sequenceNumber': 1.0, 'numberOfDecimals': 0, 'fieldType': 'IPAddress', 'requiredFlag': False}]

I thought it might work with something along the lines of: configurationsApi.update_configuration(configId, 'customFields/id=7', 'https://www.example.net/1235')
...or configurationsApi.update_configuration(configId, 'questions/questionId=502', '192.168.1.65')

NB: I have tested the update method with sub-attributes and it works perfectly - in case this is useful for others or worth documenting: configurationsApi.update_configuration(configId, 'site/id', 1078)
Also useful in the main readme might be how multiple conditions can be used e.g. configurationsApi.conditions = f'type/id=100 AND name contains "{searchString}"' (also noting that the CW API expects search strings to be enclosed with double quotes)

clientId support

Latest revisions of connectwise require the use of a clientId in the header to access the API.

I can see how to use connectpyse with the v4_6_release URL, I don't easily see how to incorporate the use of a clientId to access, for example, v2020_2, doing it the 'new_way'

Is there a standard way to add the clientId to the request header?

Some request get limited to 25 results

Thanks for your your work maintaining this API for Connectwise, simple to work with. how do you access more records. I know the API limits results to 25. how do you either paginate results or expand the pagesize of results to the limit of 1000 records?

service/tickets/{id}

response is:
Server message:{
"code": "ConnectWiseApi",
"message": "Length cannot be less than zero.\r\nParameter name: length",
"errors": null
}

Agreements Api failing to initialize

When I run this code:

def get_agreements():
api = agreements_api.AgreementsAPI(url=BASE_URL, auth=AUTH)
agreement_list = api.get_agreements()
return {'agreements':agreement_list}

al = get_agreements()

I get this result:

Traceback (most recent call last):
File "Untitled 2.py", line 54, in
al = get_agreements()
File "Untitled 2.py", line 49, in get_agreements
api = agreements_api.AgreementsAPI(url=BASE_URL, auth=AUTH)
TypeError: init() missing 1 required positional argument: 'base_url'

I have everything working with service tickets, but not sure how to initialize the Agreements API?

Ticket Creation

Here with another question. Trying to create a ticket, but keep getting error
AttributeError("'dict' object has no attribute '__dict__'")

Below is my code. Thanks again for all the help so far :)

def createStafftopBlockTicket(): ct = tickets_api.TicketsAPI(url=cw.cwURL, auth=cw.cwAUTH) ticketInfo = { "summary": "This is a test of the API broadcast system", "company": { "id":"company_id" }, "board": { "name": "board_name" }, "resources": "resource_to_assign" } print(ticketInfo) ct = ct.create_ticket(ticketInfo)

Make 2 PATCHes at once

How would I do this:

[
{
"op": "replace",
"path": "receivedStatus",
"value": "PartiallyReceiveCloneRest"
},
{
"op": "replace",
"path": "receivedQuantity",
"value": 1
}
]

URL is: {{baseUrl}}/procurement/purchaseorders/:parentId/lineitems/:id

Worked in Postman but can't figure it out in the client.

Thanks!

Add documentation to show how to use the create_ functions

While attempting to use ticket_notes.create_ticket_note(a_ticket_note), (or any .create() function) it is not clear how what a_ticket_note should be,

An example of the create() functions in the README would be helpful for future users.

Support for child items

I'm wondering how to get child item info.

i.e. /service/boards/{id}/statuses

(Same with board types, subtypes, etc.)

Setup (New way)

I am rather new to python. for the new way setup I am a bit confused.

Create two variables which are passed to the constructor of the API classes.
URL = 'https://connectwise.mycompany.com/v4_6_release/apis/3.0'
AUTH = {'Authorization': 'Basic Wmdlasdkjfeklamwekf=', 'clientId': 'myClientIdKey'}

for URL= We have a cloud based so for this would i use, 'https://api-na.myconnectwise.net/v2021.1/apis/3.0' or 'https://na.myconnectwise.net/v2021.1/apis/3.0'

for AUTH = what/where does "Basic Wmdlasdkjfeklamwekf" come from? Am i suppose to use my Public/Private API key, there? I have entered the clientid we have.

Thank you for your help!

CreateTimeEntry

I am using the API to create a time entry, but seem to be having issues.

def createTimeEntry(): time_Entry = time_entries_api.TimeEntriesAPI(url=URL, auth=AUTH) note = time_entry.TimeEntry({ 'chargeToId': TICKET_ID, 'chargeToType': 'ServiceTicket', 'member': {"identifier": "User"}, 'workType':'name/Remote', 'timeStart': '2022-01-06T12:00:00Z', 'timeEnd':'2022-01-06T21:00:00Z', 'hoursDeduct': '1.98', 'billableOption': 'Billable', 'notes': 'notes' }) time_Entry.create_time_entry(note)

The error I get is "connectpyse.restapi.ApiError: POST entries Return code: 404"

Is there something I am doing wrong?

Time Entry Question

When I try to make a time entry, I get a security error.

Server message:{
"code": "Security",
"message": "You do not have security permission to perform this action."
}

I am able to make TimeEntries for myself in the Manage App itself, but not through the API.

def createTimeEntryCP(TicketNumber,User):
time_Entry = time_entries_api.TimeEntriesAPI(url=cwURL, auth=config['cwHeaders'],)
note = time_entry.TimeEntry({
'chargeToId': TicketNumber,
'chargeToType': 'ServiceTicket',
'member': {"identifier": User},
'workType': {"name": "Remote"},
'timeStart': '2022-01-17T12:00:00Z',
'timeEnd':'2022-01-17T21:00:00Z'
})
time_Entry.create_time_entry(note)

Am I doing something incorrect here, or is it a restriction on my account?

Issue with Upload Document for Ticket

I am trying to upload a document to a ticket but keep getting error;
"raise Exception('Document creation only supported for Tickets, Opportunities, and Companies')"
o = tickets_api.TicketsAPI(url=cw.cwURL, auth=cw.cwAUTH)
d = document_api.DocumentAPI(url=cw.cwURL, auth=cw.cwAUTH)
file_name = '{}.xlsx'.format(idName)
file_location=r'{}'.format(file_name)
a_ticket = o.get_ticket_by_id(ticket_id=i)
f = os.path.join(os.path.curdir, file_location)
a_document = d.create_document(o, 'Newly Uploaded Document', file_name, open(f, 'rb'))
print(a_document.title)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.