Skip to content

Commit f62ca39

Browse files
committed
Refactor Api::V1::FormResource #make_live! and #archive!
Change form resource make_live! and archive! methods to update the form object in-place with the response from the API.
1 parent af2661b commit f62ca39

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

app/resources/api/v1/form_resource.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ def all_task_statuses
6161
end
6262

6363
def make_live!
64-
post "make-live"
64+
load_attributes_from_response(post("make-live"))
6565
end
6666

6767
def archive!
68-
post "archive"
68+
load_attributes_from_response(post("archive"))
6969
end
7070

7171
def form_submission_email

app/services/form_repository.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ def make_live!(record)
3838
form = Api::V1::FormResource.new(record.attributes, true)
3939
save_to_database!(form)
4040
save_pages_to_database!(form, form.pages) if Form.find(record.id).pages.empty?
41-
response = form.make_live!
42-
form.from_json(response.body)
41+
42+
form.make_live!
43+
4344
Form.find(record.id).make_live!
4445

4546
form
@@ -49,8 +50,9 @@ def archive!(record)
4950
form = Api::V1::FormResource.new(record.attributes, true)
5051

5152
save_to_database!(form)
52-
response = form.archive!
53-
form.from_json(response.body)
53+
54+
form.archive!
55+
5456
Form.find(record.id).archive_live_form!
5557

5658
form

0 commit comments

Comments
 (0)