Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add collaborators.all #399

Merged
merged 3 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/Collaborators/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ import {
} from "../models/regional/collaborators";
import { unpackData } from "../utils";

export type IndexQuery = NonNullable<unknown>;

export interface IndexResponse {
collaborators: Collaborator[];
}

/**
* Collaborators API Client
*/
Expand Down Expand Up @@ -74,4 +80,13 @@ export default class Collaborators {
.get("/apps/collaboration", { params: { token: token } }),
);
}

/**
* list all request owner collaborators
*/
all(params: IndexQuery): Promise<IndexResponse> {
return unpackData(
this._client.apiClient().get("/collaborators", { params }),
);
}
}
2 changes: 2 additions & 0 deletions src/models/regional/collaborators.ts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to use optional properties?

Also, could we craft the API endpoint for it to return the actual username and email of the registered user when the user has accepted the invite?

Thus, we would not need a new "extended" interface

export interface Collaborator {
  /** Id of the collaborator */
  id: string;
  /** Email of the collaborator to invite */
  email: string;
  /** Unique User ID of the user who accepted the collaboration */
  user_id: string;
  /** ID of the application owning the collaborator */
  app_id: string;
  /** Username of the person to invite */
  username: string;
  /** Status of the invitation */
  status: string;
  /** Name of the app */
  app_name?: string;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I already implemented it locally :)

Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export interface Collaborator {
username: string;
/** Status of the invitation */
status: string;
/** Name of the application owning the collaborator */
app_name?: string;
}

export interface CollaboratorInvitation {
Expand Down
11 changes: 11 additions & 0 deletions test/Collaborators/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,14 @@ describe("Collaborators#inviteAccept", () => {
},
);
});

describe("Collaborators#all", () => {
testGetter(
"https://api.osc-fr1.scalingo.com/v1/collaborators",
{},
null,
(client) => {
return new Collaborators(client).all();
},
);
});