-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add clients, update vpb client to pb client * add tests * fix test name * modify changelog * leave vpb as is,add new pb client * upgrade version, fix javadocs * fix javadoc * add all clients * Update CHANGELOG.md Co-authored-by: Matt Wisniewski <[email protected]> Co-authored-by: Matt Wisniewski <[email protected]>
- Loading branch information
1 parent
7897f67
commit 866f9a7
Showing
20 changed files
with
1,452 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
src/main/java/com/jwplayer/jwplatform/client/MediaRenditionClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
package com.jwplayer.jwplatform.client; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import org.json.JSONObject; | ||
|
||
import com.google.common.base.Preconditions; | ||
import com.jwplayer.jwplatform.exception.JWPlatformException; | ||
import com.jwplayer.jwplatform.rest.HttpCalls; | ||
|
||
/** | ||
* JW Platform MediaRendition API client. | ||
* | ||
* <p> | ||
* An API client for the JW Platform MediaRendition API. For the API documentation | ||
* see: <a href= | ||
* "https://developer.jwplayer.com/jwplayer/reference#introduction-to-api-v2">Introduction | ||
* to api v2</a> | ||
* | ||
* <p> | ||
* Example: MediaRenditionClient client = MediaRenditionClient.getClient(secret); | ||
*/ | ||
public class MediaRenditionClient extends JWPlatformClientV2 { | ||
|
||
private String path; | ||
private final String secret; | ||
|
||
/** | ||
* Instantiate a new {@code MediaRenditionClient} instance. | ||
* | ||
* @param secret - your api secret | ||
*/ | ||
private MediaRenditionClient(String secret) { | ||
this.secret = secret; | ||
this.path = "https://api.jwplayer.com/v2/sites/%s/media/%s/media_renditions/"; | ||
headers = new HashMap<>(); | ||
headers.put("Authorization", "Bearer " + this.secret); | ||
headers.put("accept", "application/json"); | ||
headers.put("Content-Type", "application/json"); | ||
} | ||
|
||
/** | ||
* see {@link #MediaRenditionClient(String)}. | ||
*/ | ||
public static MediaRenditionClient getClient(String secret) { | ||
Preconditions.checkNotNull(secret, "API Secret must not be null!"); | ||
return new MediaRenditionClient(secret); | ||
} | ||
|
||
/** | ||
* | ||
* @param siteId - PropertyID | ||
* @param mediaId - PropertyID | ||
* @param params - Parameters to be included in the request | ||
* @return JSON response from Media API | ||
* @throws JWPlatformException See <a href= | ||
* "https://developer.jwplayer.com/jwplayer/reference/get_v2-sites-site-id-media-media-id-media-renditions">List Renditions</a> | ||
*/ | ||
public JSONObject listMediaRenditions(String siteId, String mediaId, Map<String, String> params) throws JWPlatformException { | ||
Preconditions.checkNotNull(siteId, "Site ID must not be null!"); | ||
Preconditions.checkNotNull(mediaId, "Media ID must not be null!"); | ||
this.path = String.format(this.path, siteId, mediaId); | ||
return HttpCalls.request(this.path, params, false, "GET", headers); | ||
} | ||
|
||
/** | ||
* | ||
* @param siteId - PropertyID | ||
* @param mediaId - Unique identifier for a resource | ||
* @param bodyParams - Parameters to be included in the request body | ||
* @return JSON response from Media API | ||
* @throws JWPlatformException See <a href= | ||
* "https://developer.jwplayer.com/jwplayer/reference/post_v2-sites-site-id-media-media-id-media-renditions">Create Rendition</a> | ||
*/ | ||
public JSONObject createRendition(String siteId, String mediaId,Map<String, String> bodyParams) throws JWPlatformException { | ||
Preconditions.checkNotNull(siteId, "Site ID must not be null!"); | ||
Preconditions.checkNotNull(mediaId, "Media ID must not be null!"); | ||
this.path = String.format(this.path, siteId, mediaId); | ||
final boolean isBodyParams = bodyParams.size() > 0; | ||
return HttpCalls.request(this.path, bodyParams, isBodyParams, "POST", headers); | ||
} | ||
|
||
/** | ||
* | ||
* @param siteId - PropertyID | ||
* @param mediaId - Unique identifier for a resource | ||
* @param renditionId - Unique identifier for a rendition | ||
* @param params - Parameters to be included in the request | ||
* @return JSON response from Media API | ||
* @throws JWPlatformException See <a href= | ||
* "https://developer.jwplayer.com/jwplayer/reference/get_v2-sites-site-id-media-media-id-media-renditions-rendition-id-">Get Rendition By ID</a> | ||
*/ | ||
public JSONObject getRenditionById(String siteId, String mediaId, String renditionId, Map<String, String> params) | ||
throws JWPlatformException { | ||
Preconditions.checkNotNull(siteId, "Site ID must not be null!"); | ||
Preconditions.checkNotNull(mediaId, "Media ID must not be null!"); | ||
Preconditions.checkNotNull(renditionId, "Rendition ID must not be null!"); | ||
this.path = String.format(this.path, siteId, mediaId)+renditionId+"/"; | ||
return HttpCalls.request(this.path, params, false, "GET", headers); | ||
} | ||
|
||
/** | ||
* | ||
* @param siteId - PropertyID | ||
* @param mediaId - Unique identifier for a resource | ||
* @param renditionId - Unique identifier for a rendition | ||
* @return JSON response from Media API | ||
* @throws JWPlatformException See <a href= | ||
* "https://developer.jwplayer.com/jwplayer/reference/delete_v2-sites-site-id-media-media-id-media-renditions-rendition-id-">Delete Rendition</a> | ||
*/ | ||
public JSONObject deleteRendition(String siteId, String mediaId, String renditionId) throws JWPlatformException { | ||
Preconditions.checkNotNull(siteId, "Site ID must not be null!"); | ||
Preconditions.checkNotNull(mediaId, "Media ID must not be null!"); | ||
Preconditions.checkNotNull(renditionId, "Rendition ID must not be null!"); | ||
this.path = String.format(this.path, siteId, mediaId)+renditionId+"/"; | ||
return HttpCalls.request(this.path, new HashMap<>(), false, "DELETE", headers); | ||
} | ||
} |
139 changes: 139 additions & 0 deletions
139
src/main/java/com/jwplayer/jwplatform/client/OriginalClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
package com.jwplayer.jwplatform.client; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import org.json.JSONObject; | ||
|
||
import com.google.common.base.Preconditions; | ||
import com.jwplayer.jwplatform.exception.JWPlatformException; | ||
import com.jwplayer.jwplatform.rest.HttpCalls; | ||
|
||
/** | ||
* JW Platform Original API client. | ||
* | ||
* <p> | ||
* An API client for the JW Platform Original API. For the API documentation | ||
* see: <a href= | ||
* "https://developer.jwplayer.com/jwplayer/reference#introduction-to-api-v2">Introduction | ||
* to api v2</a> | ||
* | ||
* <p> | ||
* Example: OriginalClient client = OriginalClient.getClient(secret); | ||
*/ | ||
public class OriginalClient extends JWPlatformClientV2 { | ||
|
||
private String path; | ||
private final String secret; | ||
|
||
/** | ||
* Instantiate a new {@code OriginalClient} instance. | ||
* | ||
* @param secret - your api secret | ||
*/ | ||
private OriginalClient(String secret) { | ||
this.secret = secret; | ||
this.path = "https://api.jwplayer.com/v2/sites/%s/media/%s/originals/"; | ||
headers = new HashMap<>(); | ||
headers.put("Authorization", "Bearer " + this.secret); | ||
headers.put("accept", "application/json"); | ||
headers.put("Content-Type", "application/json"); | ||
} | ||
|
||
/** | ||
* see {@link #OriginalClient(String)}. | ||
*/ | ||
public static OriginalClient getClient(String secret) { | ||
Preconditions.checkNotNull(secret, "API Secret must not be null!"); | ||
return new OriginalClient(secret); | ||
} | ||
|
||
/** | ||
* | ||
* @param siteId - PropertyID | ||
* @param mediaId - PropertyID | ||
* @param params - Parameters to be included in the request | ||
* @return JSON response from Media API | ||
* @throws JWPlatformException See <a href= | ||
* "https://developer.jwplayer.com/jwplayer/reference/get_v2-sites-site-id-media-media-id-originals">List Originals</a> | ||
*/ | ||
public JSONObject listOriginals(String siteId, String mediaId, Map<String, String> params) throws JWPlatformException { | ||
Preconditions.checkNotNull(siteId, "Site ID must not be null!"); | ||
Preconditions.checkNotNull(mediaId, "Media ID must not be null!"); | ||
this.path = String.format(this.path, siteId, mediaId); | ||
return HttpCalls.request(this.path, params, false, "GET", headers); | ||
} | ||
|
||
/** | ||
* | ||
* @param siteId - PropertyID | ||
* @param mediaId - Unique identifier for a resource | ||
* @param bodyParams - Parameters to be included in the request body | ||
* @return JSON response from Media API | ||
* @throws JWPlatformException See <a href= | ||
* "https://developer.jwplayer.com/jwplayer/reference/post_v2-sites-site-id-media-media-id-originals">Create Originals</a> | ||
*/ | ||
public JSONObject createOriginals(String siteId, String mediaId,Map<String, String> bodyParams) throws JWPlatformException { | ||
Preconditions.checkNotNull(siteId, "Site ID must not be null!"); | ||
Preconditions.checkNotNull(mediaId, "Media ID must not be null!"); | ||
this.path = String.format(this.path, siteId, mediaId); | ||
final boolean isBodyParams = bodyParams.size() > 0; | ||
return HttpCalls.request(this.path, bodyParams, isBodyParams, "POST", headers); | ||
} | ||
|
||
/** | ||
* | ||
* @param siteId - PropertyID | ||
* @param mediaId - Unique identifier for a resource | ||
* @param originalId - Unique identifier for a rendition | ||
* @param params - Parameters to be included in the request | ||
* @return JSON response from Media API | ||
* @throws JWPlatformException See <a href= | ||
* "https://developer.jwplayer.com/jwplayer/reference/get_v2-sites-site-id-media-media-id-originals-original-id-">Get Original By ID</a> | ||
*/ | ||
public JSONObject getOriginalById(String siteId, String mediaId, String originalId, Map<String, String> params) | ||
throws JWPlatformException { | ||
Preconditions.checkNotNull(siteId, "Site ID must not be null!"); | ||
Preconditions.checkNotNull(mediaId, "Media ID must not be null!"); | ||
Preconditions.checkNotNull(originalId, "Original ID must not be null!"); | ||
this.path = String.format(this.path, siteId, mediaId)+ originalId + "/"; | ||
return HttpCalls.request(this.path, params, false, "GET", headers); | ||
} | ||
|
||
/** | ||
* | ||
* @param siteId - PropertyID | ||
* @param mediaId - Unique identifier for a resource | ||
* @param originalId - Unique identifier for an original | ||
* @param bodyParams - Parameters to be included in the request body | ||
* @return JSON response from Media API | ||
* @throws JWPlatformException See <a href= | ||
* "https://developer.jwplayer.com/jwplayer/reference/patch_v2-sites-site-id-media-media-id-originals-original-id-">Update Original</a> | ||
*/ | ||
public JSONObject updateOriginal(String siteId, String mediaId, String originalId, Map<String, String> bodyParams) | ||
throws JWPlatformException { | ||
Preconditions.checkNotNull(siteId, "Site ID must not be null!"); | ||
Preconditions.checkNotNull(mediaId, "Config ID must not be null!"); | ||
this.path = String.format(this.path, siteId, mediaId) + originalId + "/"; | ||
final boolean isBodyParams = bodyParams.size() > 0; | ||
return HttpCalls.request(this.path, bodyParams, isBodyParams, "PATCH", headers); | ||
} | ||
|
||
/** | ||
* | ||
* @param siteId - PropertyID | ||
* @param mediaId - Unique identifier for a resource | ||
* @param originalId - Unique identifier for a rendition | ||
* @return JSON response from Media API | ||
* @throws JWPlatformException See <a href= | ||
* "https://developer.jwplayer.com/jwplayer/reference/delete_v2-sites-site-id-media-media-id-originals-original-id-">Delete Rendition</a> | ||
*/ | ||
public JSONObject deleteOriginal(String siteId, String mediaId, String originalId) throws JWPlatformException { | ||
Preconditions.checkNotNull(siteId, "Site ID must not be null!"); | ||
Preconditions.checkNotNull(mediaId, "Media ID must not be null!"); | ||
Preconditions.checkNotNull(originalId, "Original ID must not be null!"); | ||
this.path = String.format(this.path, siteId, mediaId) + originalId + "/"; | ||
return HttpCalls.request(this.path, new HashMap<>(), false, "DELETE", headers); | ||
} | ||
|
||
} |
Oops, something went wrong.