Skip to content

Commit

Permalink
Merge pull request #44 from delatbabel/implement-getcode
Browse files Browse the repository at this point in the history
Implement getCode method in Response class
  • Loading branch information
delatbabel committed Mar 19, 2016
2 parents eb42edb + d0b5e4e commit fe05ddd
Showing 1 changed file with 31 additions and 15 deletions.
46 changes: 31 additions & 15 deletions src/Message/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function getTransactionReference()
return $this->data['error']['charge'];
}

return;
return null;
}

/**
Expand Down Expand Up @@ -79,7 +79,7 @@ public function getCustomerReference()
}
}

return;
return null;
}

/**
Expand Down Expand Up @@ -110,7 +110,7 @@ public function getCardReference()
}
}

return;
return null;
}

/**
Expand All @@ -124,7 +124,7 @@ public function getToken()
return $this->data['id'];
}

return;
return null;
}

/**
Expand All @@ -138,7 +138,7 @@ public function getCard()
return $this->data['card'];
}

return;
return null;
}

/**
Expand All @@ -150,9 +150,9 @@ public function getSource()
{
if (isset($this->data['source']) && $this->data['source']['object'] == 'card') {
return $this->data['source'];
} else {
return;
}

return null;
}

/**
Expand All @@ -166,7 +166,7 @@ public function getSubscriptionReference()
return $this->data['id'];
}

return;
return null;
}

/**
Expand All @@ -180,7 +180,7 @@ public function getEventReference()
return $this->data['id'];
}

return;
return null;
}

/**
Expand All @@ -194,7 +194,7 @@ public function getInvoiceReference()
return $this->data['id'];
}

return;
return null;
}

/**
Expand All @@ -208,7 +208,7 @@ public function getList()
return $this->data['data'];
}

return;
return null;
}

/**
Expand All @@ -224,7 +224,7 @@ public function getPlan()
return $this->data;
}

return;
return null;
}

/**
Expand All @@ -239,7 +239,7 @@ public function getPlanId()
return $plan['id'];
}

return;
return null;
}

/**
Expand All @@ -253,7 +253,7 @@ public function getInvoiceItemReference()
return $this->data['id'];
}

return;
return null;
}

/**
Expand All @@ -269,6 +269,22 @@ public function getMessage()
return $this->data['error']['message'];
}

return;
return null;
}

/**
* Get the error message from the response.
*
* Returns null if the request was successful.
*
* @return string|null
*/
public function getCode()
{
if (!$this->isSuccessful()) {
return $this->data['error']['code'];
}

return null;
}
}

0 comments on commit fe05ddd

Please sign in to comment.