Skip to content
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 isSuccessful() method to Response #97

Merged
merged 1 commit into from
Jan 20, 2019
Merged

Conversation

OndraM
Copy link
Member

@OndraM OndraM commented Jan 17, 2019

For simple check whether all contained command responses were successful.

This is also recommended way how to validate response successfulness.

If you don't need to process response (eg. when submitting events to Matej) you can now for example simply do this:

public function submitDataToMatej(/*...*/): bool
    $response = $matej->request()
        ...
        ->send();
    
    // All commands were successful
    if ($response->isSuccessful()) {
        return true;
    }
    
    // At least one was not successful, so we log those
    foreach ($response->getCommandResponses() as $commandResponse) {
        if (!$commandResponse->isSuccessful()) {
            $this->logger->log('Command to Matej failed: ' . $commandResponse);
        }
    }
    
    return false;
}

jirinovak
jirinovak previously approved these changes Jan 17, 2019
@OndraM OndraM force-pushed the feature/AR-165-is-successful branch from e299fff to b58843b Compare January 20, 2019 23:21
@OndraM OndraM force-pushed the feature/AR-165-exception-handling branch 2 times, most recently from 213cde7 to 8a9c2bb Compare January 20, 2019 23:30
@OndraM OndraM force-pushed the feature/AR-165-is-successful branch from b58843b to 4b46ddd Compare January 20, 2019 23:31
@OndraM OndraM changed the base branch from feature/AR-165-exception-handling to master January 20, 2019 23:39
@OndraM OndraM force-pushed the feature/AR-165-is-successful branch from 4b46ddd to 7cdcb30 Compare January 20, 2019 23:41
@OndraM OndraM merged commit 0de8a4f into master Jan 20, 2019
@OndraM OndraM deleted the feature/AR-165-is-successful branch March 31, 2020 11:38
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.

2 participants