Parts of the new REST api require a zuora-version header to be sent. Proposed solution will be to add

$zuora_version = null in the call functions.

Comments

Tyler_Marshall created an issue. See original summary.

TylerMarshall’s picture

Status: Active » Needs review
StatusFileSize
new2.07 KB

Adds a patch that adds $zuora_version = null in all functions and filters out in httpRequest.

TylerMarshall’s picture

StatusFileSize
new576 bytes

Forgot to add the implementation in httpHeaders()

TylerMarshall’s picture

StatusFileSize
new541 bytes

Zuora Support told me to move from zuora_version to zuora-version

TylerMarshall’s picture

StatusFileSize
new2.21 KB

Forgot to add the finished patch with interdiffs applied.

mglaman’s picture

Status: Needs review » Needs work
  1. +++ b/src/Rest/Client.php
    @@ -44,8 +44,8 @@ class Client extends ZuoraClientBase {
    +  public function get($uri, $zuora_version = null) {
    
    @@ -56,8 +56,8 @@ class Client extends ZuoraClientBase {
    +  public function post($uri, array $body, $zuora_version = null) {
    
    @@ -68,8 +68,8 @@ class Client extends ZuoraClientBase {
    +  public function put($uri, array $body, $zuora_version = null) {
    
    @@ -83,10 +83,10 @@ class Client extends ZuoraClientBase {
    +  public function httpRequest($type, $uri, array $body = null, $zuora_version = null) {
    
    @@ -104,13 +104,16 @@ class Client extends ZuoraClientBase {
    +  protected function httpHeaders($zuora_version = null) {
    

    Document blocks not updated.

  2. +++ b/src/Rest/Client.php
    @@ -104,13 +104,16 @@ class Client extends ZuoraClientBase {
    +      'zuora-version' => $zuora_version,
    ...
    +    $headers = array_filter($headers);
    

    Why not first just check if it's not null, then add if it has a value versus array filter.

TylerMarshall’s picture

StatusFileSize
new3.03 KB
new2.34 KB

Updated docs, and added if check for zuora_version

TylerMarshall’s picture

Status: Needs work » Needs review
mglaman’s picture

Status: Needs review » Needs work
+++ b/src/Rest/Client.php
@@ -40,12 +40,15 @@ class Client extends ZuoraClientBase {
+  public function get($uri, $zuora_version = null) {
+    return $this->httpRequest('GET', $uri, $zuora_version);

@@ -79,14 +88,16 @@ class Client extends ZuoraClientBase {
+  public function httpRequest($type, $uri, array $body = null, $zuora_version = null) {

httpRequest expects a body value. You're sending the Zuora version as the body in GET requests.

mglaman’s picture

+++ b/src/Rest/Client.php
@@ -79,14 +88,16 @@ class Client extends ZuoraClientBase {
     $response = $this->httpClient->request($type, '/' . self::ZUORA_API_VERSION . $uri, [
...
+      'headers' => $this->httpHeaders($zuora_version),

@@ -102,15 +113,23 @@ class Client extends ZuoraClientBase {
+    if($zuora_version != NULL){
+      $headers['zuora-version'] = $zuora_version;
+    }

I know they told us to do this, but why can't we just change the URL?

Can we also provide a constant for the other version?

TylerMarshall’s picture

StatusFileSize
new3.04 KB
new2.52 KB

Added NULL in the method header for get so we can pass zuora_header

TylerMarshall’s picture

Status: Needs work » Needs review

mglaman’s picture

Status: Needs review » Fixed

Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.