Skip to content
This repository was archived by the owner on Jan 31, 2025. It is now read-only.

Add support for Sift Verification Product#2

Open
dereksweet wants to merge 34 commits into
apartmenttherapy:masterfrom
TheRealReal:master
Open

Add support for Sift Verification Product#2
dereksweet wants to merge 34 commits into
apartmenttherapy:masterfrom
TheRealReal:master

Conversation

@dereksweet

Copy link
Copy Markdown

What does this PR do & why?

This PR adds support for the Sift verification product, their 2FA offering that will deliver one time passwords to customers for security reasons. Is intended to be used for login but can be applied to any event they support.

How can this be manually tested?

You will need to become quite familiar with the Sift Verification product to manually test it, as well as have Sift turn the feature on for you. The integration guide can be found here: https://docs.google.com/document/d/11RK_oss2Z7TjydnugYHlG5tK41GMpCyfbNbjzZAYSfM/edit

Any questions or concerns about this change?

We have been using this branch at therealreal.com for a few months now so we are quite certain it's performing as expected. There are no changes to any of the existing functionality, just added a bunch of new methods to use for the Verification product.

Deployment Notes

No deployment notes

  • add a reviewer
  • run appropriate tests
  • tag anyone who might want to see this
  • update any relevant wiki documentation

Add support for the following fields for an update_account event
- $session_id
- update_status
Add support for the Verification API, following 3 endpoints:
- /send
- /resend
- /check
- Basic automated testing added for the Verification product via doctest
- Fixed compiler warnings when running full test suite
Comment on lines -73 to +88
%Account{"$user_email": "bob@example.com", "$user_id": "bob", "$api_key": api_key, "$type": "$create_account"}
%Account{"$user_email": "bob@example.com", "$user_id": "bob", "$api_key": api_key(), "$type": "$create_account"}

iex> Account.create_account(%{user_email: "bob@example.com", user_id: "bob", payment_methods: [%{payment_type: :cash}]})
%Account{"$user_email": "bob@example.com", "$user_id": "bob", "$api_key": api_key, "$payment_methods": [%PaymentMethod{"$payment_type": "$cash"}], "$type": "$create_account"}
%Account{"$user_email": "bob@example.com", "$user_id": "bob", "$api_key": api_key(), "$payment_methods": [%PaymentMethod{"$payment_type": "$cash"}], "$type": "$create_account"}

iex> Account.create_account(%{user_email: "bob@example.com", user_id: "bob", billing_address: %{name: "Bob", zipcode: "87102"}})
%Account{"$user_email": "bob@example.com", "$user_id": "bob", "$type": "$create_account", "$api_key": api_key, "$billing_address": %Address{"$name": "Bob", "$zipcode": "87102"}}
%Account{"$user_email": "bob@example.com", "$user_id": "bob", "$type": "$create_account", "$api_key": api_key(), "$billing_address": %Address{"$name": "Bob", "$zipcode": "87102"}}

iex> Account.create_account(%{user_email: "bob@example.com", user_id: "bob", promotions: [%{promotion_id: "promo"}]})
%Account{"$user_email": "bob@example.com", "$user_id": "bob", "$type": "$create_account", "$api_key": api_key, "$promotions": [%Promotion{"$promotion_id": "promo"}]}
%Account{"$user_email": "bob@example.com", "$user_id": "bob", "$type": "$create_account", "$api_key": api_key(), "$promotions": [%Promotion{"$promotion_id": "promo"}]}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was producing compiler warnings.


alias Siftsciex.Event.Payload
alias Siftsciex.Event.Payload.{Address, Image, Item, Location}
alias Siftsciex.Event.Payload.{Address, Image, Item}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was producing compiler warnings

Comment on lines -28 to +29
iex> Response.process(%{"status" => 0, "error_message" => "OK", "time" => time, "request" => ""})
%Response{status: 0, message: "OK", time: date_time, request: "", score_response: :empty}
iex> Response.process(%{"status" => 0, "error_message" => "OK", "time" => time(), "request" => ""})
%Response{status: 0, message: "OK", time: date_time(), request: "", score_response: :empty}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was producing compiler warnings

## Examples

iex> Error.error(response)
iex> Error.error(response())

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was producing compiler warnings

Comment on lines -4 to +10
def post(_, %{"$user_id": "transport_error"} = data) do
def post(_, %{"$user_id": "transport_error"} = _data) do
{:error, %{reason: "Timeout"}}
end
def post(_, %{"$user_id": "server_error"} = data) do
def post(_, %{"$user_id": "server_error"} = _data) do
{:ok, %{status_code: 500}}
end
def post(_, %{"$user_id": "client_error"} = data) do
def post(_, %{"$user_id": "client_error"} = _data) do

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was producing compiler warnings

@LeakyBucket

Copy link
Copy Markdown
Contributor

👋 Hi @dereksweet this is awesome! Unfortunately I'm not with Apartment Therapy any longer, although it looks like @andrewb is maybe he can help out with this? I would love for improvements to make it into the library so everyone can easily use them.

@dereksweet

Copy link
Copy Markdown
Author

Sure, thanks for the quick response @LeakyBucket. @andrewb any chance you'd want to merge this? We'd like to get off our local fork to ensure we are up to date with any changes in the future. I'm sure we will be adding more features in the future, as well. Let me know!

@andrewb

andrewb commented Nov 9, 2020

Copy link
Copy Markdown
Member

@dereksweet thanks for your contribution. Unfortunately our team no longer develops our Elixir codebases so I don't expect any updates to this repo in future.

@dereksweet

Copy link
Copy Markdown
Author

@dereksweet thanks for your contribution. Unfortunately our team no longer develops our Elixir codebases so I don't expect any updates to this repo in future.

OK that's fair. How would you feel about passing the torch on to me? I would take it up on my personal account.

@dereksweet

Copy link
Copy Markdown
Author

@andrewb I can actually get this merged directly into the SiftSciences organization here: https://github.com/SiftScience

Would you be willing to assist in getting the hexdocs updated to point there instead of at apartmenttherapy?

@dereksweet

Copy link
Copy Markdown
Author

@andrewb thought I'd try one more time to ask you about this. Would you be willing to transfer ownership of this project to The RealReal. You can see we've added more support for both login events and now we are adding support for the Decisions API as well. If not we can just keep adding to our fork or make a new package entirely, but if you'd be willing to pass on ownership of this we have a great relationship with the people at Sift and they will add it to their official packages list.

Here is some documentation on how to use the hex.owner mix to transfer ownership: https://hexdocs.pm/hex/Mix.Tasks.Hex.Owner.html

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants