-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1243 from code-corps/fix-issues
Upgrade deps, add missing specs, fix some dialyzer issues
- Loading branch information
Showing
13 changed files
with
90 additions
and
111 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
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,33 +1,39 @@ | ||
defmodule CodeCorps.Emails.OrganizationInviteEmail do | ||
import Bamboo.Email | ||
import Bamboo.PostmarkHelper | ||
import Bamboo.Email, only: [to: 2] | ||
import Bamboo.PostmarkHelper | ||
|
||
alias CodeCorps.{Emails.BaseEmail, OrganizationInvite, WebClient} | ||
alias CodeCorps.{Emails.BaseEmail, OrganizationInvite, WebClient} | ||
|
||
def create(%OrganizationInvite{} = invite) do | ||
BaseEmail.create | ||
|> to(invite.email) | ||
|> template(template_id(), build_model(invite)) | ||
end | ||
@spec create(OrganizationInvite.t) :: Bamboo.Email.t | ||
def create(%OrganizationInvite{} = invite) do | ||
BaseEmail.create | ||
|> to(invite.email) | ||
|> template(template_id(), build_model(invite)) | ||
end | ||
|
||
defp build_model(%OrganizationInvite{} = invite) do | ||
%{ | ||
organization_name: invite.organization_name, | ||
invite_url: invite_url(invite.code, invite.organization_name), | ||
subject: "Create your first project on Code Corps" | ||
} | ||
end | ||
@spec build_model(OrganizationInvite.t) :: map | ||
defp build_model(%OrganizationInvite{} = invite) do | ||
%{ | ||
organization_name: invite.organization_name, | ||
invite_url: invite_url(invite.code, invite.organization_name), | ||
subject: "Create your first project on Code Corps" | ||
} | ||
end | ||
|
||
defp invite_url(code, organization_name) do | ||
WebClient.url() | ||
|> URI.merge("/invites/organization" <> "?" <> set_params(code, organization_name)) | ||
|> URI.to_string | ||
end | ||
@spec invite_url(String.t, String.t) :: String.t | ||
defp invite_url(code, organization_name) do | ||
query_params = set_params(code, organization_name) | ||
WebClient.url() | ||
|> URI.merge("/invites/organization" <> "?" <> query_params) | ||
|> URI.to_string | ||
end | ||
|
||
defp set_params(code, organization_name) do | ||
%{code: code, organization_name: organization_name } | ||
|> URI.encode_query | ||
end | ||
@spec set_params(String.t, String.t) :: binary | ||
defp set_params(code, organization_name) do | ||
%{code: code, organization_name: organization_name} | ||
|> URI.encode_query | ||
end | ||
|
||
defp template_id, do: Application.get_env(:code_corps, :organization_invite_email_template) | ||
@spec template_id :: String.t | ||
defp template_id, do: Application.get_env(:code_corps, :organization_invite_email_template) | ||
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
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
Oops, something went wrong.