Skip to content

Commit

Permalink
Add updateCustomerAddress method
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexAzartsev committed Feb 1, 2022
1 parent cc937ee commit 5d1fab2
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 3 deletions.
15 changes: 15 additions & 0 deletions src/Api/Klarna.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ public function setNewOrderAmountAndOrderLines(string $order, array $body): arra

/**
* @see https://developers.klarna.com/api/#order-management-api-acknowledge-order
*
* @param string $order
*
* @return array
Expand All @@ -288,4 +289,18 @@ public function acknowledge(string $order): array
{
return $this->postRequest("/ordermanagement/v1/orders/$order/acknowledge", []);
}

/**
* @see https://developers.klarna.com/api/#order-management-api-update-customer-addresses
*
* @param string $order
* @param array $body
*
* @return array
* @throws KlarnaException
*/
public function updateCustomerAddress(string $order, array $body): array
{
return $this->patchRequest("/ordermanagement/v1/orders/$order/customer-details", $body);
}
}
38 changes: 38 additions & 0 deletions src/Models/Address.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace Gets\Klarna\Models;
use Gets\Klarna\Traits\Fillable;

class Address
{
use Fillable;

public $given_name;
public $family_name;
public $title;
public $street_address;
public $street_address2;
public $postal_code;
public $city;
public $region;
public $country;
public $email;
public $phone;

public function toArray(): array
{
return [
'given_name' => $this->given_name,
'family_name' => $this->family_name,
'title' => $this->title,
'street_address' => $this->street_address,
'street_address2' => $this->street_address2,
'postal_code' => $this->postal_code,
'city' => $this->city,
'region' => $this->region,
'country' => $this->country,
'email' => $this->email,
'phone' => $this->phone,
];
}
}
2 changes: 1 addition & 1 deletion src/Models/OrderLine.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Gets\Klarna\Models;

use Fillable;
use Gets\Klarna\Traits\Fillable;

class OrderLine
{
Expand Down
3 changes: 1 addition & 2 deletions src/Models/ShippingInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Gets\Klarna\Models;

use Fillable;
use Gets\Klarna\Traits\Fillable;

class ShippingInfo
{
Expand All @@ -23,7 +23,6 @@ class ShippingInfo
public $shipping_method;
public $tracking_number;
public $tracking_uri;

public $return_shipping_company;
public $return_tracking_number;
public $return_tracking_uri;
Expand Down
4 changes: 4 additions & 0 deletions src/Traits/Fillable.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?php

namespace Gets\Klarna\Traits;

use InvalidArgumentException;

/**
* Fill the class properties by array/object
*/
Expand Down

0 comments on commit 5d1fab2

Please sign in to comment.