Comments (9)
Hi @rishi-freshbooks, It's a bit funny how Zendesk organized this. Each User
is tied to one organization when you query the user API (https://developer.zendesk.com/rest_api/docs/core/users) and can be retrieved via the organization
property in Zenpy:
for user in zenpy.users():
print(user.organization)
There is also an organizations endpoint (https://developer.zendesk.com/rest_api/docs/core/organizations) which takes a User
id and returns all organizations associated with that user:
for organization in zenpy.users.organizations(user_id=5386846818):
print(organization)
If you are looking for all organizations associated with a User
then the second one is what you want. Hope this helps!
from zenpy.
Thanks @facetoe! Is there a way to link a user to more than 1 organization?
from zenpy.
Zenpy doesn't support this directly however it would be easy to do in your own code with the users.organizations
endpoint.
from zenpy.
Factoe would you be able to implement this endpoint? https://developer.zendesk.com/rest_api/docs/core/organization_memberships
from zenpy.
Ahh most definitely, that looks really handy. I'll create an issue for it and try to implement it in the next week or so. Good spot!
from zenpy.
Hi @rishi-freshbooks, I've implemented part of the functionality for organization memberships in a9c4ba2. You can query organization memberships:
# To see all organization memberships
for org_memb in zenpy.organization_memberships():
print(org_memb)
# Or for each user (also works for each organization)
for user in zenpy.users():
for org_memb in zenpy.users.organization_memberships(user_id=user.id):
print(org_memb)
And also create and delete them:
obj = OrganizationMembership(user_id=1111, organization_id=222222)
created_orgmemb = zenpy.organization_memberships.create(obj)
zenpy.organization_memberships.delete(created_orgmemb)
There is some functionality I didn't implement as I figured it was unlikely to be used. If you want to use any of the un-implemented functionality let me know and I will have a look at adding it as well.
Let me know if you find any bugs!
from zenpy.
Thanks @facetoe! This is great. Do you mind bumping the version and creating a tag, so we can install this new endpoint
from zenpy.
No worries, it's done!
from zenpy.
Hey @facetoe,
Thanks for this. Is it possible to create OrganizationMembership with user and organization objects instead of ids?
Thanks
from zenpy.
Related Issues (20)
- Can we have APIException inherit from ZenpyException? HOT 1
- [Question] Events - Ticket Updated/Solved/Closed
- Support for Show Membership API HOT 1
- Create ticket for group HOT 2
- RecordNotFoundException when creating articles? HOT 3
- [Question] How to get custom field value without index? HOT 1
- Can't assign form id when creating a ticket HOT 1
- zenpy.user.create_or_update users appears to be erroring? HOT 10
- Can not find the custom field option of an organization field HOT 1
- SSL Error HOT 2
- Trying to add an attachments returns response 201
- proactive_ratelimit has the inverse result from expected.
- Search through the articles HOT 2
- Get Articles - requires locale HOT 3
- Idempotent ticket creation
- [Question] Does the library support Search Organizations by External ID HOT 2
- Request to migrate library from Offset Based Pagination to Cursor Based Pagination HOT 9
- Deleted Tickets HOT 1
- Can't apply macro to ticket
- Create new user field HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zenpy.