Skip to content

Commit

Permalink
refactor(api): add 'Content-Type' headers for endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
parfeon committed May 21, 2024
1 parent 28552a5 commit 97bc438
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 11 deletions.
9 changes: 6 additions & 3 deletions dist/web/pubnub.js
Original file line number Diff line number Diff line change
Expand Up @@ -8452,13 +8452,13 @@
return { data: serviceResponse.data };
});
}
get headers() {
return { 'Content-Type': 'application/json' };
}
get path() {
const { keySet: { subscribeKey }, channel, messageTimetoken, } = this.parameters;
return `/v1/message-actions/${subscribeKey}/channel/${encodeString(channel)}/message/${messageTimetoken}`;
}
get headers() {
return { 'Content-Type': 'application/json' };
}
get body() {
return JSON.stringify(this.parameters.action);
}
Expand Down Expand Up @@ -8771,6 +8771,9 @@
const { keySet: { subscribeKey }, channel, } = this.parameters;
return `/v1/files/${subscribeKey}/channels/${encodeString(channel)}/generate-upload-url`;
}
get headers() {
return { 'Content-Type': 'application/json' };
}
get body() {
return JSON.stringify({ name: this.parameters.name });
}
Expand Down
2 changes: 1 addition & 1 deletion dist/web/pubnub.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions lib/core/endpoints/actions/add_message_action.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ class AddMessageActionRequest extends request_1.AbstractRequest {
return { data: serviceResponse.data };
});
}
get headers() {
return { 'Content-Type': 'application/json' };
}
get path() {
const { keySet: { subscribeKey }, channel, messageTimetoken, } = this.parameters;
return `/v1/message-actions/${subscribeKey}/channel/${(0, utils_1.encodeString)(channel)}/message/${messageTimetoken}`;
}
get headers() {
return { 'Content-Type': 'application/json' };
}
get body() {
return JSON.stringify(this.parameters.action);
}
Expand Down
3 changes: 3 additions & 0 deletions lib/core/endpoints/file_upload/generate_upload_url.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ class GenerateFileUploadUrlRequest extends request_1.AbstractRequest {
const { keySet: { subscribeKey }, channel, } = this.parameters;
return `/v1/files/${subscribeKey}/channels/${(0, utils_1.encodeString)(channel)}/generate-upload-url`;
}
get headers() {
return { 'Content-Type': 'application/json' };
}
get body() {
return JSON.stringify({ name: this.parameters.name });
}
Expand Down
8 changes: 4 additions & 4 deletions src/core/endpoints/actions/add_message_action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ export class AddMessageActionRequest extends AbstractRequest<MessageAction.AddMe
return { data: serviceResponse.data };
}

protected get headers(): Record<string, string> | undefined {
return { 'Content-Type': 'application/json' };
}

protected get path(): string {
const {
keySet: { subscribeKey },
Expand All @@ -101,6 +97,10 @@ export class AddMessageActionRequest extends AbstractRequest<MessageAction.AddMe
return `/v1/message-actions/${subscribeKey}/channel/${encodeString(channel)}/message/${messageTimetoken}`;
}

protected get headers(): Record<string, string> | undefined {
return { 'Content-Type': 'application/json' };
}

protected get body(): ArrayBuffer | string | undefined {
return JSON.stringify(this.parameters.action);
}
Expand Down
4 changes: 4 additions & 0 deletions src/core/endpoints/file_upload/generate_upload_url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ export class GenerateFileUploadUrlRequest extends AbstractRequest<FileSharing.Ge
return `/v1/files/${subscribeKey}/channels/${encodeString(channel)}/generate-upload-url`;
}

protected get headers(): Record<string, string> | undefined {
return { 'Content-Type': 'application/json' };
}

protected get body(): ArrayBuffer | string | undefined {
return JSON.stringify({ name: this.parameters.name });
}
Expand Down

0 comments on commit 97bc438

Please sign in to comment.