Skip to content

Commit

Permalink
feat(BitbucketPullRequests): activities of a pull request (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
knowbased authored Feb 6, 2025
1 parent ddf4391 commit f8b3d09
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/BitbucketPharoAPI-Tests/BitbucketPullRequestsTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,44 @@ Class {
#package : 'BitbucketPharoAPI-Tests'
}

{ #category : 'tests' }
BitbucketPullRequestsTest >> testActivitiesOfInRepositoryOfProject [

| hostUrl gitlabApi result client path bitbucketPullRequests pullRequestID projectKey repoSlug pullRequestActivity |
"Given"
hostUrl := 'www.url.com'.
client := ZnClient new.

gitlabApi := BitbucketApi new
bearerToken: 'token';
host: hostUrl;
client: client.

bitbucketPullRequests := BitbucketPullRequests new bitbucketApi:
gitlabApi.

pullRequestID := 24.
projectKey := 'AAA'.
repoSlug := 'project'.

pullRequestActivity := { (#pullRequestActivity -> pullRequestID) } asDictionary.

path := '/projects/' , projectKey , '/repos/' , repoSlug
, '/pull-requests/' , pullRequestID asString , '/activities'.

(bitbucketPullRequests stub getAll: path withParams: Dictionary new)
willReturn: pullRequestActivity.

"When"
result := bitbucketPullRequests
activitiesOf: pullRequestID
inRepository: repoSlug
ofProject: projectKey.

"Then"
self assert: result equals: pullRequestActivity
]

{ #category : 'tests' }
BitbucketPullRequestsTest >> testCreateFromRefToRefInRepositoryOfProject [

Expand Down
11 changes: 11 additions & 0 deletions src/BitbucketPharoAPI/BitbucketPullRequests.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ Class {
#package : 'BitbucketPharoAPI'
}

{ #category : 'api - get' }
BitbucketPullRequests >> activitiesOf: pullRequestId inRepository: repositorySlug ofProject: projectKey [
"GET /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/activities"

| endpoint |
endpoint := '/projects/' , projectKey , '/repos/' , repositorySlug
, '/pull-requests/' , pullRequestId asString , '/activities'.

^ self getAll: endpoint withParams: Dictionary new.
]

{ #category : 'api - post' }
BitbucketPullRequests >> create: title fromRef: fromRefId toRef: toRefId inRepository: repositorySlug ofProject: projectKey [
"POST /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests"
Expand Down

0 comments on commit f8b3d09

Please sign in to comment.