Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
16 changes: 16 additions & 0 deletions src/Collaborators/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@ import { App } from "../models/regional/apps";
import {
Collaborator,
CollaboratorInvitation,
ExtendedCollaborator,
} from "../models/regional/collaborators";
import { unpackData } from "../utils";

export type IndexQuery = NonNullable<unknown>;

export interface IndexResponse {
collaborators: ExtendedCollaborator[];
}

/**
* Collaborators API Client
*/
Expand Down Expand Up @@ -74,4 +81,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 }),
);
}
}
9 changes: 9 additions & 0 deletions src/models/regional/collaborators.ts
Copy link
Contributor

@aurelien-reeves-scalingo aurelien-reeves-scalingo Nov 27, 2024

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 @@ -35,3 +35,12 @@ export interface CollaboratorInvitation {
/** Link of for the invitation */
invitation_link: string;
}

export interface ExtendedCollaborator extends Collaborator {
/** Name of the application owning the collaborator */
app_name: string;
/** Username of the collaborator */
user_username: string;
/** Email of the collaborator */
user_email: string;
}
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();
},
);
});