plivo 4.3.5 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +1 -1
- data/lib/plivo/base.rb +1 -0
- data/lib/plivo/base_client.rb +40 -4
- data/lib/plivo/resources.rb +1 -0
- data/lib/plivo/resources/call_feedback.rb +55 -0
- data/lib/plivo/rest_client.rb +4 -0
- data/lib/plivo/version.rb +1 -1
- metadata +3 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 88ca1cbed16ec4e3a12da537931eed4d5149616b
         | 
| 4 | 
            +
              data.tar.gz: 02dc6114077ff68c1d6d71d9d240a9b6c1da20e7
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 361bebcbda4512ec388ccba8536e8661ca3f4cb9dc0d24b8eda9f2b997e1dce91ce287f7d6b1970119ab983c6f74e595538a6ca522baec28220c1585bbe6d810
         | 
| 7 | 
            +
              data.tar.gz: 57171030cb74a81ae868711f9b70a59aa4c69ef029406a6fbfe2cfa42bb97bb328dd8de5cd8f8dfc9b2d80c23c334fc5abb06c472067960a385ceef3a8c0ac7d
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    
    
        data/lib/plivo/base.rb
    CHANGED
    
    
    
        data/lib/plivo/base_client.rb
    CHANGED
    
    | @@ -117,6 +117,20 @@ module Plivo | |
| 117 117 | 
             
                    faraday.response :json, content_type: /\bjson$/
         | 
| 118 118 | 
             
                    faraday.adapter Faraday.default_adapter
         | 
| 119 119 | 
             
                  end
         | 
| 120 | 
            +
             | 
| 121 | 
            +
                  @callinsights_conn = Faraday.new(@callinsights_base_uri) do |faraday|
         | 
| 122 | 
            +
                    faraday.headers = @headers
         | 
| 123 | 
            +
             | 
| 124 | 
            +
                    # DANGER: Basic auth should always come after headers, else
         | 
| 125 | 
            +
                    # The headers will replace the basic_auth
         | 
| 126 | 
            +
             | 
| 127 | 
            +
                    faraday.basic_auth(auth_id, auth_token)
         | 
| 128 | 
            +
             | 
| 129 | 
            +
                    faraday.proxy=@proxy_hash if @proxy_hash
         | 
| 130 | 
            +
                    faraday.response :json, content_type: /\bjson$/
         | 
| 131 | 
            +
                    faraday.adapter Faraday.default_adapter
         | 
| 132 | 
            +
                  end
         | 
| 133 | 
            +
             | 
| 120 134 | 
             
                end
         | 
| 121 135 |  | 
| 122 136 | 
             
                def send_get(resource_path, data, timeout)
         | 
| @@ -153,10 +167,24 @@ module Plivo | |
| 153 167 | 
             
                      req.body = data
         | 
| 154 168 | 
             
                    end
         | 
| 155 169 | 
             
                  else
         | 
| 156 | 
            -
                     | 
| 157 | 
            -
                       | 
| 158 | 
            -
                       | 
| 159 | 
            -
                       | 
| 170 | 
            +
                    if data.has_key? 'is_callinsights_request'
         | 
| 171 | 
            +
                      callinsight_base_url = data['callinsight_base_url']
         | 
| 172 | 
            +
                      resource_path = data['request_url']
         | 
| 173 | 
            +
                      data.delete('is_callinsights_request')
         | 
| 174 | 
            +
                      data.delete('request_url')
         | 
| 175 | 
            +
             | 
| 176 | 
            +
                      response = @callinsights_conn.post do |req|
         | 
| 177 | 
            +
                        req.url resource_path
         | 
| 178 | 
            +
                        req.options.timeout = timeout if timeout
         | 
| 179 | 
            +
                        req.body = JSON.generate(data) if data
         | 
| 180 | 
            +
                      end
         | 
| 181 | 
            +
             | 
| 182 | 
            +
                    else
         | 
| 183 | 
            +
                      response = @conn.post do |req|
         | 
| 184 | 
            +
                        req.url resource_path
         | 
| 185 | 
            +
                        req.options.timeout = timeout if timeout
         | 
| 186 | 
            +
                        req.body = JSON.generate(data) if data
         | 
| 187 | 
            +
                      end
         | 
| 160 188 | 
             
                    end
         | 
| 161 189 | 
             
                  end
         | 
| 162 190 | 
             
                  response
         | 
| @@ -188,6 +216,14 @@ module Plivo | |
| 188 216 | 
             
                          Exceptions::InvalidRequestError,
         | 
| 189 217 | 
             
                          'HTTP method used is not allowed to access resource'
         | 
| 190 218 | 
             
                      ],
         | 
| 219 | 
            +
                      409 => [
         | 
| 220 | 
            +
                        Exceptions::InvalidRequestError,
         | 
| 221 | 
            +
                        'Conflict'
         | 
| 222 | 
            +
                      ],
         | 
| 223 | 
            +
                      422 => [
         | 
| 224 | 
            +
                        Exceptions::InvalidRequestError,
         | 
| 225 | 
            +
                        'Unprocessable Entity'
         | 
| 226 | 
            +
                      ],
         | 
| 191 227 | 
             
                      500 => [
         | 
| 192 228 | 
             
                          Exceptions::PlivoServerError,
         | 
| 193 229 | 
             
                          'A server error occurred while accessing resource'
         | 
    
        data/lib/plivo/resources.rb
    CHANGED
    
    
| @@ -0,0 +1,55 @@ | |
| 1 | 
            +
            require 'json'
         | 
| 2 | 
            +
            require 'faraday'
         | 
| 3 | 
            +
            require 'faraday_middleware'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            module Plivo
         | 
| 6 | 
            +
              module Resources
         | 
| 7 | 
            +
                include Plivo::Utils
         | 
| 8 | 
            +
                class CallFeedback < Base::Resource
         | 
| 9 | 
            +
                  def initialize(client, options = nil)
         | 
| 10 | 
            +
                    @_name = 'Call'
         | 
| 11 | 
            +
                    super
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
                end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                class CallFeedbackInterface < Base::ResourceInterface
         | 
| 16 | 
            +
                  FEEDBACK_API_PATH = "v1/Call/%s/Feedback/"
         | 
| 17 | 
            +
                  def initialize(client, resource_list_json = nil)
         | 
| 18 | 
            +
                    @_name = 'Call'
         | 
| 19 | 
            +
                    @_resource_type = CallFeedback
         | 
| 20 | 
            +
                    super
         | 
| 21 | 
            +
                  end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                  def create(call_uuid, rating, issues = [], notes = "")
         | 
| 24 | 
            +
                    
         | 
| 25 | 
            +
                    valid_param?(:call_uuid, call_uuid, String, true)
         | 
| 26 | 
            +
                    valid_param?(:rating, rating, [Integer, Float], true)
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                    if call_uuid == ""
         | 
| 29 | 
            +
                      raise_invalid_request("call_uuid cannot be empty")
         | 
| 30 | 
            +
                    end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                    if rating < 1 or rating > 5
         | 
| 33 | 
            +
                      raise_invalid_request("Rating has to be a float between 1 - 5")
         | 
| 34 | 
            +
                    end
         | 
| 35 | 
            +
                    
         | 
| 36 | 
            +
                    params = {
         | 
| 37 | 
            +
                      rating: rating,
         | 
| 38 | 
            +
                    }
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                    if issues.length() > 0
         | 
| 41 | 
            +
                      params['issues'] = issues
         | 
| 42 | 
            +
                    end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                    if notes.length > 0
         | 
| 45 | 
            +
                      params['notes'] = notes
         | 
| 46 | 
            +
                    end
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                    params['is_callinsights_request'] = true
         | 
| 49 | 
            +
                    params['request_url'] = FEEDBACK_API_PATH % call_uuid
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                    return perform_post(params)
         | 
| 52 | 
            +
                  end
         | 
| 53 | 
            +
                end
         | 
| 54 | 
            +
              end
         | 
| 55 | 
            +
            end
         | 
    
        data/lib/plivo/rest_client.rb
    CHANGED
    
    | @@ -10,6 +10,8 @@ module Plivo | |
| 10 10 | 
             
                attr_reader :pricings, :numbers, :calls, :conferences
         | 
| 11 11 | 
             
                attr_reader :phone_numbers, :applications, :endpoints
         | 
| 12 12 | 
             
                attr_reader :addresses, :identities
         | 
| 13 | 
            +
                attr_reader :call_feedback
         | 
| 14 | 
            +
                attr_reader :powerpacks
         | 
| 13 15 | 
             
                attr_reader :powerpacks, :media
         | 
| 14 16 |  | 
| 15 17 | 
             
                def initialize(auth_id = nil, auth_token = nil, proxy_options = nil, timeout=5)
         | 
| @@ -22,6 +24,7 @@ module Plivo | |
| 22 24 |  | 
| 23 25 | 
             
                def configure_base_uri
         | 
| 24 26 | 
             
                  @base_uri = Base::PLIVO_API_URL
         | 
| 27 | 
            +
                  @callinsights_base_uri = Base::CALLINSIGHTS_API_URL
         | 
| 25 28 | 
             
                end
         | 
| 26 29 |  | 
| 27 30 | 
             
                def configure_interfaces
         | 
| @@ -40,6 +43,7 @@ module Plivo | |
| 40 43 | 
             
                  @applications = Resources::ApplicationInterface.new(self)
         | 
| 41 44 | 
             
                  @addresses = Resources::AddressInterface.new(self)
         | 
| 42 45 | 
             
                  @identities = Resources::IdentityInterface.new(self)
         | 
| 46 | 
            +
                  @call_feedback = Resources::CallFeedbackInterface.new(self)
         | 
| 43 47 | 
             
                end
         | 
| 44 48 | 
             
              end
         | 
| 45 49 | 
             
            end
         | 
    
        data/lib/plivo/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: plivo
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 4. | 
| 4 | 
            +
              version: 4.4.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - The Plivo SDKs Team
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2020- | 
| 11 | 
            +
            date: 2020-03-27 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: faraday
         | 
| @@ -164,6 +164,7 @@ files: | |
| 164 164 | 
             
            - lib/plivo/resources/accounts.rb
         | 
| 165 165 | 
             
            - lib/plivo/resources/addresses.rb
         | 
| 166 166 | 
             
            - lib/plivo/resources/applications.rb
         | 
| 167 | 
            +
            - lib/plivo/resources/call_feedback.rb
         | 
| 167 168 | 
             
            - lib/plivo/resources/calls.rb
         | 
| 168 169 | 
             
            - lib/plivo/resources/conferences.rb
         | 
| 169 170 | 
             
            - lib/plivo/resources/endpoints.rb
         |