Skip to content

Conversation

@tfinnell
Copy link
Collaborator

@tfinnell tfinnell commented Nov 9, 2017

The main change here is Facebook.Graph is replaced with Facebook.GraphAPI & Facebook.GraphVideoAPI, the HTTP response formatting functions were moved into a separate module, ResponseFormatter. One thing to consider is combining and moving the http request + formatter calls into the existing Facebook.Graph, but I do like having the HTTP library exposed in the main library opposed to in another wrapper as we get a bit more flexibility in configuring requests without having to modify a wrapper module.

I ended up updating a bit of documentation as well since I was basically touching every function as I was doing this. Added some @typedocs and provided a few links here and there. Also added a blurb about contributing to the README.

When we bump to v2.11 of the graph API we may be able to ditch the additional wrapper around the video api as I believe it's all now under the single graph_url. Things still seemed to work as they are on v2.11 when I tested, though.

Last thing, looks like #48 is stagnant, so, if there's no feedback that results in major changes to this PR, I'll start looking into implementing the chat endpoints on top of this. Regardless, appreciate any feedback guys!

@paulruescher
Copy link
Collaborator

Nice 👍

I just took a quick look and haven't done a deep dive, but one thing sticks out: do we even need hackney anymore?

@tfinnell
Copy link
Collaborator Author

Ya, you're right. HTTPoison is pulling it in anyway.

README.md Outdated
We encourage contribution from anyone! If you've got an improvement to the documentation or feature you've implemented, please open a [pull request](https://github.com/mweibel/facebook.ex/pulls).
This project uses [credo](https://github.com/rrrene/credo) for code analysis. Running `mix credo` will give you a nice output which will tell you if any of the changes you've made aren't consistent with the rest of our codebase.

The Facebook Graph API is fairly large and as such we're not using every facet of it, so if you're not seeing an edge that is handled, please report an [issue](https://github.com/mweibel/facebook.ex/issues).
Copy link
Owner

Choose a reason for hiding this comment

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

report an issue or open a PR to add it?

See [API Documentation for facebook.ex](http://hexdocs.pm/facebook/).
## Contributing
We encourage contribution from anyone! If you've got an improvement to the documentation or feature you've implemented, please open a [pull request](https://github.com/mweibel/facebook.ex/pulls).
This project uses [credo](https://github.com/rrrene/credo) for code analysis. Running `mix credo` will give you a nice output which will tell you if any of the changes you've made aren't consistent with the rest of our codebase.
Copy link
Owner

Choose a reason for hiding this comment

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

great!

@mweibel
Copy link
Owner

mweibel commented Nov 10, 2017

Just had a brief look but so far this looks amazing! Thanks for that!


alias Facebook.Config

def process_url(url), do: Config.graph_url <> url
Copy link
Collaborator

Choose a reason for hiding this comment

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

I have a pattern matching idea for how to combine this with the GraphVideoApi module, I just need a sec to test it. Essentially I think we can pattern match off a binary passed in

]
end

defp request do
Copy link
Collaborator

Choose a reason for hiding this comment

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

so much cleaner than what I had 👍

end,
body: fn(_) -> Facebook.GraphMock.me(:success) end
] do
with_mock :hackney, GraphMock.mock_options(
Copy link
Owner

Choose a reason for hiding this comment

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

:hackney mock is probably not needed anymore, or is it?

@mweibel
Copy link
Owner

mweibel commented Nov 10, 2017

Went a bit more through it and that all seems ok. A bit confused about the hackney mocks there. Is it because HTTPoison uses hackney internally?
Anyway, let me know when you consider this done and I'm more than happy to merge!
If you'd like I'll also make you an owner of the package on hex so you could publish new versions too.

end,
body: fn(_) -> Facebook.GraphMock.me(:success) end
] do
with_mock :hackney, GraphMock.mock_options(
Copy link
Collaborator

Choose a reason for hiding this comment

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

If someone wouldn't mind enlightening me, I actually don't understand how this still works. From my undertanding with_mock takes a module, and then mocks out the methods on that module via the given list. How does with_mock :hackney, still work here?

@paulruescher
Copy link
Collaborator

Oops, looks I forgot to submit my review last night 🤷‍♀️

@tfinnell
Copy link
Collaborator Author

Exactly! HTTPoison is just a wrapper for hackney (just as Facebook.Graph was), which is why this still works.

Now, we could be explicit and go the route of mocking the HTTPoison method functions, but I sorta like the consistency as is.

Since it does seem to raise some wtf? reactions, I've added some documentation to that module 😃

Thanks for the feedback @paulruescher & @mweibel -- I think this is good to go.

@mweibel I'd be happy to help out with version publishing!

@paulruescher
Copy link
Collaborator

Awesome, I def agree with keeping it for now. I know we talked mocking briefly before, but I've been using this as a guide recently for structuring 3rd party API calls of my own http://blog.plataformatec.com.br/2015/10/mocks-and-explicit-contracts/

Seems to work quite well. Definitely future consideration tho 👍

Awesome work 🎉

@tfinnell
Copy link
Collaborator Author

tfinnell commented Nov 11, 2017

I read that same blog post as I was working on this 😄
I keep bringing up this library, but, exVCR seems to address this mocking issue since the http library it uses is configurable. The reason I'm so keen on it is the amount of transparency it provides into the request/responses that an http library creates -- it becomes a super useful tool for debugging!

@mweibel mweibel merged commit ec0daaa into mweibel:master Nov 11, 2017
@mweibel
Copy link
Owner

mweibel commented Nov 11, 2017

Thanks!
Merged it. Can you tell me your hex.pm email address so I can add you? (You can also send it to my email address in my git commits if you don't wanna put it here)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants