Skip to content
This repository has been archived by the owner on Apr 4, 2022. It is now read-only.

Adopt fluent syntax for client calls #15

Merged
merged 12 commits into from Aug 27, 2021
Merged

Adopt fluent syntax for client calls #15

merged 12 commits into from Aug 27, 2021

Conversation

Gummibeer
Copy link
Contributor

resolves #13

This PR switches the current single method calls to a fluent builder style for easier readability and this also allows us to use different classes per context - as the GraphQL queries for viewer and user/organization are different and also allow different things. For example only a viewer can retrieve the tiers for a sponsorship.

I renamed and changed some more class names in that context as I think they match better now. But I'm open for discussion here and change things back.

@Gummibeer Gummibeer added the enhancement New feature or request label Aug 26, 2021
@Gummibeer Gummibeer self-assigned this Aug 26, 2021
Copy link
Owner

@driesvints driesvints left a comment

Choose a reason for hiding this comment

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

This is everything for now. Will do a new review tomorrow but it might be best that you already do some of the changes before I do so. Thanks!

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@@ -0,0 +1,69 @@
<?php

namespace GitHub\Sponsors\Clients;
Copy link
Owner

Choose a reason for hiding this comment

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

Move this back to the GitHub\Sponsors namespace.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With the coming things in mind I think that having them in a dedicated namespace than all in package root is a better idea to keep classes structured and organized.

src/Clients/Viewer.php Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
use GitHub\Sponsors\Clients\Viewer;
use Illuminate\Http\Client\Factory;

final class Client
Copy link
Owner

Choose a reason for hiding this comment

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

Merge the logic of this class with GraphqlClient and name it Client.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The idea was that the Client is more a Factory now - possibly we should rename it!?
And the GraphqlClient only cares about sending GraphQL queries to GitHub.

Merging them would also mean that I would have to pass an instance of Client to the Login/Viewer classes which would mean that they could also call themselves or the other client.

README.md Outdated Show resolved Hide resolved
src/GraphqlClient.php Outdated Show resolved Hide resolved
@Gummibeer
Copy link
Contributor Author

@driesvints driesvints merged commit c9f55d7 into main Aug 27, 2021
@driesvints driesvints deleted the issue-13 branch August 27, 2021 11:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adopt fluent syntax for client calls
2 participants