Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Epic: Database Operations (Post ORM Backend Implementation) #31

Closed
7 of 18 tasks
manishapriya94 opened this issue Jun 24, 2021 · 16 comments
Closed
7 of 18 tasks

Epic: Database Operations (Post ORM Backend Implementation) #31

manishapriya94 opened this issue Jun 24, 2021 · 16 comments
Assignees
Labels

Comments

@manishapriya94
Copy link
Contributor

manishapriya94 commented Jun 24, 2021

This epic for earth day 4/21 has moved here

User Story:

  • User has authenticated
  • Has added their name into the signature box
  • Has added their address into the address box
  • User moves to next step (new window triggered) payment added
  • Successful payment triggers 'send message' button
  • Send message button creates a letter to send to the representative
    • Send message triggers a POST to back-end to make a call to LOB API
    • Successful 'send message' should also trigger a POST to back-end to save record into the DB

Development Task

Send User Letter to Lob

Save User Letter Data

  • Create Table in PostgresDB via KNEX migration
  • Seed User Letter Data
  • Create new endpoint /api/userletter endpoint
  • Add app.js route information for /api/userletter endpoint
  • Create GET function /api/userletter
  • Configure to return all user letters that have been created
  • Create POST function: user_addressbook  amplify-back-end#124
  • Configure endpoint to accept JSON Objects with Letter information
  • Use Knex ORM to build insert query
  • Send 200 status code upon successful call to Front End
  • Add Documentation to Wiki Endpoint
  • Sample implementation in documentation
@manishapriya94
Copy link
Contributor Author

manishapriya94 commented Jun 24, 2021

@BeeXiong: Can we bring over the whole record from campaigns when it comes to the template_id for GET? (In the way we did for reps, we can bring over array of campaigns)

@mahrsbar thoughts?

@manishapriya94
Copy link
Contributor Author

FrontEnd:

  • sending user info for sender info
  • sending recipient address of representative

@BeeXiong
Copy link
Contributor

@BeeXiong: Can we bring over the whole record from campaigns when it comes to the template_id for GET? (In the way we did for reps, we can bring over array of campaigns)

@mahrsbar thoughts?

I will add a campaigns endpoint that will retrieve all campaigns in an array.

With that said...

The Amplify Endpoint also retrieve's an array of campaigns.

  • To avoid having to update multiple functions if something were to change with the campaigns table, I'll be removing the /api/amplify endpoint.
  • We should now use /api/campaigns endpoint --> wiki

@BeeXiong
Copy link
Contributor

This is the page that needs to be updated with the new URL

@mahrsbar
Copy link
Contributor

mahrsbar commented Jun 26, 2021

The current amplify endpoint already retrieves all the campaigns which is what I used. There's only three so yeah. But I will update it to api/campaigns. Actually, I don't know if we need to change it? I cleared it up with Manisha.

@BeeXiong
Copy link
Contributor

BeeXiong commented Jun 26, 2021

So this is where I see the back end coming into play and where we need to add endpoints...

  • User has authenticated
  • Has added their name into the signature box
  • Has added their address into the address box
  • User moves to next step (new window triggered) payment added
  • Successful payment triggers 'send message' button
  • Send message button creates a letter to send to the representative
    • Send message triggers a POST to back-end to make a call to LOB API
    • Successful 'send message' should also trigger a POST to back-end to save record into the DB

@mahrsbar
Copy link
Contributor

I would update to include "Has added their address" which would also be sent to LOB API, before the following point:

Has added their name into the signature box

The design has been updated as such. The postal code will still be used for search but we need the full address of the user to send to LOB.
Screen Shot 2021-06-26 at 2 31 55 PM

@BeeXiong
Copy link
Contributor

Update @manishapriya94's original post with Dev Task.

One item to point out ⬇️

  • Should we trigger the saving of data within our DB in the backend or frontend?

Having the back end automatically save data just saves the front end another call / resending that user letter information in JSON form

@mahrsbar
Copy link
Contributor

mahrsbar commented Jul 2, 2021

  • To avoid having to update multiple functions if something were to change with the campaigns table, I'll be removing the /api/amplify endpoint.
  • We should now use /api/campaigns endpoint --> wiki

@BeeXiong the search still requires api/amplify{zipcode}, this needs to be changed to api/campaigns{zipcode}. Are you able to clean up the wiki and remove the amplify table as well? I assume we're just sticking with api/campaigns for everything.

@BeeXiong
Copy link
Contributor

I think we can keep the api/amplify/{zipcode} endpoint because it actually exposes the Google Civic API. There's nothing coming from the Database.

I can switch it to api/campaigns/{zipcode} if it's easier. Just thought we create that separation between the stuff coming from the DB and stuff coming from other api's.

@mahrsbar
Copy link
Contributor

I think it's a bit confusing because api/amplify no longer exists so api/amplify/{zipcode} loses context. The term amplify isn't very intuitive as related to zip codes but open to changing it to something else so you don't lose the differentiation.

@BeeXiong
Copy link
Contributor

Would api/representative/{zipcode} make sense?

@mahrsbar
Copy link
Contributor

Yess, that works great.

@manishapriya94
Copy link
Contributor Author

Hey @BeeXiong, @nawazkhan just added some changes to the way the API was routed OpenSourceFellows/amplify-back-end#114 and then added the post function OpenSourceFellows/amplify-back-end#115

@manishapriya94
Copy link
Contributor Author

Notes from meeting 11/4
By next week we want to do the following

@manishapriya94

  • update lob documentation in wiki

@BeeXiong:
In lob.js lines 135:

  • for the user address that makes up from: create address which combines address verification and returns an address_id string
  • frontend uses this string to create a lob post request in line 18

@mahrsbar:

  • For to, format representative data from google civic api by lob address object attributes:

Lob:
Screen Shot 2021-11-04 at 6 10 05 PM

Google Civic API:
Screen Shot 2021-11-04 at 6 09 06 PM

@nawazkhan:

  • In file, check if successful payment by stripe and then route to lob post on line 20 in lob.js

@manishapriya94 manishapriya94 changed the title Send letter Save Letter Data (Post ORM Backend Implementation) Dec 22, 2021
@manishapriya94 manishapriya94 added good first issue Good for newcomers batch and removed good first issue Good for newcomers labels Feb 8, 2022
@waldnzwrld waldnzwrld transferred this issue from OpenSourceFellows/amplify-back-end Feb 11, 2022
@manishapriya94 manishapriya94 changed the title Save Letter Data (Post ORM Backend Implementation) Epic: Database Operations (Post ORM Backend Implementation) Mar 25, 2022
@manishapriya94
Copy link
Contributor Author

Resolved by create_letter function in lob.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: No status
Development

No branches or pull requests

4 participants