Skip to content

Commit

Permalink
add API to get a user by its accountID
Browse files Browse the repository at this point in the history
  • Loading branch information
badetitou committed Aug 8, 2024
1 parent 171763f commit 9cb608a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
26 changes: 24 additions & 2 deletions src/JiraPharoAPI/JiraPharoAPI.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Class {
'rawData',
'generalReader'
],
#category : 'JiraPharoAPI'
#category : #JiraPharoAPI
}

{ #category : #api }
Expand Down Expand Up @@ -181,6 +181,12 @@ JiraPharoAPI >> configureReaderForJiraIssue: reader [
pharoIssue assignee: (JPUser fromDictionary: assignee) ] ] ] ]
]

{ #category : #'api - issue search' }
JiraPharoAPI >> configureReaderForJiraUser: reader [

reader for: JPUser do: [ :mapping | mapping mapAllInstVars ]
]

{ #category : #'api - issue search' }
JiraPharoAPI >> configureReaderForJiraWorkload: reader [

Expand Down Expand Up @@ -219,6 +225,21 @@ JiraPharoAPI >> generalReader: anObject [
generalReader := anObject
]

{ #category : #'api - user' }
JiraPharoAPI >> getUser: accountId [
"https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-users/#api-rest-api-2-user-get"

self prepareZnClient.
znClient path: self basePath , '/user'.
znClient queryAt: 'accountId' put: accountId.
self rawData ifFalse: [
znClient contentReader: [ :entity |
generalReader
on: entity contents readStream;
nextAs: JPUser ] ].
^ znClient get
]

{ #category : #initialization }
JiraPharoAPI >> initialize [

Expand All @@ -229,7 +250,8 @@ JiraPharoAPI >> initialize [
self rawData: false.
generalReader := NeoJSONReader new.
self configureReaderForJiraIssue: generalReader.
self configureReaderForJiraWorkload: generalReader
self configureReaderForJiraWorkload: generalReader.
self configureReaderForJiraUser: generalReader
]

{ #category : #accessing }
Expand Down
6 changes: 5 additions & 1 deletion src/JiraPharoAPI/JiraPharoImporter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ JiraPharoImporter >> ensureUser: aPotentialUser [
JiraPharoImporter >> extractAllIssuesFromQuery: jqlQuery [

| issues tmp |
('Extract all issues from query ' , jqlQuery) recordDebug.
('Extract all issues from query ' , jqlQuery) recordInfo.
issues := OrderedCollection new.
('Extract issues from ' , issues size printString , ' to '
, (issues size + 100) printString) recordInfo.
tmp := self api
searchIssueWithExpand: nil
fields: { '*all' }
Expand All @@ -75,6 +77,8 @@ JiraPharoImporter >> extractAllIssuesFromQuery: jqlQuery [

issues addAll: tmp issues.
[ tmp issues isNotEmpty ] whileTrue: [
('Extract issues from ' , issues size printString , ' to '
, (issues size + 100) printString) recordInfo.
tmp := self api
searchIssueWithExpand: nil
fields: { '*all' }
Expand Down

0 comments on commit 9cb608a

Please sign in to comment.