Skip to content

Commit c420ad7

Browse files
add api_version support for variants entry
1 parent 5be1096 commit c420ad7

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

lib/stack/contentType/entry/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ export function Entry (http, data) {
2525
this.urlPath = `/content_types/${this.content_type_uid}/entries`
2626

2727
if (data && data.entry) {
28+
this.apiVersion = data.api_version || undefined;
29+
if (this.apiVersion) {
30+
this.stackHeaders.api_version = this.apiVersion;
31+
}
2832
Object.assign(this, cloneDeep(data.entry))
2933
this.urlPath = `/content_types/${this.content_type_uid}/entries/${this.uid}`
3034

lib/stack/contentType/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,16 @@ export function ContentType (http, data = {}) {
147147
* client.stack({ api_key: 'api_key'}).contentType('content_type_uid').entry('entry_uid').fetch()
148148
* .then((contentType) => console.log(contentType))
149149
*/
150-
this.entry = (uid = null) => {
150+
this.entry = (uid = null, options = {}) => {
151151
const data = { stackHeaders: this.stackHeaders }
152152
data.content_type_uid = this.uid
153153
if (uid) {
154154
data.entry = { uid: uid }
155155
}
156+
options = options || {}; // Ensure `options` is always an object
157+
if (options && typeof options === 'object' && options.api_version) {
158+
data.api_version = options.api_version;
159+
}
156160
return new Entry(http, data)
157161
}
158162

types/stack/bulkOperation/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ export interface BulkOperation extends SystemFields {
66
publish(config: BulkOperationConfig): Promise<Response>
77
unpublish(config: BulkOperationConfig): Promise<Response>
88
delete(config: BulkDeleteConfig): Promise<Response>
9-
addItems(config: AddItemsConfig): Promise<Response>
10-
updateItems(config: AddItemsConfig): Promise<Response>
9+
addItems(config: BulkAddItemsConfig): Promise<Response>
10+
updateItems(config: BulkAddItemsConfig): Promise<Response>
1111
jobStatus(config: BulkJobStatus): Promise<Response>
1212
}
1313
export interface BulkOperationConfig {

types/stack/contentType/index.d.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ import { Entries, Entry } from "./entry";
44

55
export interface ContentType extends SystemFields, SystemFunction<ContentType> {
66
entry(): Entries
7-
entry(uid: string): Entry
7+
entry(uid: string, options?: { api_version : number | string }): Entry
88
}
9-
10-
119

1210
export interface ContentTypes extends Queryable<ContentType, {content_type: ContentTypeData}> {
1311
import(data: {content_type: string}, params?: any): Promise<ContentType>

0 commit comments

Comments
 (0)