omnisocials 0.15.0 → 0.16.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.
@@ -52,7 +52,9 @@ module OmniSocials
52
52
  # POST /media/upload-from-url - server-side fetch, up to 1GB.
53
53
  #
54
54
  # Files over 100MB are streamed in the background: the response has
55
- # data["status"] == "processing"; poll get() until it is "ready".
55
+ # data["status"] == "processing"; poll get() until it is "ready". When
56
+ # such a file cannot be queued for processing, the answer is 503
57
+ # "processing_unavailable": send the same request again in a minute.
56
58
  def upload_from_url(url:, filename: nil, name: nil, folder: nil, folder_id: nil, pdf_mode: nil)
57
59
  body = Internal.drop_nil(
58
60
  {
@@ -189,6 +189,12 @@ module OmniSocials
189
189
  # most 20; a name that does not exist yet becomes a new tag) to filter
190
190
  # and compare posts in Analytics. Tags never go to a platform. Errors:
191
191
  # 404 tag_not_found (an unknown id), 400 invalid_tags / too_many_tags.
192
+ #
193
+ # A media id that is still processing (a large video is checked and
194
+ # converted after upload) answers 409 "media_processing" and nothing is
195
+ # created: wait until media.get(id) says "ready", then send the same
196
+ # request again. A file whose processing failed answers 400
197
+ # "invalid_media": upload it again.
192
198
  def create(content:, channels: nil, scheduled_at: nil, media_ids: nil,
193
199
  media_urls: nil, type: nil, source: nil, link_url: nil,
194
200
  link_title: nil, link_description: nil, link_thumbnail_url: nil,
@@ -226,7 +232,8 @@ module OmniSocials
226
232
  # See #create for the "warnings" array (X link posts, and the
227
233
  # "image_fit" entries steered by media_fit), the 402
228
234
  # "x_credits_insufficient" credit gate on X link posts,
229
- # comment_dm_automation and tags.
235
+ # comment_dm_automation, tags and the 409 "media_processing" / 400
236
+ # "invalid_media" answers.
230
237
  def create_and_publish(content:, channels: nil, media_ids: nil,
231
238
  media_urls: nil, type: nil, source: nil,
232
239
  link_url: nil, link_title: nil, link_description: nil,
@@ -302,6 +309,15 @@ module OmniSocials
302
309
  # tags; tags: nil or tags: [] removes them all, and leaving it out
303
310
  # keeps them. An update with only tags works on every post, published
304
311
  # and failed ones included.
312
+ #
313
+ # 409 answers, where nothing is changed: "post_publishing" while the
314
+ # post is publishing (status "posting") or a retry publishes one of its
315
+ # channels (poll #get until "published", "warning" or "failed"; an
316
+ # update with only tags still works); "review_required" when changes
317
+ # were requested on the post (approval_status "rejected") and the
318
+ # update would schedule it (it needs a new review: create it again
319
+ # with approval_workflow_id; saving it as a draft works);
320
+ # "media_processing" as on #create.
305
321
  def update(post_id, content: nil, scheduled_at: nil, channels: nil,
306
322
  media_ids: nil, media_urls: nil, type: nil, location_id: nil,
307
323
  collaborators: nil, user_tags: nil, pinterest: nil,
@@ -351,14 +367,21 @@ module OmniSocials
351
367
  @client.request("PATCH", "/posts/#{post_id}", json: body)
352
368
  end
353
369
 
354
- # DELETE /posts/{id} - remove a post from OmniSocials (the live post stays on the platform). Returns nil (204).
370
+ # DELETE /posts/{id} - remove a post from OmniSocials (the live post
371
+ # stays on the platform). Returns nil (204). While the post is
372
+ # publishing (status "posting") or a retry publishes one of its
373
+ # channels, the answer is 409 "post_publishing" and nothing is deleted:
374
+ # poll #get until "published", "warning" or "failed", then delete it.
355
375
  def delete(post_id)
356
376
  @client.request("DELETE", "/posts/#{post_id}")
357
377
  end
358
378
 
359
379
  # POST /posts/{id}/publish - publish a draft or scheduled post now.
360
380
  # See #create for the 402 "x_credits_insufficient" credit gate that
361
- # can also refuse publishing a scheduled X link post.
381
+ # can also refuse publishing a scheduled X link post. A post on which
382
+ # changes were requested in its approval workflow (approval_status
383
+ # "rejected") answers 409 "review_required": it publishes only after a
384
+ # new review (create it again with approval_workflow_id).
362
385
  def publish(post_id)
363
386
  @client.request("POST", "/posts/#{post_id}/publish")
364
387
  end
@@ -369,32 +392,50 @@ module OmniSocials
369
392
  # Only the platforms that failed are re-published; platforms that
370
393
  # already succeeded are never posted again. Asynchronous: a 200 means
371
394
  # the retry is queued - poll `get` for the outcome. Max 3 retries per
372
- # platform.
395
+ # platform. While another retry runs (a second request, the dashboard,
396
+ # the automatic retry) the answer is 409 "retry_in_progress" and
397
+ # nothing is queued: poll `get` and retry once the post is "failed" or
398
+ # "warning" again.
373
399
  def retry(post_id)
374
400
  @client.request("POST", "/posts/#{post_id}/retry")
375
401
  end
376
402
 
377
403
  # POST /posts/{id}/approve - approve the current step of a post's
378
404
  # approval workflow, on behalf of the user who owns this API key. That
379
- # user must be a listed approver for the workflow's CURRENT step -
405
+ # user must be a listed approver for the workflow's CURRENT step:
380
406
  # steps approve in order, so an approver on a later step gets a 403
381
407
  # "forbidden" error until earlier steps clear. Only works on a post
382
408
  # with approval_status "pending". If this is the last step, the post
383
409
  # finalizes immediately ("scheduled" or "posting"); otherwise it stays
384
410
  # "in_approval" and the next step's approvers are notified.
385
- def approve(post_id)
386
- @client.request("POST", "/posts/#{post_id}/approve")
411
+ #
412
+ # Pass step_order: the "current_step" of #get_approval, the step you
413
+ # reviewed. When the review is on another step now (somebody decided
414
+ # since you read it, or a retried call already went through), nothing
415
+ # is approved and the call raises a 409 OmniSocials::APIError with
416
+ # code "step_changed"; err.body["error"]["current_step_order"] is the
417
+ # step the review is on now. Read the approval again before you
418
+ # decide. Without step_order the call approves whatever step is
419
+ # current, so a retry after a timeout can approve the next step too.
420
+ def approve(post_id, step_order: nil)
421
+ body = step_order.nil? ? nil : { "step_order" => step_order }
422
+ @client.request("POST", "/posts/#{post_id}/approve", json: body)
387
423
  end
388
424
 
389
425
  # POST /posts/{id}/reject - reject a post's approval workflow, on
390
426
  # behalf of the user who owns this API key. Same approver requirement
391
427
  # as #approve. Unlike approval, a rejection stops the WHOLE workflow
392
- # immediately (not just the current step) - the post's status becomes
393
- # "rejected". `comment` is optional and, when given, is shown to the
394
- # requester and other approvers in the post's review thread.
395
- def reject(post_id, comment: nil)
396
- body = comment ? { comment: comment } : nil
397
- @client.request("POST", "/posts/#{post_id}/reject", json: body)
428
+ # immediately (not just the current step): the post's status becomes
429
+ # "rejected". `comment` is optional (max 2000 characters) and, when
430
+ # given, is shown to the requester and other approvers in the post's
431
+ # review thread. `step_order` works as on #approve: when the review
432
+ # moved on, nothing is rejected and the call raises a 409
433
+ # "step_changed" error with "current_step_order" in its body.
434
+ def reject(post_id, comment: nil, step_order: nil)
435
+ body = {}
436
+ body["comment"] = comment if comment
437
+ body["step_order"] = step_order unless step_order.nil?
438
+ @client.request("POST", "/posts/#{post_id}/reject", json: body.empty? ? nil : body)
398
439
  end
399
440
 
400
441
  # GET /posts/{id}/approval - the approval review of a post: every step
@@ -3,8 +3,11 @@
3
3
  module OmniSocials
4
4
  module Resources
5
5
  # Webhooks resource: manage event subscriptions (post.scheduled,
6
- # post.published, post.failed, post.approved, post.rejected, and
7
- # ad.status_changed for ad campaigns).
6
+ # post.published, post.failed, post.approved, post.rejected, and for ads
7
+ # ad.status_changed, ad.created, ad.updated, ad.review,
8
+ # ad.delivery_issue, campaign.created, campaign.updated,
9
+ # campaign.budget, lead.received, ads.sync_failed, ads.sync_recovered,
10
+ # ads.initial_sync_completed and ad_rule.triggered).
8
11
  #
9
12
  # For verifying incoming deliveries, see OmniSocials::Webhooks.verify.
10
13
  class Webhooks
@@ -12,12 +15,21 @@ module OmniSocials
12
15
  @client = client
13
16
  end
14
17
 
15
- # GET /webhooks - list webhook subscriptions.
18
+ # GET /webhooks - list the webhooks of the key's workspace and the
19
+ # organisation-wide webhooks of its organisation.
20
+ #
21
+ # Every webhook carries "workspace_id": nil for an organisation-wide
22
+ # webhook (made in the OmniSocials dashboard), which receives the
23
+ # events of every workspace of the organisation. A webhook whose
24
+ # creator lost access to the organisation or workspace is switched off
25
+ # automatically: "is_active" is false and "last_failure"["error"] says
26
+ # why.
16
27
  def list
17
28
  @client.request("GET", "/webhooks")
18
29
  end
19
30
 
20
- # GET /webhooks/{id} - fetch a single webhook subscription.
31
+ # GET /webhooks/{id} - fetch a webhook of the key's workspace, or an
32
+ # organisation-wide webhook of its organisation ("workspace_id" nil).
21
33
  def get(webhook_id)
22
34
  @client.request("GET", "/webhooks/#{webhook_id}")
23
35
  end
@@ -26,11 +38,19 @@ module OmniSocials
26
38
  #
27
39
  # `url` must be HTTPS. `events` is a non-empty subset of
28
40
  # post.scheduled, post.published, post.failed, post.approved,
29
- # post.rejected and ad.status_changed. The `data` of an
30
- # ad.status_changed delivery is the campaign, not a post: campaign_id,
31
- # workspace_id, name, platform, campaign_type, status, previous_status,
32
- # external_campaign_id and budget. The signing `secret` is only
33
- # returned once, in this response - store it.
41
+ # post.rejected and the ads events ad.status_changed, ad.created,
42
+ # ad.updated, ad.review, ad.delivery_issue, campaign.created,
43
+ # campaign.updated, campaign.budget, lead.received, ads.sync_failed,
44
+ # ads.sync_recovered, ads.initial_sync_completed and
45
+ # ad_rule.triggered. The `data` of an ad.status_changed delivery is
46
+ # the campaign, not a post: campaign_id, workspace_id, name, platform,
47
+ # campaign_type, status, previous_status, external_campaign_id and
48
+ # budget; the other ads events carry the campaign (plus "details") or
49
+ # their own data (a lead, a rule run, an ad account). Any Ads event
50
+ # (ad.*, campaign.*, lead.*, ads.*, ad_rule.*) needs the ads:read scope
51
+ # on the key and access_ads for its person (403 insufficient_scope /
52
+ # 403 insufficient_permission). The signing
53
+ # `secret` is only returned once, in this response - store it.
34
54
  def create(url:, events:)
35
55
  @client.request(
36
56
  "POST", "/webhooks",
@@ -38,7 +58,12 @@ module OmniSocials
38
58
  )
39
59
  end
40
60
 
41
- # PATCH /webhooks/{id} - update url, events, or active state.
61
+ # PATCH /webhooks/{id} - update url, events, or active state. Ads
62
+ # events need the same ads:read scope and access_ads as on create.
63
+ # Works on organisation-wide webhooks too. is_active: true switches on
64
+ # a webhook that was switched off (also an automatic switch-off);
65
+ # setting url, events or switching it on makes the key's creator the
66
+ # person behind the webhook.
42
67
  def update(webhook_id, url: nil, events: nil, is_active: nil)
43
68
  body = Internal.drop_nil(
44
69
  {
@@ -50,14 +75,23 @@ module OmniSocials
50
75
  @client.request("PATCH", "/webhooks/#{webhook_id}", json: body)
51
76
  end
52
77
 
53
- # DELETE /webhooks/{id} - delete a webhook. Returns nil (204).
78
+ # DELETE /webhooks/{id} - delete a webhook of the key's workspace or
79
+ # an organisation-wide webhook of its organisation. Returns nil (204).
54
80
  def delete(webhook_id)
55
81
  @client.request("DELETE", "/webhooks/#{webhook_id}")
56
82
  end
57
83
 
58
84
  # POST /webhooks/{id}/rotate-secret - rotate the signing secret.
59
85
  #
60
- # The new secret is only returned once, in this response.
86
+ # The new secret is only returned once, in this response. The old
87
+ # secret keeps signing for 24 hours: every delivery then carries
88
+ # X-OmniSocials-Signature (new secret) and
89
+ # X-OmniSocials-Signature-Previous (old secret, same format, same
90
+ # timestamp and body). Verify the first with the new secret and, when
91
+ # that fails, the second with the old one (see
92
+ # OmniSocials::Webhooks.verify). Rotating again within the 24 hours
93
+ # replaces the previous secret with the one just rotated out. Works on
94
+ # organisation-wide webhooks too.
61
95
  def rotate_secret(webhook_id)
62
96
  @client.request("POST", "/webhooks/#{webhook_id}/rotate-secret")
63
97
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OmniSocials
4
- VERSION = "0.15.0"
4
+ VERSION = "0.16.0"
5
5
  end
@@ -11,6 +11,12 @@ module OmniSocials
11
11
  # - Header: X-OmniSocials-Signature: t=<unix>,v1=<hex>
12
12
  # - Signed value: "{timestamp}.{raw_body}" (UTF-8), keyed with the
13
13
  # webhook's secret, hex digest.
14
+ # - For 24 hours after a secret rotation, deliveries also carry
15
+ # X-OmniSocials-Signature-Previous: the same format, timestamp and body,
16
+ # signed with the old secret. To keep accepting deliveries while you
17
+ # switch secrets, verify X-OmniSocials-Signature with the new secret
18
+ # and, when that raises, X-OmniSocials-Signature-Previous with the old
19
+ # secret.
14
20
  module Webhooks
15
21
  class << self
16
22
  # Verify an OmniSocials webhook delivery and return the parsed event.
@@ -19,7 +25,9 @@ module OmniSocials
19
25
  # parse and re-serialize it first; the signature is over the
20
26
  # raw bytes.
21
27
  # signature - the X-OmniSocials-Signature header value, of the form
22
- # t=<unix>,v1=<hex>.
28
+ # t=<unix>,v1=<hex>. For 24 hours after a secret rotation,
29
+ # pass the X-OmniSocials-Signature-Previous value here
30
+ # with the old secret when the new secret does not match.
23
31
  # secret - the webhook's signing secret (returned once when the
24
32
  # webhook is created, or via rotate_secret).
25
33
  # tolerance - maximum allowed age (and future skew) of the signed
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omnisocials
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.0
4
+ version: 0.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - OmniSocials
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-11-05 00:00:00.000000000 Z
11
+ date: 2026-11-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Schedule and publish social media posts, upload media, and read analytics
14
14
  across Instagram, Facebook, LinkedIn, YouTube, TikTok, X, Pinterest, Bluesky, Threads,