Skip to content

Commit b0cc7ef

Browse files
committed
Removing update, adding upsert method
1 parent 229280f commit b0cc7ef

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

src/main/java/com/postman/collection/Collection.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -696,16 +696,29 @@ public void writeToFile(File outputFile) throws IOException {
696696
throw(e);
697697
}
698698
}
699-
public void updateInPostman(PostmanID workspaceID) {
699+
700+
/*
701+
*
702+
* Convenience method to upsert a collection to Postman without specifying a workspace ID
703+
*/
704+
705+
public PostmanID upsertToPostman() throws IOException, InterruptedException, CollectionNotFoundException, InvalidCollectionActionException {
706+
{
707+
return upsertToPostman(null);
708+
}
700709

701-
}
702710
/**
703711
*
704-
* Write this collections generated JSON to a file at the specified path. Note that the order of elements in the resulting file is not guaranteed and may not match
705-
* a corresponding Postman generated file. However, this does not affect the validity or functionality of the generated JSON.
712+
* Create or update this collection in Postman.
713+
* - If this collection has a Postman ID, it will be updated in Postman
714+
* - If this collection does not have a Postman ID, it will be created as a new collection, and the ID returned by Postman will be assigned to it.
715+
* - You can optionally include a workspace ID for a workspace to link a newly created collection to.
706716
*
707-
* @param outputFile The file into which to write the JSON
717+
* @param WorkspaceID Optional workspace ID to which to link a newly created collection.
708718
* @throws IOException If there is an error attempting to create or write to the specified path
719+
* @throws InterruptedException If the HTTP request is interrupted
720+
* @throws CollectionNotFoundException if the collection ID is not found in Postman
721+
* @throws InvalidCollectionActionException If an HTTP status code other than 200 or 404 is returned.
709722
*/
710723
public PostmanID upsertToPostman(PostmanID workspaceID) throws IOException, InterruptedException, CollectionNotFoundException, InvalidCollectionActionException {
711724
String colData = this.toJson();

0 commit comments

Comments
 (0)