postproxy-sdk 1.2.0 → 1.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 665c9b0d7745b0da8ae0bd7864047997816bfa532725ee338588b94f1e6e9724
4
- data.tar.gz: d9ebae2aa90d310886561d4ec4b2da268a2dcd6d341b59343c1661c3429b656c
3
+ metadata.gz: 220a9066d8453acb2430cf48d76d634e8ac69a62a244bedb28a8d1e00a4f5232
4
+ data.tar.gz: c5b68356a893d52101198f827d55e31f2931629d170b152b1a038a02f9151350
5
5
  SHA512:
6
- metadata.gz: 32384b1c8ca96c498094d59530fd2617a542a911342ef969c93243f31da53afeb06a5d9de458413bfd0ef584c09c53a207743d0a217d49fb1dc097972e2e697e
7
- data.tar.gz: 15c9e8c42a588f99fe9ef0eb93536c7206f3a90b16d75cd1648bb1497ec5fb3b9e00fae71de3abad3b2a4c2ca442c88aea54ba129b58f6d4dc283d8c9a07de0d
6
+ metadata.gz: 580704f8585988b149e298ad924865d7a6bf7004709af8babb0761e898d6748ac907dcbe428042049d2951f61dd25de103f28edb57b966fa5b7a70c1394fffb9
7
+ data.tar.gz: 9d259eeab2ff02ddb7af93d1c62eb8950469d18ecbb01d42321d8d158f20299bb4447da88a1200b933f993bad119693ac98a522980fdd5cb3335f4c29935e2f8
data/README.md CHANGED
@@ -157,6 +157,57 @@ Stats vary by platform:
157
157
  | TikTok | `impressions`, `likes`, `comments`, `shares` |
158
158
  | Pinterest | `impressions`, `likes`, `comments`, `saved`, `outbound_clicks` |
159
159
 
160
+ ## Queues
161
+
162
+ ```ruby
163
+ # List all queues
164
+ queues = client.queues.list.data
165
+
166
+ # Get a queue
167
+ queue = client.queues.get("queue-id")
168
+
169
+ # Get next available slot
170
+ next_slot = client.queues.next_slot("queue-id")
171
+ puts next_slot.next_slot
172
+
173
+ # Create a queue with timeslots
174
+ queue = client.queues.create(
175
+ "Morning Posts",
176
+ profile_group_id: "pg-abc",
177
+ description: "Weekday morning content",
178
+ timezone: "America/New_York",
179
+ jitter: 10,
180
+ timeslots: [
181
+ { day: 1, time: "09:00" },
182
+ { day: 2, time: "09:00" },
183
+ { day: 3, time: "09:00" },
184
+ ]
185
+ )
186
+
187
+ # Update a queue
188
+ queue = client.queues.update("queue-id",
189
+ jitter: 15,
190
+ timeslots: [
191
+ { day: 6, time: "10:00" }, # add new timeslot
192
+ { id: 1, _destroy: true }, # remove existing timeslot
193
+ ]
194
+ )
195
+
196
+ # Pause/unpause a queue
197
+ client.queues.update("queue-id", enabled: false)
198
+
199
+ # Delete a queue
200
+ client.queues.delete("queue-id")
201
+
202
+ # Add a post to a queue
203
+ post = client.posts.create(
204
+ "This post will be scheduled by the queue",
205
+ profiles: ["prof-1"],
206
+ queue_id: "queue-id",
207
+ queue_priority: "high"
208
+ )
209
+ ```
210
+
160
211
  ## Webhooks
161
212
 
162
213
  ```ruby
@@ -5,6 +5,7 @@ require_relative "resources/posts"
5
5
  require_relative "resources/profiles"
6
6
  require_relative "resources/profile_groups"
7
7
  require_relative "resources/webhooks"
8
+ require_relative "resources/queues"
8
9
 
9
10
  module PostProxy
10
11
  class Client
@@ -19,6 +20,7 @@ module PostProxy
19
20
  @profiles = nil
20
21
  @profile_groups = nil
21
22
  @webhooks = nil
23
+ @queues = nil
22
24
  end
23
25
 
24
26
  def posts
@@ -37,6 +39,10 @@ module PostProxy
37
39
  @webhooks ||= Resources::Webhooks.new(self)
38
40
  end
39
41
 
42
+ def queues
43
+ @queues ||= Resources::Queues.new(self)
44
+ end
45
+
40
46
  def request(method, path, params: nil, json: nil, data: nil, files: nil, profile_group_id: nil)
41
47
  url = "/api#{path}"
42
48
 
@@ -14,7 +14,7 @@ module PostProxy
14
14
  PLATFORM_POST_STATUSES = %w[pending processing published failed deleted].freeze
15
15
 
16
16
  INSTAGRAM_FORMATS = %w[post reel story].freeze
17
- FACEBOOK_FORMATS = %w[post story].freeze
17
+ FACEBOOK_FORMATS = %w[post story reel].freeze
18
18
  TIKTOK_FORMATS = %w[video image].freeze
19
19
  LINKEDIN_FORMATS = %w[post].freeze
20
20
  YOUTUBE_FORMATS = %w[post].freeze
@@ -29,7 +29,8 @@ module PostProxy
29
29
  end
30
30
 
31
31
  def create(body, profiles:, media: nil, media_files: nil, platforms: nil,
32
- thread: nil, scheduled_at: nil, draft: nil, profile_group_id: nil)
32
+ thread: nil, scheduled_at: nil, draft: nil, queue_id: nil,
33
+ queue_priority: nil, profile_group_id: nil)
33
34
  has_files = media_files && !media_files.empty?
34
35
  has_thread_files = thread&.any? { |t| t[:media_files]&.any? }
35
36
 
@@ -95,6 +96,8 @@ module PostProxy
95
96
  json_body[:platforms] = platforms.is_a?(PlatformParams) ? platforms.to_h : platforms if platforms
96
97
  json_body[:media] = media if media
97
98
  json_body[:thread] = thread if thread
99
+ json_body[:queue_id] = queue_id if queue_id
100
+ json_body[:queue_priority] = queue_priority if queue_priority
98
101
 
99
102
  result = @client.request(:post, "/posts", json: json_body, profile_group_id: profile_group_id)
100
103
  end
@@ -0,0 +1,61 @@
1
+ module PostProxy
2
+ module Resources
3
+ class Queues
4
+ def initialize(client)
5
+ @client = client
6
+ end
7
+
8
+ def list(profile_group_id: nil)
9
+ result = @client.request(:get, "/post_queues", profile_group_id: profile_group_id)
10
+ queues = (result[:data] || []).map { |q| Queue.new(**q) }
11
+ ListResponse.new(data: queues)
12
+ end
13
+
14
+ def get(id)
15
+ result = @client.request(:get, "/post_queues/#{id}")
16
+ Queue.new(**result)
17
+ end
18
+
19
+ def next_slot(id)
20
+ result = @client.request(:get, "/post_queues/#{id}/next_slot")
21
+ NextSlotResponse.new(**result)
22
+ end
23
+
24
+ def create(name, profile_group_id:, description: nil, timezone: nil, jitter: nil, timeslots: nil)
25
+ post_queue = { name: name }
26
+ post_queue[:description] = description if description
27
+ post_queue[:timezone] = timezone if timezone
28
+ post_queue[:jitter] = jitter unless jitter.nil?
29
+ post_queue[:queue_timeslots_attributes] = timeslots if timeslots
30
+
31
+ json_body = {
32
+ profile_group_id: profile_group_id,
33
+ post_queue: post_queue,
34
+ }
35
+
36
+ result = @client.request(:post, "/post_queues", json: json_body)
37
+ Queue.new(**result)
38
+ end
39
+
40
+ def update(id, name: nil, description: nil, timezone: nil, enabled: nil, jitter: nil, timeslots: nil)
41
+ post_queue = {}
42
+ post_queue[:name] = name unless name.nil?
43
+ post_queue[:description] = description unless description.nil?
44
+ post_queue[:timezone] = timezone unless timezone.nil?
45
+ post_queue[:enabled] = enabled unless enabled.nil?
46
+ post_queue[:jitter] = jitter unless jitter.nil?
47
+ post_queue[:queue_timeslots_attributes] = timeslots if timeslots
48
+
49
+ json_body = { post_queue: post_queue }
50
+
51
+ result = @client.request(:patch, "/post_queues/#{id}", json: json_body)
52
+ Queue.new(**result)
53
+ end
54
+
55
+ def delete(id)
56
+ result = @client.request(:delete, "/post_queues/#{id}")
57
+ DeleteResponse.new(**result)
58
+ end
59
+ end
60
+ end
61
+ end
@@ -107,14 +107,40 @@ module PostProxy
107
107
  end
108
108
  end
109
109
 
110
+ class Timeslot < Model
111
+ attr_accessor :id, :day, :time
112
+ end
113
+
114
+ class Queue < Model
115
+ attr_accessor :id, :name, :description, :timezone, :enabled, :jitter,
116
+ :profile_group_id, :timeslots, :posts_count
117
+
118
+ def initialize(**attrs)
119
+ @description = nil
120
+ @timeslots = []
121
+ @posts_count = 0
122
+ super
123
+ @timeslots = (@timeslots || []).map do |t|
124
+ t.is_a?(Timeslot) ? t : Timeslot.new(**t.transform_keys(&:to_sym))
125
+ end
126
+ end
127
+ end
128
+
129
+ class NextSlotResponse < Model
130
+ attr_accessor :next_slot
131
+ end
132
+
110
133
  class Post < Model
111
- attr_accessor :id, :body, :status, :scheduled_at, :created_at, :media, :platforms, :thread
134
+ attr_accessor :id, :body, :status, :scheduled_at, :created_at, :media, :platforms, :thread,
135
+ :queue_id, :queue_priority
112
136
 
113
137
  def initialize(**attrs)
114
138
  @scheduled_at = nil
115
139
  @media = []
116
140
  @platforms = []
117
141
  @thread = []
142
+ @queue_id = nil
143
+ @queue_priority = nil
118
144
  super
119
145
  @scheduled_at = parse_time(@scheduled_at)
120
146
  @created_at = parse_time(@created_at)
@@ -265,7 +291,7 @@ module PostProxy
265
291
  # Platform-specific parameter structs
266
292
 
267
293
  class FacebookParams < Model
268
- attr_accessor :format, :first_comment, :page_id
294
+ attr_accessor :format, :title, :first_comment, :page_id
269
295
  end
270
296
 
271
297
  class InstagramParams < Model
@@ -1,3 +1,3 @@
1
1
  module PostProxy
2
- VERSION = "1.2.0"
2
+ VERSION = "1.4.1"
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.2.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - PostProxy
@@ -81,6 +81,7 @@ files:
81
81
  - lib/postproxy/resources/posts.rb
82
82
  - lib/postproxy/resources/profile_groups.rb
83
83
  - lib/postproxy/resources/profiles.rb
84
+ - lib/postproxy/resources/queues.rb
84
85
  - lib/postproxy/resources/webhooks.rb
85
86
  - lib/postproxy/types.rb
86
87
  - lib/postproxy/version.rb