-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from siriusnottin/develop
feat: new MediaType support
- Loading branch information
Showing
4 changed files
with
175 additions
and
137 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import * as coda from "@codahq/packs-sdk"; | ||
|
||
export const ApiUrl = "https://photoslibrary.googleapis.com/v1"; | ||
|
||
export async function getConnectionName(context: coda.ExecutionContext) { | ||
let request: coda.FetchRequest = { | ||
method: "GET", | ||
url: "https://www.googleapis.com/oauth2/v1/userinfo", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
}; | ||
let userResponse = await context.fetcher.fetch(request); | ||
let user = userResponse.body; | ||
return user.name as string; | ||
} | ||
|
||
export const MediasContentCategoriesList = { | ||
Animals: "ANIMALS", | ||
Fashion: "FASHION", | ||
Landmarks: "LANDMARKS", | ||
Receipts: "RECEIPTS", | ||
Weddings: "WEDDINGS", | ||
Arts: "ARTS", | ||
Flowers: "FLOWERS", | ||
Landscapes: "LANDSCAPES", | ||
Screenshots: "SCREENSHOTS", | ||
Whiteboards: "WHITEBOARDS", | ||
Birthdays: "BIRTHDAYS", | ||
Food: "FOOD", | ||
Night: "NIGHT", | ||
Selfies: "SELFIES", | ||
Cityscapes: "CITYSCAPES", | ||
Gardens: "GARDENS", | ||
People: "PEOPLE", | ||
Sport: "SPORT", | ||
Crafts: "CRAFTS", | ||
Holidays: "HOLIDAYS", | ||
Performances: "PERFORMANCES", | ||
Travel: "TRAVEL", | ||
Documents: "DOCUMENTS", | ||
Houses: "HOUSES", | ||
Pets: "PETS", | ||
Utility: "UTILITY" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import * as coda from "@codahq/packs-sdk"; | ||
import * as helpers from "./helpers"; | ||
import { MediasContentCategoriesList } from "./helpers"; | ||
|
||
export const MediaDateRangeParam = coda.makeParameter({ | ||
type: coda.ParameterType.DateArray, | ||
name: "dateRange", | ||
description: "The date range over which data should be fetched.", | ||
suggestedValue: coda.PrecannedDateRange.LastWeek, | ||
}); | ||
|
||
export const MediaTypeParam = coda.makeParameter({ | ||
type: coda.ParameterType.String, | ||
name: "mediaType", | ||
description: "The type of media to fetch.", | ||
autocomplete: ["Photo", "Video"], | ||
optional: true, | ||
}); | ||
|
||
export const MediaCategoriesIncludeParam = coda.makeParameter({ | ||
type: coda.ParameterType.StringArray, | ||
name: "categories", | ||
description: "Filter by medias categories.", | ||
optional: true, | ||
autocomplete: Object.keys(MediasContentCategoriesList) | ||
}); | ||
|
||
export const MediaFavoritesParam = coda.makeParameter({ | ||
type: coda.ParameterType.Boolean, | ||
name: "favorite", | ||
description: "Filter by favorites medias.", | ||
optional: true, | ||
}); | ||
|
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,66 @@ | ||
import * as coda from "@codahq/packs-sdk"; | ||
|
||
export const MediaSchema = coda.makeObjectSchema({ | ||
properties: { | ||
mediaId: { | ||
type: coda.ValueType.String, | ||
fromKey: "id", | ||
required: true | ||
}, | ||
filename: { type: coda.ValueType.String, required: true }, | ||
mediaType: { type: coda.ValueType.String }, | ||
description: { type: coda.ValueType.String }, | ||
creationTime: { | ||
type: coda.ValueType.String, | ||
codaType: coda.ValueHintType.DateTime | ||
}, | ||
width: { type: coda.ValueType.Number }, | ||
height: { type: coda.ValueType.Number }, | ||
image: { | ||
type: coda.ValueType.String, | ||
codaType: coda.ValueHintType.ImageAttachment, | ||
}, | ||
url: { | ||
type: coda.ValueType.String, | ||
description: "Google Photos URL for the media.", | ||
codaType: coda.ValueHintType.Url, | ||
fromKey: "productUrl", | ||
}, | ||
}, | ||
displayProperty: "filename", | ||
idProperty: "mediaId", | ||
featuredProperties: [ | ||
"image" | ||
], | ||
}); | ||
|
||
export const MediaReferenceSchema = coda.makeReferenceSchemaFromObjectSchema(MediaSchema, "Media"); | ||
|
||
export const AlbumSchema = coda.makeObjectSchema({ | ||
properties: { | ||
albumId: { | ||
type: coda.ValueType.String, | ||
fromKey: "id", | ||
}, | ||
title: { type: coda.ValueType.String }, | ||
medias: { | ||
type: coda.ValueType.Array, | ||
items: MediaReferenceSchema | ||
}, | ||
url: { | ||
type: coda.ValueType.String, | ||
description: "Google Photos URL for the album.", | ||
codaType: coda.ValueHintType.Url, | ||
fromKey: "productUrl", | ||
}, | ||
coverPhoto: { | ||
type: coda.ValueType.String, | ||
codaType: coda.ValueHintType.ImageAttachment, | ||
}, | ||
}, | ||
displayProperty: "title", | ||
idProperty: "albumId", | ||
featuredProperties: [ | ||
"coverPhoto" | ||
] | ||
}); |