Development

Changeset 5567 for plugins/sfAmazonECSPlugin/lib

You must first sign up to be able to contribute.

Show
Ignore:
Timestamp:
10/17/07 17:43:10 (1 year ago)
Author:
Jonathan.Wage
Message:

Reworked plugin to utilize the changes to sfWSDLPlugin.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfAmazonECSPlugin/lib/BasesfAmazonECS.class.php

    r4809 r5567  
    3636   * @author  Jonathan H. Wage 
    3737   **/ 
    38   public function __construct($awsAccessKeyId, $associateTag = null, $merchantId = null) 
    39   { 
    40     $params = array('AWSAccessKeyId' => $awsAccessKeyId, 'AssociateTag' => $associateTag, 'MerchantId' => $merchantId); 
    41      
    42     $this->sfWSDL = new sfWSDL('AmazonECS', $this->wsdl, $params); 
    43      
    44     $this->awsAccessKeyId = $awsAccessKeyId; 
    45     $this->associateTag = $associateTag; 
    46     $this->merchantId = $merchantId; 
     38  public function __construct($awsAccessKeyId = null, $associateTag = null, $merchantId = null) 
     39  { 
     40    $args = $this->prepareArgs($awsAccessKeyId, $associateTag, $merchantId); 
     41     
     42    $this->sfWSDL = new sfWSDL('AmazonECS', $this->wsdl, $args); 
     43     
     44    $this->awsAccessKeyId = $args['AWSAccessKeyId']; 
     45    $this->associateTag = $args['AssociateTag']; 
     46    $this->merchantId = $args['MerchantId']; 
     47  } 
     48   
     49  public function prepareArgs($awsAccessKeyId, $associateTag, $merchantId) 
     50  {     
     51    if( !$awsAccessKeyId ) 
     52    { 
     53      $awsAccessKeyId = sfConfig::get('app_aws_access_key_id'); 
     54    } 
     55     
     56    if( !$associateTag ) 
     57    { 
     58      $associateTag = sfConfig::get('app_aws_associate_tag'); 
     59    } 
     60     
     61    if( !$merchantId ) 
     62    { 
     63      $merchantId = sfConfig::get('app_aws_merchant_id'); 
     64    } 
     65     
     66    if( !$awsAccessKeyId ) 
     67    { 
     68      throw new Exception('We could not find your AWSAccessKeyId. You must place a aws_access_key_id value in your app.yml or pass aws_access_key_id as a parameter to your api method, or pass it as the 3rd argument to the sfWSDL constructor.'); 
     69    } 
     70     
     71    return array('AWSAccessKeyId' => $awsAccessKeyId, 'AssociateTag' => $associateTag, 'MerchantId' => $merchantId); 
    4772  } 
    4873   
     
    428453    $params = array_merge($mainParams, $additionalParams); 
    429454     
    430     return $this->sfWSDL->$method($params); 
     455    $this->sfWSDL->addArgument('Service', 'AWSECommerceService'); 
     456    $this->sfWSDL->addArgument('Version', '2007-06-13'); 
     457    $this->sfWSDL->addArgument('Request', array($params)); 
     458     
     459    $this->sfWSDL->setArguments(array($this->sfWSDL->getArguments())); 
     460     
     461    $result = $this->sfWSDL->$method(); 
     462     
     463    return $result; 
    431464  } 
    432465}