-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add Workflow associations and remove Task #22
Changes from 4 commits
a84fac3
a0f7df9
930d86c
a342fe9
4962ea6
bf00fd0
7ff0db6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
defmodule PcoApi.People.Workflow do | ||
use PcoApi.Actions | ||
import PcoApi.RecordAssociation | ||
|
||
endpoint "people/v2/workflows/" | ||
|
||
import PcoApi.RecordAssociation | ||
linked_association :cards | ||
linked_association :steps | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,7 +56,7 @@ defmodule PcoApi.People.Workflow.Card.Note do | |
|
||
## Example: | ||
|
||
iex> %PcoApi.Record{type: "WorkflowCard", id: 1, links: %{"self" => "http://example.com"}} |> Address.get(2) | ||
iex> %PcoApi.Record{type: "WorkflowCard", id: 1, links: %{"self" => "http://example.com"}} |> Note.get(2) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above: |
||
%PcoApi.Record{type: "WorkflowCardNote", id: 2} # for Person.id == 1 | ||
|
||
""" | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,16 +4,19 @@ defmodule PcoApi.RecordAssociation do | |
def unquote(:"#{name}")([]), do: [] | ||
def unquote(:"#{name}")(%PcoApi.Record{} = record) do | ||
# TODO: error handling when the association link doesn't exist | ||
request(:get, record.links[Atom.to_string(unquote(name))], []) | ||
|> Enum.map(fn(%{"attributes" => attrs, "id" => id, "links" => links, "type" => type}) -> | ||
%PcoApi.Record{attributes: attrs, id: id, links: links, type: type} | ||
end) | ||
unquote(:"#{name}")(request(:get, record.links[Atom.to_string(unquote(name))], [])) | ||
end | ||
def unquote(:"#{name}")([%PcoApi.Record{} = first | rest]) do | ||
[unquote(:"#{name}")(first) | unquote(:"#{name}")(rest)] | ||
|> List.flatten | ||
|> Enum.dedup | ||
end | ||
def unquote(:"#{name}")(%{"attributes" => attrs, "id" => id, "links" => links, "type" => type}) do | ||
%PcoApi.Record{attributes: attrs, id: id, links: links, type: type} | ||
end | ||
def unquote(:"#{name}")(list) when is_list(list) do | ||
list |> Enum.map(&(unquote(:"#{name}")(&1))) | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's still a little hard to read the metaprogramming in Elixir, but are you doing anything in this file other than just breaking the function into smaller functions? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The line 5 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it. 👍 |
||
end | ||
end | ||
end |
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be
Activity.get(2)
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops!