sociova 1.0.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -67,8 +67,51 @@ export type SendButtonTemplatePayload = {
67
67
  text: string;
68
68
  buttons: ButtonTemplateButton[];
69
69
  };
70
+ export type SendMediaPayload = {
71
+
72
+ recipientId: string | number;
73
+ postId: string|number;
74
+ };
70
75
 
71
76
  export type SendButtonTemplateResponse = Record<string, any>;
77
+ export type SendMediaResponse = Record<string,any>
78
+ // ---- Generic Template Types ----
79
+
80
+ export type GenericWebUrlButton = {
81
+ type: "web_url";
82
+ url: string;
83
+ title: string;
84
+ };
85
+
86
+ export type GenericPostbackButton = {
87
+ type: "postback";
88
+ title: string;
89
+ payload: string;
90
+ };
91
+
92
+ export type GenericTemplateButton =
93
+ | GenericWebUrlButton
94
+ | GenericPostbackButton;
95
+
96
+ export type GenericTemplateDefaultAction = {
97
+ type: "web_url";
98
+ url: string;
99
+ };
100
+
101
+ export type GenericTemplateElement = {
102
+ title: string;
103
+ image_url?: string;
104
+ subtitle?: string;
105
+ default_action?: GenericTemplateDefaultAction;
106
+ buttons?: GenericTemplateButton[];
107
+ };
108
+
109
+ export type SendGenericTemplatePayload = {
110
+ recipientId: string | number;
111
+ elements: GenericTemplateElement[];
112
+ };
113
+
114
+ export type SendGenericTemplateResponse = Record<string, any>;
72
115
 
73
116
  export declare class InstaClient {
74
117
  Config: {
@@ -88,4 +131,6 @@ export declare class InstaClient {
88
131
  sendReaction(payload: SendReactionPayload): Promise<SendReactionResponse>;
89
132
 
90
133
  sendButtonTemplate(payload: SendButtonTemplatePayload): Promise<SendButtonTemplateResponse>;
134
+ sendPublishedPosts(payload: SendMediaPayload): Promise<SendMediaResponse>;
135
+ sendGenericTemplate(payload: SendGenericTemplatePayload): Promise<SendGenericTemplateResponse>;
91
136
  }
@@ -135,4 +135,57 @@ async sendButtonTemplate(payload) {
135
135
 
136
136
  return await res.json();
137
137
  }
138
+
139
+ async sendPublishedPosts(payload) {
140
+ const url = `${INSTAGRAM_BASE_URL}/${AUTHENTICATED_USER}/messages`;
141
+ const res = await fetch(url, {
142
+ method: "POST",
143
+ headers: {
144
+ Authorization: `Bearer ${this.Config.auth}`,
145
+ "Content-Type": "application/json",
146
+ },
147
+ body: JSON.stringify({
148
+ recipient: {
149
+ id: payload.recipientId
150
+ },
151
+ message: {
152
+ attachment: {
153
+ type: "MEDIA_SHARE",
154
+ payload: {
155
+ id:payload.postId
156
+ }
157
+ }
158
+ }
159
+ })
160
+ });
161
+ return await res.json()
162
+ }
163
+
164
+
165
+ async sendGenericTemplate( payload) {
166
+ const url = `${INSTAGRAM_BASE_URL}${AUTHENTICATED_USER}/messages`;
167
+
168
+ const res = await fetch(url, {
169
+ method: "POST",
170
+ headers: {
171
+ Authorization: `Bearer ${this.Config.auth}`,
172
+ "Content-Type": "application/json",
173
+ },
174
+ body: JSON.stringify({
175
+ recipient: { id: payload.recipientId },
176
+ message: {
177
+ attachment: {
178
+ type: "template",
179
+ payload: {
180
+ template_type: "generic",
181
+ elements: payload.elements,
182
+ },
183
+ },
184
+ },
185
+ }),
186
+ });
187
+
188
+ return await res.json();
189
+ }
190
+
138
191
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sociova",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -12,5 +12,13 @@
12
12
  "type": "module",
13
13
  "dependencies": {
14
14
  "dotenv": "^17.3.1"
15
- }
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/eklavyapopli-ship-it/sociova.git"
19
+ },
20
+ "bugs": {
21
+ "url": "https://github.com/eklavyapopli-ship-it/sociova/issues"
22
+ },
23
+ "homepage": "https://github.com/eklavyapopli-ship-it/sociova#readme"
16
24
  }
File without changes
File without changes
File without changes
File without changes