Skip to content

Commit 159c1ae

Browse files
committed
use new sync API endpoints for job/task wait()
1 parent 4993cc3 commit 159c1ae

10 files changed

Lines changed: 25 additions & 18 deletions

File tree

lib/cloudconvert.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,7 @@
3434
module CloudConvert
3535
API_URL = "https://api.cloudconvert.com".freeze
3636
SANDBOX_URL = "https://api.sandbox.cloudconvert.com".freeze
37+
API_SYNC_URL = "https://sync.api.cloudconvert.com".freeze
38+
SANDBOX_SYNC_URL = "https://sync.api.sandbox.cloudconvert.com".freeze
3739
USER_AGENT = "CloudConvertRubyGem/#{CloudConvert::VERSION}".freeze
3840
end

lib/cloudconvert/client.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,18 @@ def download(url, *args, **options)
7575
Down.download(url, *args, **options)
7676
end
7777

78-
private
79-
8078
# @return [String]
8179
def api_host
8280
@api_host ||= sandbox ? SANDBOX_URL : API_URL
8381
end
8482

83+
# @return [String]
84+
def api_sync_host
85+
@api_sync_host ||= sandbox ? SANDBOX_SYNC_URL : API_SYNC_URL
86+
end
87+
88+
private
89+
8590
# @return [Faraday::Client]
8691
def connection
8792
@connection ||= Faraday.new(url: api_host, headers: headers) do |f|

lib/cloudconvert/resources/jobs.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def create(params)
4141
# @param id [String]
4242
# @return [Job]
4343
def wait(id)
44-
Job.result(client.get("/v2/jobs/#{id}/wait", {}))
44+
Job.result(client.get(client.api_sync_host + "/v2/jobs/#{id}", {}))
4545
end
4646

4747
# @param id [String]

lib/cloudconvert/resources/tasks.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def retry(id)
5151
# @param id [String]
5252
# @return [Task]
5353
def wait(id)
54-
Task.result(client.get("/v2/tasks/#{id}/wait"))
54+
Task.result(client.get(client.api_sync_host + "/v2/tasks/#{id}"))
5555
end
5656

5757
# @param file [File, String, IO] Either a String filename to a local file or an open IO object.

spec/integration/vcr/CloudConvert_Resources_Jobs/performs_upload_and_download_of_file.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ http_interactions:
4545
recorded_at: Thu, 17 Dec 2020 04:36:09 GMT
4646
- request:
4747
method: get
48-
uri: https://api.sandbox.cloudconvert.com/v2/tasks/52977752-7cfd-43d1-8800-3ae55d7cbc97/wait
48+
uri: https://sync.api.sandbox.cloudconvert.com/v2/tasks/52977752-7cfd-43d1-8800-3ae55d7cbc97
4949
body:
5050
encoding: US-ASCII
5151
string: ''
@@ -218,7 +218,7 @@ http_interactions:
218218
recorded_at: Thu, 17 Dec 2020 05:07:34 GMT
219219
- request:
220220
method: get
221-
uri: https://api.sandbox.cloudconvert.com/v2/tasks/e219a38a-4431-4787-bb68-25d17809422b/wait
221+
uri: https://sync.api.sandbox.cloudconvert.com/v2/tasks/e219a38a-4431-4787-bb68-25d17809422b
222222
body:
223223
encoding: US-ASCII
224224
string: ''
@@ -489,7 +489,7 @@ http_interactions:
489489
recorded_at: Thu, 17 Dec 2020 05:33:58 GMT
490490
- request:
491491
method: get
492-
uri: https://api.sandbox.cloudconvert.com/v2/tasks/304f5007-baae-4013-8d79-5d005413349b/wait
492+
uri: https://sync.api.sandbox.cloudconvert.com/v2/tasks/304f5007-baae-4013-8d79-5d005413349b
493493
body:
494494
encoding: US-ASCII
495495
string: ''

spec/integration/vcr/CloudConvert_Resources_Tasks/performs_import_upload_task.yml

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/integration/vcr/CloudConvert_Resources_Tasks/performs_import_url_task.yml

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/resources/jobs_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@
170170

171171
describe "#wait" do
172172
before do
173-
stub_get("/v2/jobs/cd82535b-0614-4b23-bbba-b24ab0e892f7/wait").to_return({
173+
stub_get(CloudConvert::API_SYNC_URL + "/v2/jobs/cd82535b-0614-4b23-bbba-b24ab0e892f7").to_return({
174174
body: fixture("responses/job.json"),
175175
headers: { content_type: "application/json" },
176176
})
@@ -181,7 +181,7 @@
181181
end
182182

183183
it "requests the correct resource" do
184-
expect(a_get("/v2/jobs/cd82535b-0614-4b23-bbba-b24ab0e892f7/wait")).to have_been_made
184+
expect(stub_request(:get, CloudConvert::API_SYNC_URL + "/v2/jobs/cd82535b-0614-4b23-bbba-b24ab0e892f7")).to have_been_made
185185
end
186186

187187
it "returns the job" do

spec/resources/tasks_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@
240240

241241
describe "#wait" do
242242
before do
243-
stub_get("/v2/tasks/4c80f1ae-5b3a-43d5-bb58-1a5c4eb4e46b/wait").to_return({
243+
stub_get(CloudConvert::API_SYNC_URL + "/v2/tasks/4c80f1ae-5b3a-43d5-bb58-1a5c4eb4e46b").to_return({
244244
body: fixture("responses/task.json"),
245245
headers: { content_type: "application/json" },
246246
})
@@ -251,7 +251,7 @@
251251
end
252252

253253
it "requests the correct resource" do
254-
expect(a_get("/v2/tasks/4c80f1ae-5b3a-43d5-bb58-1a5c4eb4e46b/wait")).to have_been_made
254+
expect(stub_request(:get, CloudConvert::API_SYNC_URL + "/v2/tasks/4c80f1ae-5b3a-43d5-bb58-1a5c4eb4e46b")).to have_been_made
255255
end
256256

257257
it "returns the task" do

spec/webhook/processor_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def webhook_secret(event)
8080
let(:controller) { ControllerWithoutMethod.new(request) }
8181

8282
it "raises an error" do
83-
expect { controller.create }.to raise_error(NoMethodError, "ControllerWithoutMethod#job_finished not implemented")
83+
expect { controller.create }.to raise_error(NoMethodError)
8484
end
8585
end
8686

0 commit comments

Comments
 (0)