Skip to content

Commit

Permalink
Merge pull request #402 from vimeo/VA-4132-Connected-Apps
Browse files Browse the repository at this point in the history
VA-4132 connected apps
  • Loading branch information
howardrigberg authored Dec 10, 2019
2 parents 22dae61 + b03fe51 commit d667c92
Show file tree
Hide file tree
Showing 21 changed files with 604 additions and 11 deletions.
85 changes: 85 additions & 0 deletions models/src/main/java/com/vimeo/networking2/ConnectedApp.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package com.vimeo.networking2

import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import com.vimeo.networking2.common.Entity
import com.vimeo.networking2.enums.ConnectedAppType
import com.vimeo.networking2.enums.asEnum
import java.util.*

/**
* A [ConnectedApp] represents a connection to a social media platform. Some activities, like simultaneously live
* stream to multiple destinations, or publishing across platforms, require requesting specific scopes. The scopes
* required will always be returned in the [neededScopes] array.
* - Note: Some properties are specific to a particular platform. These cases have been noted in the documentation
* where relevant.
*/
@JsonClass(generateAdapter = true)
data class ConnectedApp(

/**
* The time in ISO 8601 format when the connected app was added.
*/
@Json(name = "add_date")
var dateAdded: Date? = null,

/**
* The list of remaining scopes on this connected app that the user needs for a particular feature.
*/
@Json(name = "needed_scopes")
val neededScopes: ConnectedScopes? = null,

/**
* The list of third party pages that is associated with the user's account (Facebook and LinkedIn only).
*/
@Json(name = "pages")
val pages: List<PublishOptionItem>? = null,

/**
* The list of third party categories that can be selected for a publish to social
* job (Facebook and YouTube only).
*/
@Json(name = "publish_categories")
val publishCategories: List<PublishOptionItem>? = null,

/**
* The unique identifier for the user on this connected app.
*/
@Json(name = "third_party_user_id")
val userId: String? = null,

/**
* The user's display name on the connected app.
*/
@Json(name = "third_party_user_display_name")
val userName: String? = null,

/**
* The API URI of this connected app.
*/
@Json(name = "uri")
val uri: String? = null,

/**
* Whether or not the user's data access is expired (Facebook only).
*/
@Json(name = "data_access_is_expired")
val isDataAccessExpired: Boolean? = null,

/**
* The [ConnectedAppType] of the connected app.
*/
@Json(name = "type")
val rawType: String? = null

) : Entity {
override val identifier: String? = uri
}


/**
* @see ConnectedApp.rawType
* @see ConnectedAppType
*/
val ConnectedApp.type: ConnectedAppType
get() = rawType.asEnum(ConnectedAppType.UNKNOWN)
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.vimeo.networking2

import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import com.vimeo.networking2.common.Interaction

/**
* All of the interactions for a connected app.
*/
@JsonClass(generateAdapter = true)
data class ConnectedAppInteraction(

@Json(name = "options")
override val options: List<String>? = null,

@Json(name = "uri")
override val uri: String? = null,

/**
* Whether an app is connected or not.
*/
@Json(name = "is_connected")
val isConnected: Boolean? = null,

/**
* Provides the lists of scopes that are required for third-party connected app features.
*/
@Json(name = "all_scopes")
val allScopes: ConnectedScopes? = null

) : Interaction
28 changes: 28 additions & 0 deletions models/src/main/java/com/vimeo/networking2/ConnectedAppList.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.vimeo.networking2

import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import com.vimeo.networking2.common.Pageable

/**
* List of the logged in user's [ConnectedApps][ConnectedApp].
*/
@JsonClass(generateAdapter = true)
data class ConnectedAppList(

@Json(name = "total")
override val total: Int? = null,

@Json(name = "page")
override val page: Int? = null,

@Json(name = "per_page")
override val perPage: Int? = null,

@Json(name = "paging")
override val paging: Paging? = null,

@Json(name = "data")
override val data: List<ConnectedApp>? = null

) : Pageable<ConnectedApp>
23 changes: 23 additions & 0 deletions models/src/main/java/com/vimeo/networking2/ConnectedScopes.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.vimeo.networking2

import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass

/**
* Provides the lists of scopes that are required for third-party connected app features.
*/
@JsonClass(generateAdapter = true)
data class ConnectedScopes(

/**
* All scopes required for publishing to a specific social media platform.
*/
@Json(name = "publish_to_social")
val publishToSocial: List<String>? = null,

/**
* All scopes required for simulcasting to a specific social media platform.
*/
@Json(name = "simulcast")
val simulcast: List<String>? = null
)
7 changes: 0 additions & 7 deletions models/src/main/java/com/vimeo/networking2/Periodic.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.vimeo.networking2

import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import java.util.*

/**
* Periodic upload quota information.
Expand All @@ -22,12 +21,6 @@ data class Periodic(
@Json(name = "max")
val max: Long? = null,

/**
* The time in ISO 8601 format when your upload quota resets.
*/
@Json(name = "reset_date")
val resetDate: Date? = null,

/**
* The number of bytes that you've already uploaded against your quota in the current period.
*/
Expand Down
29 changes: 29 additions & 0 deletions models/src/main/java/com/vimeo/networking2/PublishOptionItem.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.vimeo.networking2

import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import com.vimeo.networking2.common.Entity

/**
* A page or category that can be sent when publishing to a social media platform.
*/
@JsonClass(generateAdapter = true)
data class PublishOptionItem(

/**
* The ID of the publish item.
*/
@Json(name = "id")
val id: String? = null,

/**
* The name or display name of the publish item, i.e.: "art", "family", "vacation" etc.
*/
@Json(name = "name")
val name: String? = null

) : Entity {

override val identifier: String? = id

}
6 changes: 6 additions & 0 deletions models/src/main/java/com/vimeo/networking2/UserConnections.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ data class UserConnections(
@Json(name = "channels")
val channels: Connection? = null,

/**
* Information about this user's connected apps.
*/
@Json(name = "connected_apps")
val connectedApps: Connection? = null,

/**
* Information about this user's feed.
*/
Expand Down
28 changes: 26 additions & 2 deletions models/src/main/java/com/vimeo/networking2/UserInteractions.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.vimeo.networking2

import com.vimeo.networking2.common.FollowableInteractions
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import com.vimeo.networking2.common.FollowableInteractions

/**
* All actions that can be taken on a user.
Expand Down Expand Up @@ -32,6 +32,30 @@ data class UserInteractions(
* Information regarding where and how to report a user.
*/
@Json(name = "report")
val report: BasicInteraction? = null
val report: BasicInteraction? = null,

/**
* Information related to the Facebook connected app.
*/
@Json(name = "facebook_connected_app")
val facebookConnectedApp: ConnectedAppInteraction? = null,

/**
* Information related to the YouTube connected app.
*/
@Json(name = "youtube_connected_app")
val youTubeConnectedApp: ConnectedAppInteraction? = null,

/**
* Information related to the LinkedIn connected app.
*/
@Json(name = "linkedin_connected_app")
val linkedInConnectedApp: ConnectedAppInteraction? = null,

/**
* Information related to the Twitter connected app.
*/
@Json(name = "twitter_connected_app")
val twitterConnectedApp: ConnectedAppInteraction? = null

): FollowableInteractions
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.vimeo.networking2.enums

/**
* An enumeration of the supported connected app types.
*/
enum class ConnectedAppType(override val value: String?) : StringValue {

/**
* Represents a connection to Facebook.
*/
FACEBOOK("facebook"),

/**
* Represents a connection to LinkedIn.
*/
LINKED_IN("linkedin"),

/**
* Represents a connection to Twitter.
*/
TWITTER("twitter"),

/**
* Represents a connection to YouTube.
*/
YOUTUBE("youtube"),

/**
* Unknown connection type.
*/
UNKNOWN(null);
}
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ enum class ErrorCodeType(override val value: String?) : StringValue {

UNABLE_TO_CREATE_USER_GOOGLE_COULD_NOT_VERIFY_TOKEN("2337"),

TWITTER_COULD_NOT_VERIFY_TOKEN("2339"),

LINKEDIN_COULD_NOT_VERIFY_TOKEN("2340"),

// Albums
ALBUM_THUMBNAIL_ACCESS_FORBIDDEN("3200"),

Expand All @@ -185,6 +189,8 @@ enum class ErrorCodeType(override val value: String?) : StringValue {

USER_NOT_AUTHORIZED_TO_DELETE_ACCOUNT("2406"),

CONNECTED_APP_ALREADY_EXISTS("2419"),

INVALID_INPUT_BAD_UPLOAD_TYPE("2230"),

INVALID_INPUT_NO_CLIP_NAME("2231"),
Expand Down
5 changes: 5 additions & 0 deletions models/src/test/java/com/vimeo/networking2/ModelsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ class ModelsTest {
Comment::class,
CommentConnections::class,
CommentList::class,
ConnectedApp::class,
ConnectedAppList::class,
ConnectedAppInteraction::class,
ConnectedScopes::class,
Connection::class,
Credit::class,
Document::class,
Expand Down Expand Up @@ -86,6 +90,7 @@ class ModelsTest {
ProgrammedContentItem::class,
ProgrammedContentItemList::class,
Publish::class,
PublishOptionItem::class,
PurchaseInteraction::class,
PurchaseOnDemandInteraction::class,
Quota::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class EnumsTest {
BillingPeriodType::class.java,
CommentType::class.java,
CommentPrivacyType::class.java,
ConnectedAppType::class.java,
ContentFilterType::class.java,
DownloadType::class.java,
EmbedPrivacyType::class.java,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ public final class Vimeo {
public static final String PARAMETER_ALBUM_PRIVACY = "privacy";
public static final String PARAMETER_ALBUM_PASSWORD = "password";

public static final String PARAMETER_AUTH_CODE = "auth_code";
public static final String PARAMETER_APP_TYPE = "app_type";

public static final String PARAMETER_COMMENT_TEXT_BODY = "text";

public static final String PARAMETER_ACTIVE = "active";
Expand Down
Loading

0 comments on commit d667c92

Please sign in to comment.