Skip to content

Structuring of an API class? #5

Answered by Mulkave
bilogic asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, very close! I can suggest a few enhancements to the above:

  1. In a feature, only call jobs and operation. Never a direct class (i.e. PayPalClient)
  2. No need to pass the client to AuthenticateWithPayPalJob because it already knows which class it needs to deal with
  3. Exchange objects between jobs instead of primitive data types (strings, numbers, etc.)

Here's how it would look like after the above (though not sure if i understand correctly whether you should or should not have username and password).

class CheckBalanceFeature
{
    public function handle()
    {
        $token = $this->run(AuthenticateWithPayPalJob::class, [
           'username' => $username,
           'password' => $pass…

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by Mulkave
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #5 on December 10, 2020 21:15.