> ## Documentation Index
> Fetch the complete documentation index at: https://plivo.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Upgrade from Ruby Legacy to v4.9.0 or Latest Version

> Migrate from legacy Ruby SDK to v4.9.0+ — code changes required

## Introduction

This is a major application update. Plivo recommends you always use the latest or an active version of our SDKs for guaranteed security, stability, and uptime. The active SDK versions are designed to handle intermittent and regional failures of API requests. In addition, they offer a host of security features, such as protection against DoS attacks and bot detection for suspicious user agents.

<Warning>
  <strong>Deprecation notice:</strong> We’re deprecating Plivo Ruby SDK legacy versions lower than v4.9.0 on January 31, 2022. If you use a deprecated version of our SDK after that date, your API requests and voice calls may fail intermittently. Plivo will no longer provide bug fixes to these versions, and our support team may ask you to upgrade before debugging issues.
</Warning>

## Migrate your applications

### Ruby version support

The Plivo Ruby SDK supports Ruby 2.0 and above.

Use the command **gem install plivo -v 4.9.0** to upgrade to the active version of the SDK, or **gem update plivo** to upgrade to the latest version.

After you upgrade to the latest version of the SDK, you should check every program that depends on it and make changes to the syntax for several kinds of operations. Here are examples of how coding differs between the deprecated legacy version of the SDK and the latest active versions.

### Importing the SDK

<CodeGroup>
  ```ruby Legacy theme={null}
  require 'plivo'
  ```

  ```ruby Latest theme={null}
  require 'plivo'
  ```
</CodeGroup>

### Initialize

<CodeGroup>
  ```ruby Legacy theme={null}
  p = RestAPI.new("<auth_id>","<auth_token>")
  ```

  ```ruby Latest theme={null}
  api = RestClient.new("<auth_id>","<auth_token>")
  ```
</CodeGroup>

### Access Resources

<CodeGroup>
  ```ruby Legacy theme={null}
  response = p.make_call(params)
  ```

  ```ruby Latest theme={null}
  response = api.calls.create(params)
  ```
</CodeGroup>

### Make a call

<CodeGroup>
  ```ruby Legacy theme={null}
  require 'rubygems'
  require 'plivo'
  include Plivo
  AUTH_ID = "<auth_id>"
  AUTH_TOKEN = "<auth_token>"

  p = RestAPI.new(AUTH_ID, AUTH_TOKEN)

  params = {
      'to' => '12025552323',   
      'from' => '12025551212', 
      'answer_url' => 'https://s3.amazonaws.com/static.plivo.com/answer.xml',
      'answer_method' => 'GET'
  }

  response = p.make_call(params)
  print response
  ```

  ```ruby Latest theme={null}
  require 'rubygems'
  require 'plivo'

  include Plivo
  include Plivo::Exceptions

  api = RestClient.new("<auth_id>","<auth_token>")

  begin
    response = api.calls.create(
      '+12025551212',
      ['+12025552323'],
      'https://s3.amazonaws.com/static.plivo.com/answer.xml'
    )
    puts response
  rescue PlivoRESTError => e
    puts 'Exception: ' + e.message
  end
  ```
</CodeGroup>

### Dial XML

<CodeGroup>
  ```ruby Legacy theme={null}
  require 'rubygems'
  require 'plivo'
  include Plivo

  response = Response.new()

  params = {
      'dialMusic' => "https://<yourdomain>.com/dial_music/"
  }

  dial = response.addDial(params)
  first_number = "12025552323"
  dial.addNumber(first_number)

  puts response.to_xml()
  ```

  ```ruby Latest theme={null}
  require 'rubygems'
  require 'plivo'

  include Plivo::XML
  include Plivo::Exceptions

  begin
    response = Response.new

    params = {
        'dialMusic' => "https://<yourdomain>.com/dial_music/"
    }

    dial = response.addDial(params)
    first_number = "12025552323"
    dial.addNumber(first_number)

    xml = PlivoXML.new(response)
    puts xml.to_xml
  rescue PlivoXMLError => e
    puts 'Exception: ' + e.message
  end
  ```
</CodeGroup>

### Conference XML

<CodeGroup>
  ```ruby Legacy theme={null}
  require 'rubygems'
  require 'plivo'
  include Plivo

  response = Response.new()

  params = {
      'startConferenceOnEnter' => "false",
      'waitSound' => "https://<yourdomain>.com/waitmusic/"
  }

  conference_name = "My Room"
  response.addConference(conference_name, params)

  puts response.to_xml()
  ```

  ```ruby Latest theme={null}
  require 'rubygems'
  require 'plivo'

  include Plivo::XML
  include Plivo::Exceptions

  begin
    response = Response.new

    params = {
      'startConferenceOnEnter' => "false",
      'waitSound' => "https://<yourdomain>.com/waitmusic/"
    }

    conference_name = "My Room"
    response.addConference(conference_name, params)

    xml = PlivoXML.new(response)
    puts xml.to_xml
  rescue PlivoXMLError => e
    puts 'Exception: ' + e.message
  end
  ```
</CodeGroup>

### Record API

<CodeGroup>
  ```ruby Legacy theme={null}
  require 'rubygems'
  require 'plivo'
  AUTH_ID = "<auth_id>"
  AUTH_TOKEN = "<auth_token>"


  p = RestAPI.new(AUTH_ID, AUTH_TOKEN)
  params = {'call_uuid' => call_uuid}
  response = p.record(params)
  print response
  ```

  ```ruby Latest theme={null}
  require 'rubygems'
  require 'plivo'

  include Plivo
  include Plivo::Exceptions

  api = RestClient.new("<auth_id>","<auth_token>")

  begin
    response = api.calls.record(
      'eba53b9e-8fbd-45c1-9444-696d2172fbc8'
    )
    puts response
  rescue PlivoRESTError => e
    puts 'Exception: ' + e.message
  end
  ```
</CodeGroup>

### Record XML

<CodeGroup>
  ```ruby Legacy theme={null}
  require 'rubygems'
  require 'plivo'
  include Plivo

  response = Response.new()

  params = {
      'action' => "https://<yourdomain>.com/get_recording/",
      'startOnDialAnswer' => "true",
      'redirect' => "false"
  }

  response.addRecord(params)

  dial = response.addDial()
  number = "12025552323"
  dial.addNumber(number)

  puts response.to_xml()
  ```

  ```ruby Latest theme={null}
  require 'rubygems'
  require 'plivo'

  include Plivo::XML
  include Plivo::Exceptions

  begin
    response = Response.new

    params = {
        action: 'https://<yourdomain>.com/get_recording/',
        startOnDialAnswer: 'true',
        redirect: 'false'
    }

    response.addRecord(params)

    dial = response.addDial()
    number = '12025552323'
    dial.addNumber(number)

    xml = PlivoXML.new(response)
    puts xml.to_xml
  rescue PlivoXMLError => e
    puts 'Exception: ' + e.message
  end
  ```
</CodeGroup>
