You are here

class Braintree_SettlementBatchSummary in Commerce Braintree 7

Hierarchy

Expanded class hierarchy of Braintree_SettlementBatchSummary

File

braintree_php/lib/Braintree/SettlementBatchSummary.php, line 2

View source
class Braintree_SettlementBatchSummary extends Braintree {
  public static function generate($settlement_date, $groupByCustomField = NULL) {
    $criteria = array(
      'settlement_date' => $settlement_date,
    );
    if (isset($groupByCustomField)) {
      $criteria['group_by_custom_field'] = $groupByCustomField;
    }
    $params = array(
      'settlement_batch_summary' => $criteria,
    );
    $response = Braintree_Http::post('/settlement_batch_summary', $params);
    if (isset($groupByCustomField)) {
      $response['settlementBatchSummary']['records'] = self::_underscoreCustomField($groupByCustomField, $response['settlementBatchSummary']['records']);
    }
    return self::_verifyGatewayResponse($response);
  }
  private static function _underscoreCustomField($groupByCustomField, $records) {
    $updatedRecords = array();
    foreach ($records as $record) {
      $camelized = Braintree_Util::delimiterToCamelCase($groupByCustomField);
      $record[$groupByCustomField] = $record[$camelized];
      unset($record[$camelized]);
      $updatedRecords[] = $record;
    }
    return $updatedRecords;
  }
  private static function _verifyGatewayResponse($response) {
    if (isset($response['settlementBatchSummary'])) {
      return new Braintree_Result_Successful(self::factory($response['settlementBatchSummary']));
    }
    else {
      if (isset($response['apiErrorResponse'])) {
        return new Braintree_Result_Error($response['apiErrorResponse']);
      }
      else {
        throw new Braintree_Exception_Unexpected("Expected settlementBatchSummary or apiErrorResponse");
      }
    }
  }
  public static function factory($attributes) {
    $instance = new self();
    $instance
      ->_initialize($attributes);
    return $instance;
  }

  /**
   * @ignore
   */
  protected function _initialize($attributes) {
    $this->_attributes = $attributes;
  }
  public function records() {
    return $this->_attributes['records'];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Braintree::returnObjectOrThrowException public static function
Braintree::_set public function
Braintree::__clone protected function @ignore don't permit cloning the instances (like $x = clone $v)
Braintree::__construct protected function @ignore don't permit an explicit call of the constructor! (like $t = new Braintree_Transaction()) 1
Braintree::__get public function returns private/nonexistent instance properties @ignore @access public
Braintree::__isset public function used by isset() and empty() @access public
Braintree_SettlementBatchSummary::factory public static function
Braintree_SettlementBatchSummary::generate public static function
Braintree_SettlementBatchSummary::records public function
Braintree_SettlementBatchSummary::_initialize protected function @ignore
Braintree_SettlementBatchSummary::_underscoreCustomField private static function
Braintree_SettlementBatchSummary::_verifyGatewayResponse private static function