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
defmodule Acme.EmailTest do | |
use ExUnit.Case | |
alias Acme.Models.User | |
test "welcome email" do | |
user = %User{first_name: "John", email: "person@example.com"} | |
email = Acme.Email.welcome_user(user) | |
assert email.to == user |
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
config :geolix, :databases, [ | |
%{ | |
id: :city, | |
adapter: Geolix.Adapter.MMDB2, | |
source: "https://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz" | |
}, | |
%{ | |
id: :country, | |
adapter: Geolix.Adapter.MMDB2, | |
source: "https://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.tar.gz" |
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
iex(1)> Geolix.lookup("45.50.161.38") | |
%{ | |
city: %Geolix.Adapter.MMDB2.Result.City{ | |
city: %Geolix.Adapter.MMDB2.Record.City{ | |
geoname_id: 5368361, | |
name: "Los Angeles", | |
names: %{ | |
de: "Los Angeles", | |
en: "Los Angeles", | |
es: "Los Ángeles", |
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
iex(1)> Geolix.lookup("45.50.161.38", [as: :raw, where: :country]) | |
%{ | |
continent: %{ | |
code: "NA", | |
geoname_id: 6255149, | |
names: %{ | |
de: "Nordamerika", | |
en: "North America", | |
es: "Norteamérica", | |
fr: "Amérique du Nord", |
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
iex(1)> Geolix.lookup("45.50.161.38", [as: :raw, where: :country]) | |
%{ | |
continent: %{ | |
code: "NA", | |
geoname_id: 6255149, | |
names: %{ | |
de: "Nordamerika", | |
en: "North America", | |
es: "Norteamérica", | |
fr: "Amérique du Nord", |
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
def create_subscription(email, plan_id, payment_method_id) do | |
case Repo.get_by(User, email: email) do | |
%User{customer_id: nil, name: name} = user -> | |
params = %{ | |
name: name, | |
email: email, | |
payment_method: payment_method_id, | |
invoice_settings: %{ | |
default_payment_method: payment_method_id | |
} |
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
def create_subscription(email, plan_id, payment_method_id) do | |
with %User{customer_id: nil, name: name} = user <- | |
Repo.get_by(User, email: email), | |
{:ok, %Stripe.Customer{id: customer_id}} <- | |
Stripe.Customer.create(%{ | |
name: name, | |
email: email, | |
payment_method: payment_method_id, | |
invoice_settings: %{ | |
default_payment_method: payment_method_id |
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
def create_subscription(email, plan_id, payment_method_id) do | |
with {:user_lookup, %User{customer_id: nil, name: name} = user} <- | |
{:user_lookup, Repo.get_by(User, email: email)}, | |
{:customer_creation, {:ok, %Stripe.Customer{id: customer_id}}} <- | |
{:customer_creation, | |
Stripe.Customer.create(%{ | |
name: name, | |
email: email, | |
payment_method: payment_method_id, | |
invoice_settings: %{ |
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
Python 3.7.6 (default, Jan 2 2020, 08:35:56) | |
[Clang 11.0.0 (clang-1100.0.33.16)] on darwin | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> 0.1 + 0.2 | |
0.30000000000000004 |
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
Python 3.7.6 (default, Jan 2 2020, 08:35:56) | |
[Clang 11.0.0 (clang-1100.0.33.16)] on darwin | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> 0.1 + 0.2 | |
0.30000000000000004 |