omnisocials 0.16.0 → 0.17.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 +4 -4
- data/lib/omnisocials/client.rb +3 -1
- data/lib/omnisocials/internal.rb +21 -2
- data/lib/omnisocials/resources/accounts.rb +1 -1
- data/lib/omnisocials/resources/analytics.rb +1 -1
- data/lib/omnisocials/resources/automations.rb +7 -5
- data/lib/omnisocials/resources/feature_requests.rb +1 -1
- data/lib/omnisocials/resources/folders.rb +2 -2
- data/lib/omnisocials/resources/hashtag_sets.rb +3 -3
- data/lib/omnisocials/resources/inbox.rb +1 -1
- data/lib/omnisocials/resources/media.rb +3 -3
- data/lib/omnisocials/resources/posts.rb +8 -8
- data/lib/omnisocials/resources/tags.rb +2 -2
- data/lib/omnisocials/resources/webhooks.rb +10 -5
- data/lib/omnisocials/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ed162913bd0b1df20523b08aa142a02796d6582043bcd83e240beeb8c66f63fe
|
|
4
|
+
data.tar.gz: 849d9a1b4cfcc90de8e49c62084c2bb24e25c89890fac04f0b643504bb9052a9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6b3c178ef5fe80eb82627dee0fb49820b774b19f5fcfc2c806c7e6c427d186d4f50f809ed313a428f4025d1e57097fab653f6a55a0d5ec1380baac17db7c2788
|
|
7
|
+
data.tar.gz: 51133e2698b555d04f47a4d3aa9df28e2407484f3705a6758688d97fda76276a7a1d54d39702437c1f87e13e082ce342e55588fc4e2cab07ffe21cfa6fbe4358
|
data/lib/omnisocials/client.rb
CHANGED
|
@@ -154,7 +154,9 @@ module OmniSocials
|
|
|
154
154
|
private
|
|
155
155
|
|
|
156
156
|
def build_uri(path, query)
|
|
157
|
-
|
|
157
|
+
# Every id in path was encoded with Internal.path_segment; this refuses
|
|
158
|
+
# an id of "", "." or ".." before the request is sent.
|
|
159
|
+
uri = URI.parse("#{base_url}#{Internal.check_path(path)}")
|
|
158
160
|
pairs = Internal.serialize_query(query)
|
|
159
161
|
uri.query = URI.encode_www_form(pairs) if pairs
|
|
160
162
|
uri
|
data/lib/omnisocials/internal.rb
CHANGED
|
@@ -35,12 +35,31 @@ module OmniSocials
|
|
|
35
35
|
hash.reject { |_key, value| value.nil? || value.is_a?(NotGiven) }
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
-
# URL-encode
|
|
39
|
-
#
|
|
38
|
+
# URL-encode a caller-supplied id as exactly one path segment. "/", "?",
|
|
39
|
+
# "#" and "%" are encoded too, so an id cannot add a segment, start a
|
|
40
|
+
# query or a fragment, or carry an escape of its own (an id such as
|
|
41
|
+
# "../webhooks/wh_1/rotate-secret#" would otherwise move the call to
|
|
42
|
+
# another endpoint of the same API key). Spaces become %20 (a path
|
|
43
|
+
# segment treats "+" literally, unlike a query string). Every id that
|
|
44
|
+
# goes into a request path goes through this method.
|
|
40
45
|
def path_segment(value)
|
|
41
46
|
CGI.escape(value.to_s).gsub("+", "%20")
|
|
42
47
|
end
|
|
43
48
|
|
|
49
|
+
# Refuse a request path with an empty, "." or ".." segment.
|
|
50
|
+
# path_segment leaves "." and ".." as they are, and URL normalization
|
|
51
|
+
# drops such a segment or climbs one level, so an id of ".." would reach
|
|
52
|
+
# another endpoint; an empty id would reach the list route. Raises
|
|
53
|
+
# ArgumentError before anything is sent.
|
|
54
|
+
def check_path(path)
|
|
55
|
+
segments = path.to_s.split("?", 2).first.to_s.split("/", -1).drop(1)
|
|
56
|
+
if segments.any? { |segment| segment.empty? || segment == "." || segment == ".." }
|
|
57
|
+
raise ArgumentError, "Invalid request path #{path.inspect}: an id cannot be empty, \".\" or \"..\"."
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
path
|
|
61
|
+
end
|
|
62
|
+
|
|
44
63
|
# Join an array into a comma-separated string; pass strings through.
|
|
45
64
|
def join_list(value)
|
|
46
65
|
return nil if value.nil?
|
|
@@ -10,7 +10,7 @@ module OmniSocials
|
|
|
10
10
|
|
|
11
11
|
# GET /analytics/posts/{id} - latest per-platform metrics for one post.
|
|
12
12
|
def post(post_id)
|
|
13
|
-
@client.request("GET", "/analytics/posts/#{post_id}")
|
|
13
|
+
@client.request("GET", "/analytics/posts/#{Internal.path_segment(post_id)}")
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
# GET /analytics/posts?ids=a,b,c - bulk metrics for up to 100 posts in
|
|
@@ -35,7 +35,7 @@ module OmniSocials
|
|
|
35
35
|
# GET /automations/{id} - fetch a single automation. Requires the
|
|
36
36
|
# automations:read scope (opt-in on the API key).
|
|
37
37
|
def get(automation_id)
|
|
38
|
-
@client.request("GET", "/automations/#{automation_id}")
|
|
38
|
+
@client.request("GET", "/automations/#{Internal.path_segment(automation_id)}")
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
# POST /automations - create a comment-to-DM automation.
|
|
@@ -131,13 +131,13 @@ module OmniSocials
|
|
|
131
131
|
trigger: trigger, actions: actions, limits: limits, status: status,
|
|
132
132
|
platform: platform, facebook_post_id: facebook_post_id
|
|
133
133
|
)
|
|
134
|
-
@client.request("PATCH", "/automations/#{automation_id}", json: body)
|
|
134
|
+
@client.request("PATCH", "/automations/#{Internal.path_segment(automation_id)}", json: body)
|
|
135
135
|
end
|
|
136
136
|
|
|
137
137
|
# DELETE /automations/{id} - delete an automation. Returns nil (204).
|
|
138
138
|
# Requires the automations:write scope.
|
|
139
139
|
def delete(automation_id)
|
|
140
|
-
@client.request("DELETE", "/automations/#{automation_id}")
|
|
140
|
+
@client.request("DELETE", "/automations/#{Internal.path_segment(automation_id)}")
|
|
141
141
|
end
|
|
142
142
|
|
|
143
143
|
# GET /automations/{id}/events - the automation's activity: one event
|
|
@@ -154,7 +154,9 @@ module OmniSocials
|
|
|
154
154
|
# events is left out). Each event carries kind ("comment", "dm",
|
|
155
155
|
# "story_reply"), outcome, reason / reason_label (X adds the skip
|
|
156
156
|
# reasons "dms_closed", "no_credits", "opted_out" and
|
|
157
|
-
# "automation_off"; Follow first adds "already_waiting"
|
|
157
|
+
# "automation_off"; Follow first adds "already_waiting";
|
|
158
|
+
# "plan_inactive" = the organisation had no active plan or trial, so
|
|
159
|
+
# nothing was sent), person (id,
|
|
158
160
|
# username; on Facebook the person's name, since Facebook has no
|
|
159
161
|
# @handle), trigger_id, trigger_text, message (the DM sent),
|
|
160
162
|
# public_reply, platform_message_id, follow_gate (Follow first:
|
|
@@ -162,7 +164,7 @@ module OmniSocials
|
|
|
162
164
|
# "checked", "after_ask" }, else nil), created_at and sent_at.
|
|
163
165
|
def list_events(automation_id, outcome: nil, limit: nil, offset: nil)
|
|
164
166
|
@client.request(
|
|
165
|
-
"GET", "/automations/#{automation_id}/events",
|
|
167
|
+
"GET", "/automations/#{Internal.path_segment(automation_id)}/events",
|
|
166
168
|
query: { "outcome" => outcome, "limit" => limit, "offset" => offset }
|
|
167
169
|
)
|
|
168
170
|
end
|
|
@@ -54,7 +54,7 @@ module OmniSocials
|
|
|
54
54
|
# GET /feature-requests/{id} - one request with its status and the
|
|
55
55
|
# team's replies. Errors: 400 invalid_id, 404 not_found.
|
|
56
56
|
def get(request_id)
|
|
57
|
-
@client.request("GET", "/feature-requests/#{request_id}")
|
|
57
|
+
@client.request("GET", "/feature-requests/#{Internal.path_segment(request_id)}")
|
|
58
58
|
end
|
|
59
59
|
end
|
|
60
60
|
end
|
|
@@ -26,7 +26,7 @@ module OmniSocials
|
|
|
26
26
|
def update(folder_id, name: nil, parent_id: OmniSocials::NOT_GIVEN)
|
|
27
27
|
body = Internal.drop_nil({ "name" => name })
|
|
28
28
|
body["parent_id"] = parent_id unless parent_id.is_a?(NotGiven)
|
|
29
|
-
@client.request("PATCH", "/folders/#{folder_id}", json: body)
|
|
29
|
+
@client.request("PATCH", "/folders/#{Internal.path_segment(folder_id)}", json: body)
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
# DELETE /folders/{id} - delete a folder. Returns nil (204).
|
|
@@ -34,7 +34,7 @@ module OmniSocials
|
|
|
34
34
|
# The folder's media is NOT deleted: files move to the root and
|
|
35
35
|
# subfolders move up to the deleted folder's parent.
|
|
36
36
|
def delete(folder_id)
|
|
37
|
-
@client.request("DELETE", "/folders/#{folder_id}")
|
|
37
|
+
@client.request("DELETE", "/folders/#{Internal.path_segment(folder_id)}")
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
40
|
end
|
|
@@ -16,7 +16,7 @@ module OmniSocials
|
|
|
16
16
|
|
|
17
17
|
# GET /hashtag-sets/{id} - fetch a single hashtag set.
|
|
18
18
|
def get(hashtag_set_id)
|
|
19
|
-
@client.request("GET", "/hashtag-sets/#{hashtag_set_id}")
|
|
19
|
+
@client.request("GET", "/hashtag-sets/#{Internal.path_segment(hashtag_set_id)}")
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
# POST /hashtag-sets - create a hashtag set.
|
|
@@ -36,12 +36,12 @@ module OmniSocials
|
|
|
36
36
|
# `hashtags` replaces the FULL list.
|
|
37
37
|
def update(hashtag_set_id, name: nil, hashtags: nil)
|
|
38
38
|
body = Internal.drop_nil({ "name" => name, "hashtags" => hashtags })
|
|
39
|
-
@client.request("PATCH", "/hashtag-sets/#{hashtag_set_id}", json: body)
|
|
39
|
+
@client.request("PATCH", "/hashtag-sets/#{Internal.path_segment(hashtag_set_id)}", json: body)
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
# DELETE /hashtag-sets/{id} - delete a hashtag set. Returns nil (204).
|
|
43
43
|
def delete(hashtag_set_id)
|
|
44
|
-
@client.request("DELETE", "/hashtag-sets/#{hashtag_set_id}")
|
|
44
|
+
@client.request("DELETE", "/hashtag-sets/#{Internal.path_segment(hashtag_set_id)}")
|
|
45
45
|
end
|
|
46
46
|
end
|
|
47
47
|
end
|
|
@@ -279,7 +279,7 @@ module OmniSocials
|
|
|
279
279
|
# escaped; spaces become %20 (a path segment treats "+" literally,
|
|
280
280
|
# unlike a query string).
|
|
281
281
|
def encode_id(conversation_id)
|
|
282
|
-
|
|
282
|
+
Internal.path_segment(conversation_id)
|
|
283
283
|
end
|
|
284
284
|
end
|
|
285
285
|
end
|
|
@@ -24,7 +24,7 @@ module OmniSocials
|
|
|
24
24
|
|
|
25
25
|
# GET /media/{id} - fetch a single library file.
|
|
26
26
|
def get(media_id)
|
|
27
|
-
@client.request("GET", "/media/#{media_id}")
|
|
27
|
+
@client.request("GET", "/media/#{Internal.path_segment(media_id)}")
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
# POST /media/upload - multipart upload (max 100MB inline).
|
|
@@ -130,7 +130,7 @@ module OmniSocials
|
|
|
130
130
|
def update(media_id, name: nil, folder_id: OmniSocials::NOT_GIVEN)
|
|
131
131
|
body = Internal.drop_nil({ "name" => name })
|
|
132
132
|
body["folder_id"] = folder_id unless folder_id.is_a?(NotGiven)
|
|
133
|
-
@client.request("PATCH", "/media/#{media_id}", json: body)
|
|
133
|
+
@client.request("PATCH", "/media/#{Internal.path_segment(media_id)}", json: body)
|
|
134
134
|
end
|
|
135
135
|
|
|
136
136
|
# DELETE /media/{id} - delete a file. Returns nil (204).
|
|
@@ -138,7 +138,7 @@ module OmniSocials
|
|
|
138
138
|
# Fails with 409 media_in_use if the file is attached to a scheduled or
|
|
139
139
|
# publishing post.
|
|
140
140
|
def delete(media_id)
|
|
141
|
-
@client.request("DELETE", "/media/#{media_id}")
|
|
141
|
+
@client.request("DELETE", "/media/#{Internal.path_segment(media_id)}")
|
|
142
142
|
end
|
|
143
143
|
end
|
|
144
144
|
end
|
|
@@ -43,7 +43,7 @@ module OmniSocials
|
|
|
43
43
|
|
|
44
44
|
# GET /posts/{id} - fetch a single post.
|
|
45
45
|
def get(post_id)
|
|
46
|
-
@client.request("GET", "/posts/#{post_id}")
|
|
46
|
+
@client.request("GET", "/posts/#{Internal.path_segment(post_id)}")
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
# GET /posts/recent-platform - recent posts fetched live from the
|
|
@@ -364,7 +364,7 @@ module OmniSocials
|
|
|
364
364
|
body["discord"] = discord unless discord.is_a?(NotGiven)
|
|
365
365
|
# And for tags: an explicit nil (or []) removes every tag of the post.
|
|
366
366
|
body["tags"] = tags unless tags.is_a?(NotGiven)
|
|
367
|
-
@client.request("PATCH", "/posts/#{post_id}", json: body)
|
|
367
|
+
@client.request("PATCH", "/posts/#{Internal.path_segment(post_id)}", json: body)
|
|
368
368
|
end
|
|
369
369
|
|
|
370
370
|
# DELETE /posts/{id} - remove a post from OmniSocials (the live post
|
|
@@ -373,7 +373,7 @@ module OmniSocials
|
|
|
373
373
|
# channels, the answer is 409 "post_publishing" and nothing is deleted:
|
|
374
374
|
# poll #get until "published", "warning" or "failed", then delete it.
|
|
375
375
|
def delete(post_id)
|
|
376
|
-
@client.request("DELETE", "/posts/#{post_id}")
|
|
376
|
+
@client.request("DELETE", "/posts/#{Internal.path_segment(post_id)}")
|
|
377
377
|
end
|
|
378
378
|
|
|
379
379
|
# POST /posts/{id}/publish - publish a draft or scheduled post now.
|
|
@@ -383,7 +383,7 @@ module OmniSocials
|
|
|
383
383
|
# "rejected") answers 409 "review_required": it publishes only after a
|
|
384
384
|
# new review (create it again with approval_workflow_id).
|
|
385
385
|
def publish(post_id)
|
|
386
|
-
@client.request("POST", "/posts/#{post_id}/publish")
|
|
386
|
+
@client.request("POST", "/posts/#{Internal.path_segment(post_id)}/publish")
|
|
387
387
|
end
|
|
388
388
|
|
|
389
389
|
# POST /posts/{id}/retry - retry the failed platforms of a "failed" or
|
|
@@ -397,7 +397,7 @@ module OmniSocials
|
|
|
397
397
|
# nothing is queued: poll `get` and retry once the post is "failed" or
|
|
398
398
|
# "warning" again.
|
|
399
399
|
def retry(post_id)
|
|
400
|
-
@client.request("POST", "/posts/#{post_id}/retry")
|
|
400
|
+
@client.request("POST", "/posts/#{Internal.path_segment(post_id)}/retry")
|
|
401
401
|
end
|
|
402
402
|
|
|
403
403
|
# POST /posts/{id}/approve - approve the current step of a post's
|
|
@@ -419,7 +419,7 @@ module OmniSocials
|
|
|
419
419
|
# current, so a retry after a timeout can approve the next step too.
|
|
420
420
|
def approve(post_id, step_order: nil)
|
|
421
421
|
body = step_order.nil? ? nil : { "step_order" => step_order }
|
|
422
|
-
@client.request("POST", "/posts/#{post_id}/approve", json: body)
|
|
422
|
+
@client.request("POST", "/posts/#{Internal.path_segment(post_id)}/approve", json: body)
|
|
423
423
|
end
|
|
424
424
|
|
|
425
425
|
# POST /posts/{id}/reject - reject a post's approval workflow, on
|
|
@@ -435,7 +435,7 @@ module OmniSocials
|
|
|
435
435
|
body = {}
|
|
436
436
|
body["comment"] = comment if comment
|
|
437
437
|
body["step_order"] = step_order unless step_order.nil?
|
|
438
|
-
@client.request("POST", "/posts/#{post_id}/reject", json: body.empty? ? nil : body)
|
|
438
|
+
@client.request("POST", "/posts/#{Internal.path_segment(post_id)}/reject", json: body.empty? ? nil : body)
|
|
439
439
|
end
|
|
440
440
|
|
|
441
441
|
# GET /posts/{id}/approval - the approval review of a post: every step
|
|
@@ -451,7 +451,7 @@ module OmniSocials
|
|
|
451
451
|
# and empty steps and comments. Read-only; requires the posts:read
|
|
452
452
|
# scope.
|
|
453
453
|
def get_approval(post_id)
|
|
454
|
-
@client.request("GET", "/posts/#{post_id}/approval")
|
|
454
|
+
@client.request("GET", "/posts/#{Internal.path_segment(post_id)}/approval")
|
|
455
455
|
end
|
|
456
456
|
|
|
457
457
|
private
|
|
@@ -51,13 +51,13 @@ module OmniSocials
|
|
|
51
51
|
# 409 tag_exists.
|
|
52
52
|
def update(tag_id, name: nil, color: nil)
|
|
53
53
|
body = Internal.drop_nil({ "name" => name, "color" => color })
|
|
54
|
-
@client.request("PATCH", "/tags/#{tag_id}", json: body)
|
|
54
|
+
@client.request("PATCH", "/tags/#{Internal.path_segment(tag_id)}", json: body)
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
# DELETE /tags/{id} - delete a tag and take it off every post (the
|
|
58
58
|
# posts stay). Returns { "data" => { "tag", "posts_untagged" } }.
|
|
59
59
|
def delete(tag_id)
|
|
60
|
-
@client.request("DELETE", "/tags/#{tag_id}")
|
|
60
|
+
@client.request("DELETE", "/tags/#{Internal.path_segment(tag_id)}")
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
# POST /tags/apply - add, remove or replace the tags of up to 500 posts
|
|
@@ -31,7 +31,7 @@ module OmniSocials
|
|
|
31
31
|
# GET /webhooks/{id} - fetch a webhook of the key's workspace, or an
|
|
32
32
|
# organisation-wide webhook of its organisation ("workspace_id" nil).
|
|
33
33
|
def get(webhook_id)
|
|
34
|
-
@client.request("GET", "/webhooks/#{webhook_id}")
|
|
34
|
+
@client.request("GET", "/webhooks/#{Internal.path_segment(webhook_id)}")
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
# POST /webhooks - create a webhook subscription.
|
|
@@ -63,7 +63,12 @@ module OmniSocials
|
|
|
63
63
|
# Works on organisation-wide webhooks too. is_active: true switches on
|
|
64
64
|
# a webhook that was switched off (also an automatic switch-off);
|
|
65
65
|
# setting url, events or switching it on makes the key's creator the
|
|
66
|
-
# person behind the webhook.
|
|
66
|
+
# person behind the webhook. Setting url on an organisation-wide
|
|
67
|
+
# webhook (even its current one) moves it to the key's workspace: from
|
|
68
|
+
# then on it gets only that workspace's events, and the answer shows
|
|
69
|
+
# the new workspace_id. When the webhook has Ads events after the
|
|
70
|
+
# change, setting url or events or switching it on needs ads:read and
|
|
71
|
+
# access_ads (403 otherwise, nothing changed).
|
|
67
72
|
def update(webhook_id, url: nil, events: nil, is_active: nil)
|
|
68
73
|
body = Internal.drop_nil(
|
|
69
74
|
{
|
|
@@ -72,13 +77,13 @@ module OmniSocials
|
|
|
72
77
|
"is_active" => is_active
|
|
73
78
|
}
|
|
74
79
|
)
|
|
75
|
-
@client.request("PATCH", "/webhooks/#{webhook_id}", json: body)
|
|
80
|
+
@client.request("PATCH", "/webhooks/#{Internal.path_segment(webhook_id)}", json: body)
|
|
76
81
|
end
|
|
77
82
|
|
|
78
83
|
# DELETE /webhooks/{id} - delete a webhook of the key's workspace or
|
|
79
84
|
# an organisation-wide webhook of its organisation. Returns nil (204).
|
|
80
85
|
def delete(webhook_id)
|
|
81
|
-
@client.request("DELETE", "/webhooks/#{webhook_id}")
|
|
86
|
+
@client.request("DELETE", "/webhooks/#{Internal.path_segment(webhook_id)}")
|
|
82
87
|
end
|
|
83
88
|
|
|
84
89
|
# POST /webhooks/{id}/rotate-secret - rotate the signing secret.
|
|
@@ -93,7 +98,7 @@ module OmniSocials
|
|
|
93
98
|
# replaces the previous secret with the one just rotated out. Works on
|
|
94
99
|
# organisation-wide webhooks too.
|
|
95
100
|
def rotate_secret(webhook_id)
|
|
96
|
-
@client.request("POST", "/webhooks/#{webhook_id}/rotate-secret")
|
|
101
|
+
@client.request("POST", "/webhooks/#{Internal.path_segment(webhook_id)}/rotate-secret")
|
|
97
102
|
end
|
|
98
103
|
end
|
|
99
104
|
end
|
data/lib/omnisocials/version.rb
CHANGED
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.
|
|
4
|
+
version: 0.17.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-
|
|
11
|
+
date: 2026-11-08 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,
|