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 json helper method to set payload as json-encoded value. #147

Merged
merged 6 commits into from
Aug 2, 2023

Conversation

mjauvin
Copy link
Member

@mjauvin mjauvin commented May 9, 2023

Allows doing this:

$payload = [
    'key1' => 'value1',
    'key2' => 'value2'
];

$apiResult = Http::post($url, function ($http) use ($payload) {
    $http->json( $payload );
});

Instead of this:

$payload = [
    'key1' => 'value1',
    'key2' => 'value2'
];

$apiResult = Http::post($url, function ($http) use ($payload) {
    $http->header('Content-Type', 'application/json; charset=utf-8');
    $http->setOption( CURLOPT_POSTFIELDS, json_encode($payload) );

src/Network/Http.php Outdated Show resolved Hide resolved
src/Network/Http.php Outdated Show resolved Hide resolved
@bennothommo bennothommo added this to the v1.2.3 milestone May 9, 2023
@mjauvin mjauvin changed the title Add the option to set the full payload as json-encoded value Add json helper method to set payload as json-encoded value. May 9, 2023
@LukeTowers LukeTowers modified the milestones: v1.2.3, v1.2.4 Jul 7, 2023
@mjauvin
Copy link
Member Author

mjauvin commented Jul 28, 2023

Any objection to merge this one ?

src/Network/Http.php Outdated Show resolved Hide resolved
src/Network/Http.php Outdated Show resolved Hide resolved
@LukeTowers LukeTowers merged commit ce542ac into develop Aug 2, 2023
8 checks passed
@LukeTowers LukeTowers deleted the set-payload branch August 2, 2023 01:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants