leaseweb-rest-api 1.0.1 → 1.0.2
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/Gemfile +2 -1
- data/leaseweb-rest-api.gemspec +2 -2
- data/lib/hash-to-uri-conversion.rb +3 -3
- data/lib/leaseweb-rest-api.rb +113 -44
- data/spec/lib/leaseweb-rest-api_spec.rb +218 -218
- data/spec/spec_helper.rb +2 -3
- metadata +13 -13
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: adc4d1eef0cc5d6c853af1e1bfd5283241140d15
         | 
| 4 | 
            +
              data.tar.gz: 906b653fd5dbeeeaab1e91e0c29ce2b5b6afcf86
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 4269770ca1487cd9c82315b7a1cf5df14e36496bfe7289e722f11f3fae5d79f1a87ec6949adf5a6a257ceae21b2f4ab0e85f2063af5239ed5c617a095aae3343
         | 
| 7 | 
            +
              data.tar.gz: 1b0efc5c9ed2eaad0685eb670f10019fdc41e78334ae6b49d9d86c4f3e5f5c5aacf887b8f97e39e031bb896fe6d532fe493aead9e4c73cfa775d3f688b04c118
         | 
    
        data/Gemfile
    CHANGED
    
    
    
        data/leaseweb-rest-api.gemspec
    CHANGED
    
    | @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            Gem::Specification.new do |s|
         | 
| 2 2 | 
             
              s.name          = 'leaseweb-rest-api'
         | 
| 3 | 
            -
              s.version       = '1.0. | 
| 3 | 
            +
              s.version       = '1.0.2'
         | 
| 4 4 | 
             
              s.authors       = 'Arnoud Vermeer'
         | 
| 5 5 | 
             
              s.email         = 'a.vermeer@tech.leaseweb.com'
         | 
| 6 6 | 
             
              s.license       = 'Apache'
         | 
| @@ -14,4 +14,4 @@ Gem::Specification.new do |s| | |
| 14 14 |  | 
| 15 15 | 
             
              s.add_development_dependency 'rspec'
         | 
| 16 16 | 
             
              s.add_development_dependency 'webmock'
         | 
| 17 | 
            -
            end
         | 
| 17 | 
            +
            end
         | 
| @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            class HashToURIConversion
         | 
| 2 2 | 
             
              def to_params(hash)
         | 
| 3 | 
            -
                params = hash.map { |k,v| normalize_param(k,v) }.join
         | 
| 3 | 
            +
                params = hash.map { |k, v| normalize_param(k, v) }.join
         | 
| 4 4 | 
             
                params.chop! # trailing &
         | 
| 5 5 | 
             
                params
         | 
| 6 6 | 
             
              end
         | 
| @@ -12,7 +12,7 @@ class HashToURIConversion | |
| 12 12 | 
             
                if value.is_a?(Array)
         | 
| 13 13 | 
             
                  param << value.each_with_index.map { |element, i| normalize_param("#{key}[#{i}]", element) }.join
         | 
| 14 14 | 
             
                elsif value.is_a?(Hash)
         | 
| 15 | 
            -
                  stack << [key,value]
         | 
| 15 | 
            +
                  stack << [key, value]
         | 
| 16 16 | 
             
                else
         | 
| 17 17 | 
             
                  param << "#{key}=#{URI.encode(value.to_s, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))}&"
         | 
| 18 18 | 
             
                end
         | 
| @@ -29,4 +29,4 @@ class HashToURIConversion | |
| 29 29 |  | 
| 30 30 | 
             
                param
         | 
| 31 31 | 
             
              end
         | 
| 32 | 
            -
            end
         | 
| 32 | 
            +
            end
         | 
    
        data/lib/leaseweb-rest-api.rb
    CHANGED
    
    | @@ -3,23 +3,56 @@ | |
| 3 3 | 
             
            require 'httparty'
         | 
| 4 4 | 
             
            require 'base64'
         | 
| 5 5 | 
             
            require 'time'
         | 
| 6 | 
            +
            require 'json'
         | 
| 6 7 | 
             
            require_relative 'hash-to-uri-conversion'
         | 
| 7 8 |  | 
| 8 9 | 
             
            class LeasewebAPI
         | 
| 9 10 | 
             
              include HTTParty
         | 
| 10 11 | 
             
              format :json
         | 
| 11 | 
            -
              #debug_output $stderr
         | 
| 12 | 
            +
              # debug_output $stderr
         | 
| 12 13 |  | 
| 13 14 | 
             
              base_uri 'https://api.leaseweb.com/v1'
         | 
| 14 15 |  | 
| 15 | 
            -
              def initialize | 
| 16 | 
            -
                @ | 
| 17 | 
            -
                 | 
| 16 | 
            +
              def initialize(apikey = nil, privateKey = nil, password = nil, clientId = nil, clientSecret = nil)
         | 
| 17 | 
            +
                @auth_token_url = 'https://auth.leaseweb.com/token'
         | 
| 18 | 
            +
                if !apikey.nil?
         | 
| 19 | 
            +
                  @options = { headers: { 'X-Lsw-Auth' => apikey } }
         | 
| 20 | 
            +
                elsif !clientId.nil? && !clientSecret.nil?
         | 
| 21 | 
            +
                  access_token = getOauthToken(clientId, clientSecret)['access_token']
         | 
| 22 | 
            +
                  @options = { headers: { 'Authorization' => "Bearer #{access_token}" } }
         | 
| 23 | 
            +
                else
         | 
| 24 | 
            +
                  puts 'Your API credentials are required.'
         | 
| 25 | 
            +
                  exit
         | 
| 26 | 
            +
                end
         | 
| 27 | 
            +
                @private_key = OpenSSL::PKey::RSA.new(File.read(privateKey), password) unless privateKey.nil? || password.nil?
         | 
| 28 | 
            +
              end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
              def getOauthToken(clientId, clientSecret)
         | 
| 31 | 
            +
                auth = { username: clientId, password: clientSecret }
         | 
| 32 | 
            +
                self.class.post(@auth_token_url, basic_auth: auth, body: { grant_type: 'client_credentials' })
         | 
| 33 | 
            +
              end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
              def get(url)
         | 
| 36 | 
            +
                self.class.get(url, @options)
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
              def post(url, body)
         | 
| 40 | 
            +
                opt = @options.merge!(body: body)
         | 
| 41 | 
            +
                self.class.post(url, opt)
         | 
| 42 | 
            +
              end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
              def put(url, body)
         | 
| 45 | 
            +
                opt = @options.merge!(body: body)
         | 
| 46 | 
            +
                self.class.put(url, opt)
         | 
| 47 | 
            +
              end
         | 
| 48 | 
            +
             | 
| 49 | 
            +
              def delete(url)
         | 
| 50 | 
            +
                self.class.delete(url, @options)
         | 
| 18 51 | 
             
              end
         | 
| 19 52 |  | 
| 20 53 | 
             
              # Domains
         | 
| 21 54 | 
             
              def getDomains
         | 
| 22 | 
            -
                self.class.get( | 
| 55 | 
            +
                self.class.get('/domains', @options)
         | 
| 23 56 | 
             
              end
         | 
| 24 57 |  | 
| 25 58 | 
             
              def getDomain(domain)
         | 
| @@ -27,7 +60,7 @@ class LeasewebAPI | |
| 27 60 | 
             
              end
         | 
| 28 61 |  | 
| 29 62 | 
             
              def updateDomain(domain, ttl)
         | 
| 30 | 
            -
                opt = @options.merge!( | 
| 63 | 
            +
                opt = @options.merge!(body: { ttl: ttl })
         | 
| 31 64 |  | 
| 32 65 | 
             
                self.class.put("/domains/#{domain}", opt)
         | 
| 33 66 | 
             
              end
         | 
| @@ -37,9 +70,9 @@ class LeasewebAPI | |
| 37 70 | 
             
              end
         | 
| 38 71 |  | 
| 39 72 | 
             
              def createDNSRecords(domain, host, content, type, priority = nil)
         | 
| 40 | 
            -
                opt = @options.merge!( | 
| 73 | 
            +
                opt = @options.merge!(body: { host: host, content: content, type: type })
         | 
| 41 74 |  | 
| 42 | 
            -
                if  | 
| 75 | 
            +
                if !priority.nil? && ((type == 'MX') || (type == 'SRV'))
         | 
| 43 76 | 
             
                  opt[:body][:priority] = priority
         | 
| 44 77 | 
             
                end
         | 
| 45 78 |  | 
| @@ -51,9 +84,9 @@ class LeasewebAPI | |
| 51 84 | 
             
              end
         | 
| 52 85 |  | 
| 53 86 | 
             
              def updateDNSRecord(domain, dnsRecordId, host, content, type, priority = nil)
         | 
| 54 | 
            -
                opt = @options.merge!( | 
| 87 | 
            +
                opt = @options.merge!(body: { id: dnsRecordId, host: host, content: content, type: type })
         | 
| 55 88 |  | 
| 56 | 
            -
                if  | 
| 89 | 
            +
                if !priority.nil? && ((type == 'MX') || (type == 'SRV'))
         | 
| 57 90 | 
             
                  opt[:body][:priority] = priority
         | 
| 58 91 | 
             
                end
         | 
| 59 92 |  | 
| @@ -66,12 +99,12 @@ class LeasewebAPI | |
| 66 99 |  | 
| 67 100 | 
             
              # Rescue
         | 
| 68 101 | 
             
              def getRescueImages
         | 
| 69 | 
            -
                self.class.get( | 
| 102 | 
            +
                self.class.get('/rescueImages', @options)
         | 
| 70 103 | 
             
              end
         | 
| 71 104 |  | 
| 72 105 | 
             
              # BareMetals
         | 
| 73 106 | 
             
              def getBareMetals
         | 
| 74 | 
            -
                self.class.get( | 
| 107 | 
            +
                self.class.get('/bareMetals', @options)
         | 
| 75 108 | 
             
              end
         | 
| 76 109 |  | 
| 77 110 | 
             
              def getBareMetal(bareMetalId)
         | 
| @@ -79,7 +112,7 @@ class LeasewebAPI | |
| 79 112 | 
             
              end
         | 
| 80 113 |  | 
| 81 114 | 
             
              def updateBareMetal(bareMetalId, reference)
         | 
| 82 | 
            -
                opt = @options.merge!( | 
| 115 | 
            +
                opt = @options.merge!(body: { reference: reference })
         | 
| 83 116 |  | 
| 84 117 | 
             
                self.class.put("/bareMetals/#{bareMetalId}", opt)
         | 
| 85 118 | 
             
              end
         | 
| @@ -108,8 +141,8 @@ class LeasewebAPI | |
| 108 141 | 
             
                self.class.get("/bareMetals/#{bareMetalId}/ips/#{ipAddress}", @options)
         | 
| 109 142 | 
             
              end
         | 
| 110 143 |  | 
| 111 | 
            -
              def updateIP(bareMetalId, ipAddress, reverseLookup='', nullRouted=0)
         | 
| 112 | 
            -
                opt = @options.merge!( | 
| 144 | 
            +
              def updateIP(bareMetalId, ipAddress, reverseLookup = '', nullRouted = 0)
         | 
| 145 | 
            +
                opt = @options.merge!(body: { reverseLookup: reverseLookup, nullRouted: nullRouted })
         | 
| 113 146 |  | 
| 114 147 | 
             
                self.class.put("/bareMetals/#{bareMetalId}/ips/#{ipAddress}", opt)
         | 
| 115 148 | 
             
              end
         | 
| @@ -122,11 +155,11 @@ class LeasewebAPI | |
| 122 155 | 
             
                self.class.get("/bareMetals/#{bareMetalId}/networkUsage", @options)
         | 
| 123 156 | 
             
              end
         | 
| 124 157 |  | 
| 125 | 
            -
              def getNetworkUsageBandWidth(bareMetalId, dateFrom, dateTo, format='json')
         | 
| 158 | 
            +
              def getNetworkUsageBandWidth(bareMetalId, dateFrom, dateTo, format = 'json')
         | 
| 126 159 | 
             
                self.class.get("/bareMetals/#{bareMetalId}/networkUsage/bandWidth", formatRequest(dateFrom, dateTo, format))
         | 
| 127 160 | 
             
              end
         | 
| 128 161 |  | 
| 129 | 
            -
              def getNetworkUsageDataTraffic(bareMetalId, dateFrom, dateTo, format='json')
         | 
| 162 | 
            +
              def getNetworkUsageDataTraffic(bareMetalId, dateFrom, dateTo, format = 'json')
         | 
| 130 163 | 
             
                self.class.get("/bareMetals/#{bareMetalId}/networkUsage/dataTraffic", formatRequest(dateFrom, dateTo, format))
         | 
| 131 164 | 
             
              end
         | 
| 132 165 |  | 
| @@ -135,19 +168,19 @@ class LeasewebAPI | |
| 135 168 | 
             
              end
         | 
| 136 169 |  | 
| 137 170 | 
             
              def installServer(bareMetalId, osId, hdd = [])
         | 
| 138 | 
            -
                opt = @options.merge!( | 
| 171 | 
            +
                opt = @options.merge!(body: { osId: osId, hdd: hdd }, query_string_normalizer: ->(h) { HashToURIConversion.new.to_params(h) })
         | 
| 139 172 |  | 
| 140 173 | 
             
                self.class.post("/bareMetals/#{bareMetalId}/install", opt)
         | 
| 141 174 | 
             
              end
         | 
| 142 175 |  | 
| 143 176 | 
             
              def postResqueMode(bareMetalId, osId)
         | 
| 144 | 
            -
                opt = @options.merge!( | 
| 177 | 
            +
                opt = @options.merge!(body: { osId: osId })
         | 
| 145 178 |  | 
| 146 179 | 
             
                self.class.post("/bareMetals/#{bareMetalId}/rescueMode", opt)
         | 
| 147 180 | 
             
              end
         | 
| 148 181 |  | 
| 149 | 
            -
              def getRootPassword(bareMetalId, format='json')
         | 
| 150 | 
            -
                opt = @options.merge!( | 
| 182 | 
            +
              def getRootPassword(bareMetalId, format = 'json')
         | 
| 183 | 
            +
                opt = @options.merge!(headers: formatHeader(format))
         | 
| 151 184 |  | 
| 152 185 | 
             
                self.class.get("/bareMetals/#{bareMetalId}/rootPassword", opt)
         | 
| 153 186 | 
             
              end
         | 
| @@ -155,12 +188,12 @@ class LeasewebAPI | |
| 155 188 | 
             
              def getInstallationStatus(bareMetalId)
         | 
| 156 189 | 
             
                response = self.class.get("/bareMetals/#{bareMetalId}/installationStatus", @options)
         | 
| 157 190 |  | 
| 158 | 
            -
                if response[ | 
| 159 | 
            -
                  response[ | 
| 191 | 
            +
                if response['installationStatus'].include?('initRootPassword')
         | 
| 192 | 
            +
                  response['installationStatus']['initRootPassword'] = decrypt(response['installationStatus']['initRootPassword'])
         | 
| 160 193 | 
             
                end
         | 
| 161 194 |  | 
| 162 | 
            -
                if response[ | 
| 163 | 
            -
                  response[ | 
| 195 | 
            +
                if response['installationStatus'].include?('rescueModeRootPass')
         | 
| 196 | 
            +
                  response['installationStatus']['rescueModeRootPass'] = decrypt(response['installationStatus']['rescueModeRootPass'])
         | 
| 164 197 | 
             
                end
         | 
| 165 198 |  | 
| 166 199 | 
             
                response
         | 
| @@ -171,7 +204,7 @@ class LeasewebAPI | |
| 171 204 | 
             
              end
         | 
| 172 205 |  | 
| 173 206 | 
             
              def setLease(bareMetalId, bootFileName)
         | 
| 174 | 
            -
                opt = @options.merge!( | 
| 207 | 
            +
                opt = @options.merge!(body: { bootFileName: bootFileName })
         | 
| 175 208 |  | 
| 176 209 | 
             
                self.class.post("/bareMetals/#{bareMetalId}/leases", opt)
         | 
| 177 210 | 
             
              end
         | 
| @@ -184,16 +217,24 @@ class LeasewebAPI | |
| 184 217 | 
             
                self.class.delete("/bareMetals/#{bareMetalId}/leases/#{macAddress}", @options)
         | 
| 185 218 | 
             
              end
         | 
| 186 219 |  | 
| 220 | 
            +
              # New install call
         | 
| 221 | 
            +
              def install(bareMetalId, operatingSystemId, options = {})
         | 
| 222 | 
            +
                options[:operatingSystemId] = operatingSystemId
         | 
| 223 | 
            +
                opt = @options.merge!(body: options.to_json)
         | 
| 224 | 
            +
             | 
| 225 | 
            +
                self.class.post("/bmpapi/bareMetals/#{bareMetalId}/install", opt)
         | 
| 226 | 
            +
              end
         | 
| 227 | 
            +
             | 
| 187 228 | 
             
              # Private Networks
         | 
| 188 229 | 
             
              def getPrivateNetworks
         | 
| 189 | 
            -
                self.class.get( | 
| 230 | 
            +
                self.class.get('/privateNetworks', @options)
         | 
| 190 231 | 
             
              end
         | 
| 191 232 |  | 
| 192 233 | 
             
              # TODO: check post with name
         | 
| 193 | 
            -
              def createPrivateNetworks(name='')
         | 
| 194 | 
            -
                opt = @options.merge!( | 
| 234 | 
            +
              def createPrivateNetworks(name = '')
         | 
| 235 | 
            +
                opt = @options.merge!(body: { name: name })
         | 
| 195 236 |  | 
| 196 | 
            -
                self.class.post( | 
| 237 | 
            +
                self.class.post('/privateNetworks', opt)
         | 
| 197 238 | 
             
              end
         | 
| 198 239 |  | 
| 199 240 | 
             
              def getPrivateNetwork(id)
         | 
| @@ -201,8 +242,8 @@ class LeasewebAPI | |
| 201 242 | 
             
              end
         | 
| 202 243 |  | 
| 203 244 | 
             
              # TODO: Check with Jeroen if it works
         | 
| 204 | 
            -
              def updatePrivateNetwork(id, name='')
         | 
| 205 | 
            -
                opt = @options.merge!( | 
| 245 | 
            +
              def updatePrivateNetwork(id, name = '')
         | 
| 246 | 
            +
                opt = @options.merge!(body: { name: name })
         | 
| 206 247 |  | 
| 207 248 | 
             
                self.class.put("/privateNetworks/#{id}", opt)
         | 
| 208 249 | 
             
              end
         | 
| @@ -212,7 +253,7 @@ class LeasewebAPI | |
| 212 253 | 
             
              end
         | 
| 213 254 |  | 
| 214 255 | 
             
              def createPrivateNetworksBareMetals(id, bareMetalId)
         | 
| 215 | 
            -
                opt = @options.merge!( | 
| 256 | 
            +
                opt = @options.merge!(body: { bareMetalId: bareMetalId })
         | 
| 216 257 |  | 
| 217 258 | 
             
                self.class.post("/privateNetworks/#{id}/bareMetals", opt)
         | 
| 218 259 | 
             
              end
         | 
| @@ -223,7 +264,7 @@ class LeasewebAPI | |
| 223 264 |  | 
| 224 265 | 
             
              # Operating Systems
         | 
| 225 266 | 
             
              def getOperatingSystems
         | 
| 226 | 
            -
                self.class.get( | 
| 267 | 
            +
                self.class.get('/operatingSystems', @options)
         | 
| 227 268 | 
             
              end
         | 
| 228 269 |  | 
| 229 270 | 
             
              def getOperatingSystem(operatingSystemId)
         | 
| @@ -239,27 +280,55 @@ class LeasewebAPI | |
| 239 280 | 
             
              end
         | 
| 240 281 |  | 
| 241 282 | 
             
              def getPartitionSchema(operatingSystemId, bareMetalId)
         | 
| 242 | 
            -
                opt = @options.merge!( | 
| 283 | 
            +
                opt = @options.merge!(query: { serverPackId: bareMetalId })
         | 
| 243 284 |  | 
| 244 285 | 
             
                self.class.get("/operatingSystems/#{operatingSystemId}/partitionSchema", opt)
         | 
| 245 286 | 
             
              end
         | 
| 246 287 |  | 
| 247 288 | 
             
              # IPs
         | 
| 248 289 | 
             
              def getIps
         | 
| 249 | 
            -
                self.class.get( | 
| 290 | 
            +
                self.class.get('/ips', @options)
         | 
| 250 291 | 
             
              end
         | 
| 251 292 |  | 
| 252 293 | 
             
              def getIp(ipAddress)
         | 
| 253 294 | 
             
                self.class.get("/ips/#{ipAddress}", @options)
         | 
| 254 295 | 
             
              end
         | 
| 255 296 |  | 
| 256 | 
            -
              def updateIp(ipAddress, reverseLookup='', nullRouted=0)
         | 
| 257 | 
            -
                opt = @options.merge!( | 
| 297 | 
            +
              def updateIp(ipAddress, reverseLookup = '', nullRouted = 0)
         | 
| 298 | 
            +
                opt = @options.merge!(body: { reverseLookup: reverseLookup, nullRouted: nullRouted })
         | 
| 258 299 |  | 
| 259 300 | 
             
                self.class.put("/ips/#{ipAddress}", opt)
         | 
| 260 301 | 
             
              end
         | 
| 261 302 |  | 
| 303 | 
            +
              # Pay as you go
         | 
| 304 | 
            +
              def getPAYGInstances
         | 
| 305 | 
            +
                self.class.get('/payAsYouGo/bareMetals/instances', @options)
         | 
| 306 | 
            +
              end
         | 
| 307 | 
            +
             | 
| 308 | 
            +
              def createPAYGInstance(modelId)
         | 
| 309 | 
            +
                opt = @options.merge!(model: modelId)
         | 
| 310 | 
            +
             | 
| 311 | 
            +
                self.class.post('/payAsYouGo/bareMetals/instances', opt)
         | 
| 312 | 
            +
              end
         | 
| 313 | 
            +
             | 
| 314 | 
            +
              def getPAYGInstance(bareMetalId)
         | 
| 315 | 
            +
                self.class.get("/payAsYouGo/bareMetals/instances/#{bareMetalId}", @options)
         | 
| 316 | 
            +
              end
         | 
| 317 | 
            +
             | 
| 318 | 
            +
              def destroyPAYGInstance(bareMetalId)
         | 
| 319 | 
            +
                self.class.post("/payAsYouGo/bareMetals/instances/#{bareMetalId}/destroy", @options)
         | 
| 320 | 
            +
              end
         | 
| 321 | 
            +
             | 
| 322 | 
            +
              def getPAYGModels
         | 
| 323 | 
            +
                self.class.get('/payAsYouGo/bareMetals/models', @options)
         | 
| 324 | 
            +
              end
         | 
| 325 | 
            +
             | 
| 326 | 
            +
              def getPAYGModelInstance(modelId)
         | 
| 327 | 
            +
                self.class.get("/payAsYouGo/bareMetals/models/#{modelId}", @options)
         | 
| 328 | 
            +
              end
         | 
| 329 | 
            +
             | 
| 262 330 | 
             
              protected
         | 
| 331 | 
            +
             | 
| 263 332 | 
             
              def decrypt(string)
         | 
| 264 333 | 
             
                @private_key.private_decrypt(Base64.decode64(string))
         | 
| 265 334 | 
             
              end
         | 
| @@ -269,16 +338,16 @@ class LeasewebAPI | |
| 269 338 | 
             
              end
         | 
| 270 339 |  | 
| 271 340 | 
             
              def formatHeader(format)
         | 
| 272 | 
            -
                if format == 'json'
         | 
| 273 | 
            -
             | 
| 274 | 
            -
             | 
| 275 | 
            -
             | 
| 276 | 
            -
             | 
| 341 | 
            +
                header = if format == 'json'
         | 
| 342 | 
            +
                           { 'Accept' => 'application/json' }.merge!(@options[:headers])
         | 
| 343 | 
            +
                         else
         | 
| 344 | 
            +
                           { 'Accept' => 'image/png' }.merge!(@options[:headers])
         | 
| 345 | 
            +
                         end
         | 
| 277 346 |  | 
| 278 347 | 
             
                header
         | 
| 279 348 | 
             
              end
         | 
| 280 349 |  | 
| 281 350 | 
             
              def formatRequest(dateFrom, dateTo, format)
         | 
| 282 | 
            -
                @options.merge!( | 
| 351 | 
            +
                @options.merge!(query: { dateFrom: dateFormat(dateFrom), dateTo: dateFormat(dateTo) }, headers: formatHeader(format))
         | 
| 283 352 | 
             
              end
         | 
| 284 353 | 
             
            end
         |