postproxy-sdk 1.5.0 → 1.7.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 86174e66ca792b05a9f36bff9b881c65c3fdaaeb360e8a4fb49e94014d984839
4
- data.tar.gz: ebe347a97de89a5af6697087252156b044a26f5c8eae11c3e2129c4594a6cb46
3
+ metadata.gz: 0aea2892ef3d3256dfd1cc9ce790da283df1d6edb83a2cfcaa76c0aa8a8194ae
4
+ data.tar.gz: a9f008666d47832963cc7119d0db1b53d53c7ddd3dc690fa13acebc05c72f5f6
5
5
  SHA512:
6
- metadata.gz: 73dc2f50e0d720cd4048b23db241a17ea81cec2010bb06ae0f6a42a4edbb4d26f2b074be9e3a71ac4e24b9d09fa31651365727aefd88346e416284de4a4a6424
7
- data.tar.gz: ae13c32ba3db5b1bb1e07bfd3ae63cc7d977215a834e1b4ce42b3298a3e6e790240b5a6dc251c41561489238cdbfdbab816ef22f221dc7ab3886db7e3f837669
6
+ metadata.gz: c9f6cf9ec0d398081c84c21c41824bd590fa9d57b7e8eea423512bcc899b82d3df93c4532edf307e2f949a0d72217e6677743b36434a4384e9b9d801030b4aa4
7
+ data.tar.gz: 325923dc017d840f212edac1941f2f2aa8d8821594f2418e40dee1e1b56a8f103627ab1f8cb9adb07f576afcc8fe5a6b431fcc408a50c4ac6887948bf80426d6
data/README.md CHANGED
@@ -105,6 +105,18 @@ post.thread.each { |child| puts "#{child.id}: #{child.body}" }
105
105
 
106
106
  # Delete a post
107
107
  client.posts.delete("post-id")
108
+
109
+ # Delete a post and also remove it from social platforms
110
+ client.posts.delete("post-id", delete_on_platform: true)
111
+
112
+ # Delete from platforms only (keeps DB record). Defaults to all platforms.
113
+ client.posts.delete_on_platform("post-id")
114
+ # Target a single network
115
+ client.posts.delete_on_platform("post-id", network: "twitter")
116
+ # Target a specific profile
117
+ client.posts.delete_on_platform("post-id", profile_id: "prof-abc")
118
+ # Target a specific post profile (covers entire thread for that profile)
119
+ client.posts.delete_on_platform("post-id", post_profile_id: "pp-abc")
108
120
  ```
109
121
 
110
122
  ## Post Stats
@@ -248,6 +260,43 @@ PostProxy::WebhookSignature.verify(
248
260
  )
249
261
  ```
250
262
 
263
+ ## Comments
264
+
265
+ ```ruby
266
+ # List comments on a post (paginated)
267
+ comments = client.comments.list("post-id", profile_id: "profile-id")
268
+ comments.data.each do |comment|
269
+ puts "#{comment.author_username}: #{comment.body}"
270
+ comment.replies.each do |reply|
271
+ puts " #{reply.author_username}: #{reply.body}"
272
+ end
273
+ end
274
+
275
+ # List with pagination
276
+ comments = client.comments.list("post-id", profile_id: "profile-id", page: 2, per_page: 10)
277
+
278
+ # Get a single comment
279
+ comment = client.comments.get("post-id", "comment-id", profile_id: "profile-id")
280
+
281
+ # Create a comment
282
+ comment = client.comments.create("post-id", profile_id: "profile-id", text: "Great post!")
283
+
284
+ # Reply to a comment
285
+ reply = client.comments.create("post-id", profile_id: "profile-id", text: "Thanks!", parent_id: "comment-id")
286
+
287
+ # Delete a comment
288
+ result = client.comments.delete("post-id", "comment-id", profile_id: "profile-id")
289
+ puts result.accepted # true
290
+
291
+ # Hide / unhide a comment
292
+ client.comments.hide("post-id", "comment-id", profile_id: "profile-id")
293
+ client.comments.unhide("post-id", "comment-id", profile_id: "profile-id")
294
+
295
+ # Like / unlike a comment
296
+ client.comments.like("post-id", "comment-id", profile_id: "profile-id")
297
+ client.comments.unlike("post-id", "comment-id", profile_id: "profile-id")
298
+ ```
299
+
251
300
  ## Profiles
252
301
 
253
302
  ```ruby
@@ -6,6 +6,7 @@ require_relative "resources/profiles"
6
6
  require_relative "resources/profile_groups"
7
7
  require_relative "resources/webhooks"
8
8
  require_relative "resources/queues"
9
+ require_relative "resources/comments"
9
10
 
10
11
  module PostProxy
11
12
  class Client
@@ -21,6 +22,7 @@ module PostProxy
21
22
  @profile_groups = nil
22
23
  @webhooks = nil
23
24
  @queues = nil
25
+ @comments = nil
24
26
  end
25
27
 
26
28
  def posts
@@ -43,6 +45,10 @@ module PostProxy
43
45
  @queues ||= Resources::Queues.new(self)
44
46
  end
45
47
 
48
+ def comments
49
+ @comments ||= Resources::Comments.new(self)
50
+ end
51
+
46
52
  def request(method, path, params: nil, json: nil, data: nil, files: nil, profile_group_id: nil)
47
53
  url = "/api#{path}"
48
54
 
@@ -0,0 +1,62 @@
1
+ module PostProxy
2
+ module Resources
3
+ class Comments
4
+ def initialize(client)
5
+ @client = client
6
+ end
7
+
8
+ def list(post_id, profile_id:, page: nil, per_page: nil)
9
+ params = { profile_id: profile_id }
10
+ params[:page] = page if page
11
+ params[:per_page] = per_page if per_page
12
+
13
+ result = @client.request(:get, "/posts/#{post_id}/comments", params: params)
14
+ comments = (result[:data] || []).map { |c| Comment.new(**c) }
15
+ PaginatedResponse.new(
16
+ data: comments,
17
+ total: result[:total],
18
+ page: result[:page],
19
+ per_page: result[:per_page]
20
+ )
21
+ end
22
+
23
+ def get(post_id, comment_id, profile_id:)
24
+ result = @client.request(:get, "/posts/#{post_id}/comments/#{comment_id}", params: { profile_id: profile_id })
25
+ Comment.new(**result)
26
+ end
27
+
28
+ def create(post_id, text, profile_id:, parent_id: nil)
29
+ json_body = { text: text }
30
+ json_body[:parent_id] = parent_id if parent_id
31
+
32
+ result = @client.request(:post, "/posts/#{post_id}/comments", params: { profile_id: profile_id }, json: json_body)
33
+ Comment.new(**result)
34
+ end
35
+
36
+ def delete(post_id, comment_id, profile_id:)
37
+ result = @client.request(:delete, "/posts/#{post_id}/comments/#{comment_id}", params: { profile_id: profile_id })
38
+ AcceptedResponse.new(**result)
39
+ end
40
+
41
+ def hide(post_id, comment_id, profile_id:)
42
+ result = @client.request(:post, "/posts/#{post_id}/comments/#{comment_id}/hide", params: { profile_id: profile_id })
43
+ AcceptedResponse.new(**result)
44
+ end
45
+
46
+ def unhide(post_id, comment_id, profile_id:)
47
+ result = @client.request(:post, "/posts/#{post_id}/comments/#{comment_id}/unhide", params: { profile_id: profile_id })
48
+ AcceptedResponse.new(**result)
49
+ end
50
+
51
+ def like(post_id, comment_id, profile_id:)
52
+ result = @client.request(:post, "/posts/#{post_id}/comments/#{comment_id}/like", params: { profile_id: profile_id })
53
+ AcceptedResponse.new(**result)
54
+ end
55
+
56
+ def unlike(post_id, comment_id, profile_id:)
57
+ result = @client.request(:post, "/posts/#{post_id}/comments/#{comment_id}/unlike", params: { profile_id: profile_id })
58
+ AcceptedResponse.new(**result)
59
+ end
60
+ end
61
+ end
62
+ end
@@ -38,6 +38,8 @@ module PostProxy
38
38
  form_data = { "post[body]" => body }
39
39
  form_data["post[scheduled_at]"] = format_time(scheduled_at) if scheduled_at
40
40
  form_data["post[draft]"] = draft.to_s if !draft.nil?
41
+ form_data["queue_id"] = queue_id if queue_id
42
+ form_data["queue_priority"] = queue_priority if queue_priority
41
43
 
42
44
  files = []
43
45
 
@@ -116,6 +118,8 @@ module PostProxy
116
118
  form_data["post[body]"] = body if body
117
119
  form_data["post[scheduled_at]"] = format_time(scheduled_at) if scheduled_at
118
120
  form_data["post[draft]"] = draft.to_s if !draft.nil?
121
+ form_data["queue_id"] = queue_id if queue_id
122
+ form_data["queue_priority"] = queue_priority if queue_priority
119
123
 
120
124
  files = []
121
125
 
@@ -205,11 +209,28 @@ module PostProxy
205
209
  StatsResponse.new(data: posts)
206
210
  end
207
211
 
208
- def delete(id, profile_group_id: nil)
209
- result = @client.request(:delete, "/posts/#{id}", profile_group_id: profile_group_id)
212
+ def delete(id, delete_on_platform: nil, profile_group_id: nil)
213
+ params = {}
214
+ params[:delete_on_platform] = delete_on_platform unless delete_on_platform.nil?
215
+ result = @client.request(:delete, "/posts/#{id}",
216
+ params: params.empty? ? nil : params,
217
+ profile_group_id: profile_group_id
218
+ )
210
219
  DeleteResponse.new(**result)
211
220
  end
212
221
 
222
+ def delete_on_platform(id, post_profile_id: nil, profile_id: nil, network: nil, profile_group_id: nil)
223
+ json_body = {}
224
+ json_body[:post_profile_id] = post_profile_id if post_profile_id
225
+ json_body[:profile_id] = profile_id if profile_id
226
+ json_body[:network] = network if network
227
+ result = @client.request(:post, "/posts/#{id}/delete_on_platform",
228
+ json: json_body.empty? ? nil : json_body,
229
+ profile_group_id: profile_group_id
230
+ )
231
+ DeleteOnPlatformResponse.new(**result)
232
+ end
233
+
213
234
  private
214
235
 
215
236
  def format_time(value)
@@ -63,17 +63,31 @@ module PostProxy
63
63
  end
64
64
  end
65
65
 
66
+ class ErrorDetails < Model
67
+ attr_accessor :platform_error_code, :platform_error_subcode, :platform_error_message, :postproxy_note
68
+
69
+ def initialize(**attrs)
70
+ @platform_error_code = nil
71
+ @platform_error_subcode = nil
72
+ @platform_error_message = nil
73
+ @postproxy_note = nil
74
+ super
75
+ end
76
+ end
77
+
66
78
  class PlatformResult < Model
67
- attr_accessor :platform, :status, :params, :error, :attempted_at, :insights
79
+ attr_accessor :platform, :status, :params, :error, :error_details, :attempted_at, :insights
68
80
 
69
81
  def initialize(**attrs)
70
82
  @params = nil
71
83
  @error = nil
84
+ @error_details = nil
72
85
  @attempted_at = nil
73
86
  @insights = nil
74
87
  super
75
88
  @attempted_at = parse_time(@attempted_at)
76
89
  @insights = Insights.new(**@insights) if @insights.is_a?(Hash)
90
+ @error_details = ErrorDetails.new(**@error_details.transform_keys(&:to_sym)) if @error_details.is_a?(Hash)
77
91
  end
78
92
 
79
93
  private
@@ -276,10 +290,62 @@ module PostProxy
276
290
  end
277
291
  end
278
292
 
293
+ class Comment < Model
294
+ attr_accessor :id, :external_id, :body, :status, :author_username,
295
+ :author_avatar_url, :author_external_id, :parent_external_id,
296
+ :like_count, :is_hidden, :permalink, :platform_data,
297
+ :posted_at, :created_at, :replies
298
+
299
+ def initialize(**attrs)
300
+ @external_id = nil
301
+ @author_avatar_url = nil
302
+ @author_external_id = nil
303
+ @parent_external_id = nil
304
+ @like_count = 0
305
+ @is_hidden = false
306
+ @permalink = nil
307
+ @platform_data = nil
308
+ @replies = []
309
+ super
310
+ @posted_at = parse_time(@posted_at)
311
+ @created_at = parse_time(@created_at)
312
+ @replies = (@replies || []).map do |r|
313
+ r.is_a?(Comment) ? r : Comment.new(**r.transform_keys(&:to_sym))
314
+ end
315
+ end
316
+
317
+ private
318
+
319
+ def parse_time(value)
320
+ return nil if value.nil?
321
+ value.is_a?(Time) ? value : Time.parse(value.to_s)
322
+ end
323
+ end
324
+
325
+ class AcceptedResponse < Model
326
+ attr_accessor :accepted
327
+ end
328
+
279
329
  class DeleteResponse < Model
280
330
  attr_accessor :deleted
281
331
  end
282
332
 
333
+ class DeletingPlatform < Model
334
+ attr_accessor :post_profile_id, :platform
335
+ end
336
+
337
+ class DeleteOnPlatformResponse < Model
338
+ attr_accessor :success, :deleting
339
+
340
+ def initialize(**attrs)
341
+ @deleting = []
342
+ super
343
+ @deleting = (@deleting || []).map do |entry|
344
+ entry.is_a?(DeletingPlatform) ? entry : DeletingPlatform.new(**entry)
345
+ end
346
+ end
347
+ end
348
+
283
349
  class SuccessResponse < Model
284
350
  attr_accessor :success
285
351
  end
@@ -310,7 +376,8 @@ module PostProxy
310
376
  end
311
377
 
312
378
  class YouTubeParams < Model
313
- attr_accessor :format, :title, :privacy_status, :cover_url, :made_for_kids
379
+ attr_accessor :format, :title, :privacy_status, :cover_url, :made_for_kids,
380
+ :tags, :category_id, :contains_synthetic_media
314
381
  end
315
382
 
316
383
  class PinterestParams < Model
@@ -1,3 +1,3 @@
1
1
  module PostProxy
2
- VERSION = "1.5.0"
2
+ VERSION = "1.7.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postproxy-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - PostProxy
@@ -78,6 +78,7 @@ files:
78
78
  - lib/postproxy/client.rb
79
79
  - lib/postproxy/constants.rb
80
80
  - lib/postproxy/errors.rb
81
+ - lib/postproxy/resources/comments.rb
81
82
  - lib/postproxy/resources/posts.rb
82
83
  - lib/postproxy/resources/profile_groups.rb
83
84
  - lib/postproxy/resources/profiles.rb