public function buy($phoneNumber, $appId = null)
    {
        $response = $this->client->update(
            $this->uri . $phoneNumber . '/',
            ['app_id'=>$appId]
        );

        $responseContents = $response->getContent();
        if(!array_key_exists("error",$responseContents)){
            return new PhoneNumberBuyResponse(
                $responseContents['api_id'],
                $responseContents['message'],
                $responseContents['numbers'][0]['number'],
                $responseContents['numbers'][0]['status'],
                $responseContents['status'],
                $response->getStatusCode()
            );
        } else {
            throw new PlivoResponseException(
                $responseContents['error'],
                0,
                null,
                $response->getContent(),
                $response->getStatusCode()

            );
        }
        
    }
public function buy($phoneNumber, $appId = null)
    {
        $response = $this->client->update(
            $this->uri . $phoneNumber . '/',
            ['app_id'=>$appId]
        );

        $responseContents = $response->getContent();
        if(!array_key_exists("error",$responseContents)){
            return new PhoneNumberBuyResponse(
                $responseContents['api_id'],
                $responseContents['message'],
                $responseContents['numbers'][0]['number'],
                $responseContents['numbers'][0]['status'],
                $responseContents['status'],
                $response->getStatusCode()
            );
        } else {
            throw new PlivoResponseException(
                $responseContents['error'],
                0,
                null,
                $response->getContent(),
                $response->getStatusCode()

            );
        }
        
    }
public function buy ( $ phoneNumber , $ appId = null ) { $ response = $ this -> client -> update ( $ this -> uri . $ phoneNumber . '/' , [ 'app_id' => $ appId ] ) ; $ responseContents = $ response -> getContent ( ) ; if ( ! array_key_exists ( "error" , $ responseContents ) ) { return new PhoneNumberBuyResponse ( $ responseContents [ 'api_id' ] , $ responseContents [ 'message' ] , $ responseContents [ 'numbers' ] [ 0 ] [ 'number' ] , $ responseContents [ 'numbers' ] [ 0 ] [ 'status' ] , $ responseContents [ 'status' ] , $ response -> getStatusCode ( ) ) ; } else { throw new PlivoResponseException ( $ responseContents [ 'error' ] , 0 , null , $ response -> getContent ( ) , $ response -> getStatusCode ( ) ) ; } }
Buy a phone number

@param number $phoneNumber
@param string|null $appId
@return PhoneNumberBuyResponse output
Buy a phone number