OpenSourceFellows / amplify-back-end

The API backend for ProgramEquity
https://www.programequity.com/
MIT License
11 stars 0 forks source link

Create a lob letter object via template_id #59

Closed manishapriya94 closed 3 years ago

manishapriya94 commented 3 years ago

User campaign id to send frontend information on which template_id to display

Screen Shot 2021-05-22 at 6 52 09 PM

Implementation

  1. In campaign.js use campaigns API to match template_id to campaign id
  2. Frontend will use a GET function when representative is selected Screen Shot 2021-05-22 at 6 50 22 PM
BeeXiong commented 3 years ago

@manishapriya94 The code seems to be completed and functional with the TestLob secret. However the LiveLob secret looks to be still throwing a 401 error which means it's not authenticating correctly.

Can you double check to make sure the Environment variables within Heroku are up to date and accurate?

manishapriya94 commented 3 years ago

Let me slack what I'm seeing in #devs

mahrsbar commented 3 years ago

the API call in Lob EndPoints is not working.

This is the response i get if I try with a template_id:

Screen Shot 2021-06-29 at 6 45 03 PM

Any idea why @BeeXiong

BeeXiong commented 3 years ago

Updated code to remove try catch issue that @hamdaankhalid identified.

Screen Shot 2021-06-29 at 9 37 07 PM

The time out issue should be address but we are now returning a status 404 (Not Found). Local development seems to work 👇

Screen Shot 2021-06-29 at 10 02 28 PM

Current error from heroku logs:

Screen Shot 2021-06-29 at 10 07 05 PM

@manishapriya94 - Can you check lob to see if these templates exist within Lob? I don't have access I think.

manishapriya94 commented 3 years ago

This is what it is for live:

Screen Shot 2021-06-29 at 9 19 02 PM

This is what it is for test:

Screen Shot 2021-06-29 at 9 18 06 PM

Seems like the second templ one was deleted though …

BeeXiong commented 3 years ago

Okay. So the endpoint should be working and does bring back data from Lob.

Our problem is that we have a disconnect with the data in the DB compared to what is actually in Lob + Lob has different templates for each environment. I assumed templates would work for both but apparently not.

Here's what our DB has...

Screen Shot 2021-06-29 at 10 37 56 PM

@manishapriya94 - Can you give us a list of what is in Lob.

mahrsbar commented 3 years ago

That's interesting. I'm curious what test and live mean in this case? Do we need both?

Also, I tried both calls.

The test version resulted in:

Screen Shot 2021-06-29 at 10 53 08 PM

Seems like it's working for you locally but not through heroku? Is this because of the disconnect btw live and test or another issue?

The live version resulted in:

Screen Shot 2021-06-29 at 10 55 00 PM

Is this what we're looking for in terms of data? It seems like the html tags aren't loading properly or am I reading this incorrectly?

BeeXiong commented 3 years ago

Seems like it's working for you locally but not through heroku? Is this because of the disconnect btw live and test or another issue?

This template tmpl_1057bb6f50f81fb worked locally when I used the TestLob secret locally. When I tried to use the LiveLob secret, it did not work locally.

Since the app is configured to automatically pull the LiveLob secret from Heroku, only the templates (such as tmpl_dd329a670255dd8) will work as they are configured in Lob to be "Live Templates".

Something also seems to be wrong with the html tags as you mentioned. @manishapriya94 can you confirm

manishapriya94 commented 3 years ago

For simplicity sake it seems like just streamlining to live would be best (they're the only letters that can be sent) or would you want the test for internal testing purpose?

By html tags, do you mean content of the letter? @mahrsbar

Let me refresh all templates and provide only live template IDs for the letters we have in db @BeeXiong

BeeXiong commented 3 years ago

I think @mahrsbar is referring to how the HTML only has "deails" within the tags.

The one that is in the test environment has a lot more HTML code within the tags

Screen Shot 2021-06-29 at 10 02 28 PM
manishapriya94 commented 3 years ago

@mahrsbar oh the html tags may be limited since we created a lot of empty shells

mahrsbar commented 3 years ago

Ahh, okay. I think sticking with live version works. Will this change the API call used in the front end?

Is it possible to add some text in the html tags to the live versions just so once its called in the front-end, some kind of letter text is available to view? Not necessary but would be beneficial for testing and design.

manishapriya94 commented 3 years ago

@mahrsbar updated!

mahrsbar commented 3 years ago

Thank you! The letter_version api needs to be updated to get the live template_id instead of the test one right? @BeeXiong

BeeXiong commented 3 years ago

Thank you! The letter_version api needs to be updated to get the live template_id instead of the test one right? @BeeXiong

We need to update the database to have correct template_id information. For now @mahrsbar, I'd say you could hard code the template_id that works with the Live environment. Just awaiting what we have in lob to do that in the DB.

I also agree that we should just create everything in the Live environment for templates

manishapriya94 commented 3 years ago

For now lets keep it to one version of each across the federal, state, local templates of each letter unless the policy is state specific (In AAAJ's case)

Screen Shot 2021-06-30 at 4 51 41 PM
BeeXiong commented 3 years ago

@manishapriya94 - Saw that the Jobs for All Act was an unknown campaign. Per our conversation, could you provide me with the data to put into the db? Structure is below.

Screen Shot 2021-07-01 at 12 23 47 PM

Once I have that foreign key for the campaign, I can add a new record for that Jobs for All Act template_id tmpl_8f8b18039d528a1 (data structure for letter_version table below)

Screen Shot 2021-07-01 at 12 25 56 PM
manishapriya94 commented 3 years ago

Yep! Will add a campaign adder issue EOD For now: org: Sunrise Movement name: Jobs for All Act cause: Climate Justice type: Grant page_url: https://www.sunrisemovement.org/

For AAAJ, lets make the name Education Access for All Act?

manishapriya94 commented 3 years ago

Updated

Screen Shot 2021-07-01 at 5 15 58 PM
BeeXiong commented 3 years ago

Jumping back in this... Any task left to do for this?

If so, let's edit this comment to put task.

If not, let's close this issue to clean up a bit.