Skip to content

Commit d69a624

Browse files
committed
Add landing URL request
1 parent e902011 commit d69a624

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed

src/main/java/com/creatubbles/api/CreatubblesAPI.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.nio.file.Files;
77

88
import com.google.gson.*;
9+
910
import org.glassfish.jersey.client.ClientProperties;
1011
import org.glassfish.jersey.client.JerseyClient;
1112
import org.glassfish.jersey.client.JerseyClientBuilder;
@@ -19,6 +20,7 @@
1920
import com.creatubbles.api.response.creation.CreateCreationResponse;
2021
import com.creatubbles.api.response.creation.CreationsUploadsResponse;
2122
import com.creatubbles.api.response.creation.GetCreationsResponse;
23+
import com.creatubbles.api.response.creation.LandingURLResponse;
2224
import com.creatubbles.api.response.creator.CreateCreatorResponse;
2325
import com.creatubbles.api.response.creator.GetCreatorsResponse;
2426
import com.creatubbles.api.response.gallery.CreateUserGalleryResponse;
@@ -39,6 +41,7 @@ public class CreatubblesAPI {
3941
.registerTypeAdapter(GetCreationsResponse.class, new GetCreationsResponse())
4042
.registerTypeAdapter(CreateCreationResponse.class, new CreateCreationResponse())
4143
.registerTypeAdapter(CreationsUploadsResponse.class, new CreationsUploadsResponse())
44+
.registerTypeAdapter(LandingURLResponse.class, new LandingURLResponse())
4245
.registerTypeAdapter(String.class, new StringAdapter())
4346
.create();
4447

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.creatubbles.api.request.creation;
2+
3+
import com.creatubbles.api.core.CreatubblesRequest;
4+
import com.creatubbles.api.response.creation.LandingURLResponse;
5+
import com.creatubbles.api.util.EndPoints;
6+
import com.creatubbles.api.util.HttpMethod;
7+
8+
9+
public class LandingURLRequest extends CreatubblesRequest<LandingURLResponse> {
10+
11+
public LandingURLRequest(String creationId, String accessToken) {
12+
super(String.format(EndPoints.CREATION_LANDING_URL, creationId), HttpMethod.GET, accessToken);
13+
}
14+
15+
@Override
16+
public Class<? extends LandingURLResponse> getResponseClass() {
17+
return LandingURLResponse.class;
18+
}
19+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.creatubbles.api.response.creation;
2+
3+
import java.lang.reflect.Type;
4+
5+
import com.creatubbles.api.core.CreatubblesResponse;
6+
import com.google.gson.JsonDeserializationContext;
7+
import com.google.gson.JsonDeserializer;
8+
import com.google.gson.JsonElement;
9+
import com.google.gson.JsonParseException;
10+
11+
12+
public class LandingURLResponse extends CreatubblesResponse implements JsonDeserializer<LandingURLResponse> {
13+
public String url;
14+
15+
@Override
16+
public LandingURLResponse deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
17+
url = json.getAsJsonObject().getAsJsonObject("data").getAsJsonObject("attributes").get("url").getAsString();
18+
return this;
19+
}
20+
}

src/main/java/com/creatubbles/api/util/EndPoints.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,6 @@ public class EndPoints {
3636
public static final String CREATIONS = "creations";
3737
public static final String CREATIONS_UPLOADS = "creations/%s/uploads";
3838
public static final String PING_CREATIONS_UPLOADS = "uploads/%s";
39+
public static final String CREATION_LANDING_URL = "creations/%s/landing_url";
3940

4041
}

0 commit comments

Comments
 (0)