MCPcopy Index your code
hub / github.com/simstudioai/sim / fetchUsers

Function fetchUsers

apps/sim/tools/jira/get_users.ts:99–130  ·  view source on GitHub ↗
(cloudId: string)

Source from the content-addressed store, hash-verified

97
98 transformResponse: async (response: Response, params?: JiraGetUsersParams) => {
99 const fetchUsers = async (cloudId: string) => {
100 let usersUrl: string
101 if (params!.accountId) {
102 usersUrl = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/user?accountId=${encodeURIComponent(params!.accountId)}`
103 } else {
104 const queryParams = new URLSearchParams()
105 if (params!.startAt !== undefined) queryParams.append('startAt', String(params!.startAt))
106 if (params!.maxResults !== undefined)
107 queryParams.append('maxResults', String(params!.maxResults))
108 const queryString = queryParams.toString()
109 usersUrl = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/users/search${queryString ? `?${queryString}` : ''}`
110 }
111
112 const usersResponse = await fetch(usersUrl, {
113 method: 'GET',
114 headers: {
115 Accept: 'application/json',
116 Authorization: `Bearer ${params!.accessToken}`,
117 },
118 })
119
120 if (!usersResponse.ok) {
121 let message = `Failed to get Jira users (${usersResponse.status})`
122 try {
123 const err = await usersResponse.json()
124 message = err?.errorMessages?.join(', ') || err?.message || message
125 } catch (_e) {}
126 throw new Error(message)
127 }
128
129 return usersResponse.json()
130 }
131
132 let data: any
133

Callers 1

get_users.tsFile · 0.70

Calls 2

joinMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected