postproxy-sdk 1.4.0 → 1.5.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: 8aa3207765c712cdc5887c3c94ae33010ec0e01f8487c867641929f84d8f08e7
4
- data.tar.gz: 1f40051ca925f4eda94ce0883af44f456c564666afd4f4e766ef9040ff48e6db
3
+ metadata.gz: 86174e66ca792b05a9f36bff9b881c65c3fdaaeb360e8a4fb49e94014d984839
4
+ data.tar.gz: ebe347a97de89a5af6697087252156b044a26f5c8eae11c3e2129c4594a6cb46
5
5
  SHA512:
6
- metadata.gz: a035631e203fdefda661eda488dd7384b4690e8dd490b430d35ed73d421e49a11927a7282ee489e197a16975a0874e8d95ec0337b347ef5b141c30c570f69301
7
- data.tar.gz: 36e967ff4467ee46f261489cfc770ac09e3e0d2a092dc8faa6e6186585fd8b4df3cc9f3abc7db5cd2607befd3603715f835da647c1aa5213eebe63ab920fcfec
6
+ metadata.gz: 73dc2f50e0d720cd4048b23db241a17ea81cec2010bb06ae0f6a42a4edbb4d26f2b074be9e3a71ac4e24b9d09fa31651365727aefd88346e416284de4a4a6424
7
+ data.tar.gz: ae13c32ba3db5b1bb1e07bfd3ae63cc7d977215a834e1b4ce42b3298a3e6e790240b5a6dc251c41561489238cdbfdbab816ef22f221dc7ab3886db7e3f837669
@@ -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
@@ -105,6 +105,88 @@ module PostProxy
105
105
  Post.new(**result)
106
106
  end
107
107
 
108
+ def update(id, body: nil, profiles: nil, media: nil, media_files: nil, platforms: nil,
109
+ thread: nil, scheduled_at: nil, draft: nil, queue_id: nil,
110
+ queue_priority: nil, profile_group_id: nil)
111
+ has_files = media_files && !media_files.empty?
112
+ has_thread_files = thread&.any? { |t| t[:media_files]&.any? }
113
+
114
+ if has_files || has_thread_files
115
+ form_data = {}
116
+ form_data["post[body]"] = body if body
117
+ form_data["post[scheduled_at]"] = format_time(scheduled_at) if scheduled_at
118
+ form_data["post[draft]"] = draft.to_s if !draft.nil?
119
+
120
+ files = []
121
+
122
+ profiles&.each do |p|
123
+ files << ["profiles[]", nil, p, "text/plain"]
124
+ end
125
+
126
+ media&.each do |m|
127
+ files << ["media[]", nil, m, "text/plain"]
128
+ end
129
+
130
+ if platforms
131
+ params_hash = platforms.is_a?(PlatformParams) ? platforms.to_h : platforms
132
+ params_hash.each do |platform, platform_params|
133
+ platform_params.each do |key, value|
134
+ files << ["platforms[#{platform}][#{key}]", nil, value.to_s, "text/plain"]
135
+ end
136
+ end
137
+ end
138
+
139
+ media_files&.each do |path|
140
+ path = path.to_s
141
+ filename = File.basename(path)
142
+ content_type = mime_type_for(filename)
143
+ io = File.open(path, "rb")
144
+ files << ["media[]", filename, io, content_type]
145
+ end
146
+
147
+ thread&.each_with_index do |t, i|
148
+ form_data["thread[#{i}][body]"] = t[:body] if t[:body]
149
+
150
+ t[:media]&.each do |m|
151
+ files << ["thread[#{i}][media][]", nil, m, "text/plain"]
152
+ end
153
+
154
+ t[:media_files]&.each do |path|
155
+ path = path.to_s
156
+ filename = File.basename(path)
157
+ content_type = mime_type_for(filename)
158
+ io = File.open(path, "rb")
159
+ files << ["thread[#{i}][media][]", filename, io, content_type]
160
+ end
161
+ end
162
+
163
+ result = @client.request(:patch, "/posts/#{id}",
164
+ data: form_data,
165
+ files: files,
166
+ profile_group_id: profile_group_id
167
+ )
168
+ else
169
+ json_body = {}
170
+
171
+ post_payload = {}
172
+ post_payload[:body] = body if body
173
+ post_payload[:scheduled_at] = format_time(scheduled_at) if scheduled_at
174
+ post_payload[:draft] = draft unless draft.nil?
175
+ json_body[:post] = post_payload unless post_payload.empty?
176
+
177
+ json_body[:profiles] = profiles if profiles
178
+ json_body[:platforms] = platforms.is_a?(PlatformParams) ? platforms.to_h : platforms if platforms
179
+ json_body[:media] = media if media
180
+ json_body[:thread] = thread if thread
181
+ json_body[:queue_id] = queue_id if queue_id
182
+ json_body[:queue_priority] = queue_priority if queue_priority
183
+
184
+ result = @client.request(:patch, "/posts/#{id}", json: json_body, profile_group_id: profile_group_id)
185
+ end
186
+
187
+ Post.new(**result)
188
+ end
189
+
108
190
  def publish_draft(id, profile_group_id: nil)
109
191
  result = @client.request(:post, "/posts/#{id}/publish", profile_group_id: profile_group_id)
110
192
  Post.new(**result)
@@ -291,7 +291,7 @@ module PostProxy
291
291
  # Platform-specific parameter structs
292
292
 
293
293
  class FacebookParams < Model
294
- attr_accessor :format, :first_comment, :page_id
294
+ attr_accessor :format, :title, :first_comment, :page_id
295
295
  end
296
296
 
297
297
  class InstagramParams < Model
@@ -1,3 +1,3 @@
1
1
  module PostProxy
2
- VERSION = "1.4.0"
2
+ VERSION = "1.5.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.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - PostProxy