-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #101 from co-cddo/add-agreements-api
Add agreements API
- Loading branch information
Showing
16 changed files
with
146 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
object false | ||
child(@agreements => :agreements) do |_agreement| | ||
node(:data) do |agreement| | ||
{ | ||
id: agreement.record_id, | ||
name: agreement.name, | ||
} | ||
end | ||
node(:link) do |agreement| | ||
Rails.application.routes.url_helpers.agreement_url(agreement, format: :json) | ||
end | ||
end | ||
node(:links) do | ||
hash = { | ||
page_size: @pagy.items, | ||
current_page: @pagy.page, | ||
} | ||
hash[:next] = Rails.application.routes.url_helpers.agreements_url(page: @pagy.next, format: :json) if @pagy.next | ||
hash[:previous] = Rails.application.routes.url_helpers.agreements_url(page: @pagy.prev, format: :json) if @pagy.prev | ||
hash | ||
end | ||
|
||
# collection @agreements => :agreements | ||
# node(:data) do |agreement| | ||
# { name: agreement.name } | ||
# end | ||
# node(:link) do |agreement| | ||
# Rails.application.routes.url_helpers.agreement_url(agreement, format: :json) | ||
# end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
object @agreement | ||
node(:data) do |agreement| | ||
agreement.fields.except("agreement_name") | ||
end | ||
node(:links) do | ||
{ index: Rails.application.routes.url_helpers.agreements_url(format: :json) } | ||
end | ||
child control_people: :controllers do | ||
node(:data) do |control_person| | ||
{ name: control_person.name } | ||
end | ||
end | ||
child powers: :powers do | ||
node(:data) do |power| | ||
{ name: power.name } | ||
end | ||
end | ||
child processors: :processors do | ||
node(:data) do |processor| | ||
{ name: processor.name } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
FactoryBot.define do | ||
factory :agreement do | ||
name { Faker::Name.name } | ||
record_id { rand(1..100) } | ||
sequence :fields do |n| | ||
{ name:, id: n } | ||
sequence :record_id | ||
fields do | ||
{ name:, id: record_id } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters