Skip to content

Commit

Permalink
Add optional pageType parameter to ParselyMetadata class in Android SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinAkram committed Jan 17, 2024
1 parent 9cbf080 commit 9661b27
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ open class ParselyMetadata
/**
* Create a new ParselyMetadata object.
*
* @param authors The names of the authors of the content. Up to 10 authors are accepted.
* @param link A post's canonical url.
* @param section The category or vertical to which this content belongs.
* @param tags User-defined tags for the content. Up to 20 are allowed.
* @param thumbUrl URL at which the main image for this content is located.
* @param title The title of the content.
* @param pubDate The date this piece of content was published.
* @param authors The names of the authors of the content. Up to 10 authors are accepted.
* @param link A post's canonical url.
* @param section The category or vertical to which this content belongs.
* @param tags User-defined tags for the content. Up to 20 are allowed.
* @param thumbUrl URL at which the main image for this content is located.
* @param title The title of the content.
* @param pubDate The date this piece of content was published.
* @param pageType The type of page being tracked
*/(
private val authors: List<String>? = null,
@JvmField internal val link: String? = null,
Expand All @@ -30,6 +31,7 @@ open class ParselyMetadata
private val thumbUrl: String? = null,
private val title: String? = null,
private val pubDate: Calendar? = null
private val pageType: String? = null
) {
/**
* Turn this object into a Map
Expand Down Expand Up @@ -59,6 +61,9 @@ open class ParselyMetadata
if (pubDate != null) {
output["pub_date_tmsp"] = pubDate.timeInMillis / 1000
}
if (pageType != null) {
output["page_type"] = pageType
}
return output
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ class ParselyMetadataTest {
tags,
thumbUrl,
title,
pubDate
pubDate,
pageType
)

// when
Expand All @@ -39,7 +40,8 @@ class ParselyMetadataTest {
thumbUrl,
title,
pubDate,
duration
duration,
pageType
)

// when
Expand All @@ -57,6 +59,7 @@ class ParselyMetadataTest {
val thumbUrl = "sample thumb url"
val title = "sample title"
val pubDate = Calendar.getInstance().apply { set(2023, 0, 1) }
val pageType = "post"

val expectedParselyMetadataMap = mapOf(
"authors" to authors,
Expand All @@ -65,7 +68,8 @@ class ParselyMetadataTest {
"tags" to tags,
"thumb_url" to thumbUrl,
"title" to title,
"pub_date_tmsp" to pubDate.timeInMillis / 1000
"pub_date_tmsp" to pubDate.timeInMillis / 1000,
"page_type" to pageType
)
}
}

0 comments on commit 9661b27

Please sign in to comment.