api_caller 0.1.0 → 0.1.1
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/lib/api_caller.rb +9 -4
- metadata +1 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 31039c03bf087f2096c0fff8586a8a10f0b587a1
         | 
| 4 | 
            +
              data.tar.gz: 9d1b1bac10c267b5ac25e10423d2e96d8c2ff2f4
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 87d0a7d2c6b2a0676d20c69a0d3b98b69953abe13111488da665a5c63dfd6fcd92e3bdaebf39ffa8daec67198cc83fd668eeb248b8831212e22d779ebf646b57
         | 
| 7 | 
            +
              data.tar.gz: 6cf5f59611a01f9bfaeb4e6f35eac16e9d86af4a640f3ac7aa06d049961be9ee3e019916a6b29a134f32b60508adec8c39c67822421e3a542b5ee79a744d1030
         | 
    
        data/lib/api_caller.rb
    CHANGED
    
    | @@ -5,7 +5,8 @@ class ApiCaller | |
| 5 5 | 
             
              def self.get(uri_string:, logger: nil)
         | 
| 6 6 | 
             
                response = nil
         | 
| 7 7 |  | 
| 8 | 
            -
                uri =  | 
| 8 | 
            +
                uri = escaped_uri(uri_string)
         | 
| 9 | 
            +
             | 
| 9 10 | 
             
                begin
         | 
| 10 11 | 
             
                  Net::HTTP.start(uri.host, uri.port, {use_ssl: uri.scheme == 'https', open_timeout: 1}) do |http|
         | 
| 11 12 | 
             
                    request = Net::HTTP::Get.new(uri)
         | 
| @@ -29,7 +30,7 @@ class ApiCaller | |
| 29 30 | 
             
              def self.delete(uri_string:, logger: nil)
         | 
| 30 31 | 
             
                response = nil
         | 
| 31 32 |  | 
| 32 | 
            -
                uri =  | 
| 33 | 
            +
                uri = escaped_uri(uri_string)
         | 
| 33 34 | 
             
                begin
         | 
| 34 35 | 
             
                  Net::HTTP.start(uri.host, uri.port, {use_ssl: uri.scheme == 'https', open_timeout: 1}) do |http|
         | 
| 35 36 | 
             
                    request = Net::HTTP::Delete.new(uri)
         | 
| @@ -44,10 +45,14 @@ class ApiCaller | |
| 44 45 |  | 
| 45 46 | 
             
              private
         | 
| 46 47 |  | 
| 48 | 
            +
              def self.escaped_uri(uri)
         | 
| 49 | 
            +
                URI(URI.escape(uri))
         | 
| 50 | 
            +
              end
         | 
| 51 | 
            +
             | 
| 47 52 | 
             
              def self.url_params_post(uri_string:, params:, logger: nil)
         | 
| 48 53 | 
             
                response = nil
         | 
| 49 54 |  | 
| 50 | 
            -
                uri =  | 
| 55 | 
            +
                uri = escaped_uri(uri_string)
         | 
| 51 56 | 
             
                begin
         | 
| 52 57 | 
             
                  Net::HTTP.start(uri.host, uri.port, {use_ssl: uri.scheme == 'https', open_timeout: 1, read_timeout: 1}) do |http|
         | 
| 53 58 | 
             
                    request = Net::HTTP::Post.new(uri)
         | 
| @@ -63,7 +68,7 @@ class ApiCaller | |
| 63 68 | 
             
              def self.body_params_post(uri_string:, params:, content_type: nil, logger: nil)
         | 
| 64 69 | 
             
                response = nil
         | 
| 65 70 |  | 
| 66 | 
            -
                uri =  | 
| 71 | 
            +
                uri = escaped_uri(uri_string)
         | 
| 67 72 | 
             
                begin
         | 
| 68 73 | 
             
                  Net::HTTP.start(uri.host, uri.port, {use_ssl: uri.scheme == 'https', open_timeout: 1, read_timeout: 1}) do |http|
         | 
| 69 74 | 
             
                    request = Net::HTTP::Post.new(uri, content_type)
         |