-
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.
feat: Private api endpoints for funder
- Loading branch information
1 parent
97e7660
commit e57da54
Showing
17 changed files
with
571 additions
and
67 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module API | ||
module V1 | ||
module Members | ||
class BaseController < API::V1::BaseController | ||
before_action :authenticate! | ||
end | ||
end | ||
end | ||
end |
77 changes: 77 additions & 0 deletions
77
backend/app/controllers/api/v1/members/funders_controller.rb
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,77 @@ | ||
module API | ||
module V1 | ||
module Members | ||
class FundersController < BaseController | ||
skip_before_action :require_json!, only: %i[update] | ||
|
||
load_and_authorize_resource | ||
|
||
def show | ||
render json: FunderSerializer.new( | ||
current_member.funder, | ||
include: included_relationships, | ||
fields: sparse_fieldset, | ||
params: {current_member: current_member, current_ability: current_ability} | ||
).serializable_hash | ||
end | ||
|
||
def update | ||
if current_member.funder.update(funder_params) | ||
render json: FunderSerializer.new( | ||
current_member.funder, | ||
include: included_relationships, | ||
fields: sparse_fieldset, | ||
params: {current_member: current_member, current_ability: current_ability} | ||
).serializable_hash | ||
else | ||
raise API::UnprocessableEntityError, current_member.funder.errors.full_messages.to_sentence | ||
end | ||
end | ||
|
||
private | ||
|
||
def funder_params | ||
p = params.fetch(:funder_params, {}).permit( | ||
:name, | ||
:description, | ||
:logo, | ||
:primary_office_address, | ||
:primary_office_city, | ||
:primary_office_state_id, | ||
:primary_office_country_id, | ||
:primary_contact_first_name, | ||
:primary_contact_last_name, | ||
:primary_contact_email, | ||
:show_primary_email, | ||
:primary_contact_phone, | ||
:primary_contact_location, | ||
:primary_contact_role, | ||
:secondary_email_which_can_be_shared, | ||
:website, | ||
:date_joined_fora, | ||
:funder_type, | ||
:funder_type_other, | ||
:capital_acceptances_other, | ||
:leadership_demographics_other, | ||
:number_staff_employees, | ||
:application_status, | ||
:funder_legal_status, | ||
:funder_legal_status_other, | ||
:new_to_regenerative_ag, | ||
:networks, | ||
:capital_types_other, | ||
:spend_down_strategy, | ||
:areas_other, | ||
:demographics_other, | ||
capital_acceptances: [], | ||
leadership_demographics: [], | ||
capital_types: [], | ||
areas: [], | ||
demographics: [] | ||
) | ||
p.merge published: true | ||
end | ||
end | ||
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
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,22 +1,22 @@ | ||
{ | ||
"data": { | ||
"id": "284482a5-7e3b-4c85-a339-306b5b635297", | ||
"id": "f5f720f9-2896-4583-b63a-d61bb98e5e96", | ||
"type": "member", | ||
"attributes": { | ||
"first_name": "Dawna" | ||
}, | ||
"relationships": { | ||
"funder": { | ||
"data": { | ||
"id": "42bafc40-e1d1-4547-b5f0-fc084c314e3b", | ||
"id": "8ff19280-2af6-4a2c-be00-ba5fbea69263", | ||
"type": "funder" | ||
} | ||
} | ||
} | ||
}, | ||
"included": [ | ||
{ | ||
"id": "42bafc40-e1d1-4547-b5f0-fc084c314e3b", | ||
"id": "8ff19280-2af6-4a2c-be00-ba5fbea69263", | ||
"type": "funder", | ||
"attributes": { | ||
"name": "Otha Kemmer", | ||
|
@@ -58,21 +58,21 @@ | |
"demographics_other": "Enim repellat pariatur est.", | ||
"contact_email": "[email protected]", | ||
"logo": { | ||
"small": "http://localhost:4000/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaEpJaWt4TVRrMFl6TmlaQzB6Wmpjd0xUUTRPREV0WWpJM1pDMWtNV00yTW1JME1qTmpaak1HT2daRlZBPT0iLCJleHAiOm51bGwsInB1ciI6ImJsb2JfaWQifX0=--e07e810222ab916c357c81f15aaadfd91d37f4a3/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdCem9MWm05eWJXRjBTU0lJYW5CbkJqb0dSVlE2QzNKbGMybDZaVWtpRERJd01IZ3lNREFHT3daVSIsImV4cCI6bnVsbCwicHVyIjoidmFyaWF0aW9uIn19--8673702c2d856505736727890dcac6a632977811/picture.jpg", | ||
"medium": "http://localhost:4000/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaEpJaWt4TVRrMFl6TmlaQzB6Wmpjd0xUUTRPREV0WWpJM1pDMWtNV00yTW1JME1qTmpaak1HT2daRlZBPT0iLCJleHAiOm51bGwsInB1ciI6ImJsb2JfaWQifX0=--e07e810222ab916c357c81f15aaadfd91d37f4a3/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdCem9MWm05eWJXRjBTU0lJYW5CbkJqb0dSVlE2QzNKbGMybDZaVWtpRERnd01IZzRNREFHT3daVSIsImV4cCI6bnVsbCwicHVyIjoidmFyaWF0aW9uIn19--e82a96c0eabd93d914de4ef37febd98c36e0e275/picture.jpg", | ||
"original": "http://localhost:4000/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaEpJaWt4TVRrMFl6TmlaQzB6Wmpjd0xUUTRPREV0WWpJM1pDMWtNV00yTW1JME1qTmpaak1HT2daRlZBPT0iLCJleHAiOm51bGwsInB1ciI6ImJsb2JfaWQifX0=--e07e810222ab916c357c81f15aaadfd91d37f4a3/picture.jpg" | ||
"small": "http://localhost:4000/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaEpJaWxrWTJNMVpUZzFOaTFtTm1NNExUUTROMlV0T1RrNU5TMWtaVEl4WkdKaE0ySTJPV0VHT2daRlZBPT0iLCJleHAiOm51bGwsInB1ciI6ImJsb2JfaWQifX0=--6ebae4c6f2260e3a7353702f52289ee02cc113ad/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdCem9MWm05eWJXRjBTU0lJYW5CbkJqb0dSVlE2QzNKbGMybDZaVWtpRERJd01IZ3lNREFHT3daVSIsImV4cCI6bnVsbCwicHVyIjoidmFyaWF0aW9uIn19--8673702c2d856505736727890dcac6a632977811/picture.jpg", | ||
"medium": "http://localhost:4000/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaEpJaWxrWTJNMVpUZzFOaTFtTm1NNExUUTROMlV0T1RrNU5TMWtaVEl4WkdKaE0ySTJPV0VHT2daRlZBPT0iLCJleHAiOm51bGwsInB1ciI6ImJsb2JfaWQifX0=--6ebae4c6f2260e3a7353702f52289ee02cc113ad/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdCem9MWm05eWJXRjBTU0lJYW5CbkJqb0dSVlE2QzNKbGMybDZaVWtpRERnd01IZzRNREFHT3daVSIsImV4cCI6bnVsbCwicHVyIjoidmFyaWF0aW9uIn19--e82a96c0eabd93d914de4ef37febd98c36e0e275/picture.jpg", | ||
"original": "http://localhost:4000/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaEpJaWxrWTJNMVpUZzFOaTFtTm1NNExUUTROMlV0T1RrNU5TMWtaVEl4WkdKaE0ySTJPV0VHT2daRlZBPT0iLCJleHAiOm51bGwsInB1ciI6ImJsb2JfaWQifX0=--6ebae4c6f2260e3a7353702f52289ee02cc113ad/picture.jpg" | ||
} | ||
}, | ||
"relationships": { | ||
"primary_office_state": { | ||
"data": { | ||
"id": "5e0a16f2-669d-4edd-802b-727294069bee", | ||
"id": "8382f3a9-e384-4716-8675-a428592c41f8", | ||
"type": "subgeographic" | ||
} | ||
}, | ||
"primary_office_country": { | ||
"data": { | ||
"id": "c9d602e6-c5c8-4488-b834-5acc1d5300f3", | ||
"id": "7c156964-9f67-4333-8160-3b9728840bd5", | ||
"type": "subgeographic" | ||
} | ||
}, | ||
|
2 changes: 1 addition & 1 deletion
2
...api/v1/get-member-me-sparse-fieldset.json → ...ts/api/v1/get-member-sparse-fieldset.json
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
10 changes: 5 additions & 5 deletions
10
...tures/snapshots/api/v1/get-member-me.json → ...fixtures/snapshots/api/v1/get-member.json
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,19 +1,19 @@ | ||
{ | ||
"data": { | ||
"id": "242e574b-ea06-4a1d-b925-b77147214bd9", | ||
"id": "40e66665-d429-44db-b1b7-e59bedd968fd", | ||
"type": "member", | ||
"attributes": { | ||
"id": "242e574b-ea06-4a1d-b925-b77147214bd9", | ||
"id": "40e66665-d429-44db-b1b7-e59bedd968fd", | ||
"email": "[email protected]", | ||
"first_name": "Dawna", | ||
"last_name": "Block", | ||
"created_at": "2024-12-31T11:21:25.233Z", | ||
"updated_at": "2024-12-31T11:21:25.233Z" | ||
"created_at": "2024-12-31T12:30:07.642Z", | ||
"updated_at": "2024-12-31T12:30:07.642Z" | ||
}, | ||
"relationships": { | ||
"funder": { | ||
"data": { | ||
"id": "44a070ab-5bf7-476a-b552-e8868bb23c7a", | ||
"id": "48b5de22-d450-4e58-985c-aba167f82920", | ||
"type": "funder" | ||
} | ||
} | ||
|
41 changes: 41 additions & 0 deletions
41
backend/spec/fixtures/snapshots/api/v1/members/get-funder-include-relationships.json
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,41 @@ | ||
{ | ||
"data": { | ||
"id": "fa9efb5e-e30a-4e41-b877-9d8d6884e088", | ||
"type": "funder", | ||
"attributes": { | ||
"name": "Otha Kemmer" | ||
}, | ||
"relationships": { | ||
"primary_office_country": { | ||
"data": { | ||
"id": "6f0bcd78-a484-451b-87a1-531cd7aed386", | ||
"type": "subgeographic" | ||
} | ||
} | ||
} | ||
}, | ||
"included": [ | ||
{ | ||
"id": "6f0bcd78-a484-451b-87a1-531cd7aed386", | ||
"type": "subgeographic", | ||
"attributes": { | ||
"name": "Papua New Guinea", | ||
"code": "NPL", | ||
"geographic": "countries", | ||
"abbreviation": "C-NPL", | ||
"created_at": "2024-12-31T11:53:23.489Z", | ||
"updated_at": "2024-12-31T11:53:23.489Z" | ||
}, | ||
"relationships": { | ||
"parent": { | ||
"data": null | ||
}, | ||
"subgeographics": { | ||
"data": [ | ||
|
||
] | ||
} | ||
} | ||
} | ||
] | ||
} |
12 changes: 12 additions & 0 deletions
12
backend/spec/fixtures/snapshots/api/v1/members/get-funder-sparse-fieldset.json
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,12 @@ | ||
{ | ||
"data": { | ||
"id": "01448ed1-3dae-43d4-a6ed-625f69ab7f78", | ||
"type": "funder", | ||
"attributes": { | ||
"name": "Otha Kemmer", | ||
"description": "Enim repellat pariatur. Earum modi eos. Libero tempora exercitationem. Qui dolorem quo." | ||
}, | ||
"relationships": { | ||
} | ||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
backend/spec/fixtures/snapshots/api/v1/members/get-funder.json
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,80 @@ | ||
{ | ||
"data": { | ||
"id": "a76e97ea-5a98-4d8f-adb5-d62b47d8a2a8", | ||
"type": "funder", | ||
"attributes": { | ||
"name": "Otha Kemmer", | ||
"description": "Enim repellat pariatur. Earum modi eos. Libero tempora exercitationem. Qui dolorem quo.", | ||
"primary_office_city": "South Moises", | ||
"website": "http://kutch-spencer.com/moises", | ||
"date_joined_fora": "2021-11-27T00:00:00.000Z", | ||
"funder_type": "funder_collaborative_or_network", | ||
"funder_type_other": "Enim repellat pariatur est.", | ||
"capital_acceptances": [ | ||
"other", | ||
"investments_accepted" | ||
], | ||
"capital_acceptances_other": "Enim repellat pariatur est.", | ||
"leadership_demographics": [ | ||
"hispanic_or_latinx", | ||
"other" | ||
], | ||
"leadership_demographics_other": "Enim repellat pariatur est.", | ||
"application_status": "invitation_only", | ||
"funder_legal_status": "other", | ||
"funder_legal_status_other": "Enim repellat pariatur est.", | ||
"networks": "Enim repellat pariatur. Earum modi eos. Libero tempora exercitationem. Qui dolorem quo.", | ||
"capital_types": [ | ||
"re_grants", | ||
"pris" | ||
], | ||
"capital_types_other": "Enim repellat pariatur est.", | ||
"spend_down_strategy": true, | ||
"areas": [ | ||
"land_asset_financing", | ||
"capacity_building" | ||
], | ||
"areas_other": "Enim repellat pariatur est.", | ||
"demographics": [ | ||
"hispanic_or_latinx", | ||
"other" | ||
], | ||
"demographics_other": "Enim repellat pariatur est.", | ||
"contact_email": "[email protected]", | ||
"logo": { | ||
"small": "http://localhost:4000/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaEpJaWt6WlRjd09EQmlaQzB3TW1SbExUUmhPRFV0WVRSaVlpMHlOV05tTlRZM09UTXpZaklHT2daRlZBPT0iLCJleHAiOm51bGwsInB1ciI6ImJsb2JfaWQifX0=--0a6421a4d48a2cb819c50eaabc7173b3b13eb6ed/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdCem9MWm05eWJXRjBTU0lJYW5CbkJqb0dSVlE2QzNKbGMybDZaVWtpRERJd01IZ3lNREFHT3daVSIsImV4cCI6bnVsbCwicHVyIjoidmFyaWF0aW9uIn19--8673702c2d856505736727890dcac6a632977811/picture.jpg", | ||
"medium": "http://localhost:4000/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaEpJaWt6WlRjd09EQmlaQzB3TW1SbExUUmhPRFV0WVRSaVlpMHlOV05tTlRZM09UTXpZaklHT2daRlZBPT0iLCJleHAiOm51bGwsInB1ciI6ImJsb2JfaWQifX0=--0a6421a4d48a2cb819c50eaabc7173b3b13eb6ed/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdCem9MWm05eWJXRjBTU0lJYW5CbkJqb0dSVlE2QzNKbGMybDZaVWtpRERnd01IZzRNREFHT3daVSIsImV4cCI6bnVsbCwicHVyIjoidmFyaWF0aW9uIn19--e82a96c0eabd93d914de4ef37febd98c36e0e275/picture.jpg", | ||
"original": "http://localhost:4000/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaEpJaWt6WlRjd09EQmlaQzB3TW1SbExUUmhPRFV0WVRSaVlpMHlOV05tTlRZM09UTXpZaklHT2daRlZBPT0iLCJleHAiOm51bGwsInB1ciI6ImJsb2JfaWQifX0=--0a6421a4d48a2cb819c50eaabc7173b3b13eb6ed/picture.jpg" | ||
} | ||
}, | ||
"relationships": { | ||
"primary_office_state": { | ||
"data": { | ||
"id": "82ecb6e8-d4e1-4b38-b0a3-93218f43de66", | ||
"type": "subgeographic" | ||
} | ||
}, | ||
"primary_office_country": { | ||
"data": { | ||
"id": "76a7f382-aab9-429b-a553-168b8f2aa83b", | ||
"type": "subgeographic" | ||
} | ||
}, | ||
"subgeographics": { | ||
"data": [ | ||
|
||
] | ||
}, | ||
"subgeographic_ancestors": { | ||
"data": [ | ||
|
||
] | ||
}, | ||
"projects": { | ||
"data": [ | ||
|
||
] | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.