Sha256: 62d34566932c723ae756ff443fc55f5ace97e3705378f9b9c75e483f767e8d7a
Contents?: true
Size: 1.42 KB
Versions: 3
Compression:
Stored size: 1.42 KB
Contents
module OneAndOne class Datacenter def initialize(test: false) # Check if hitting mock api or live api if test @connection = Excon.new($base_url, :mock => true) else @connection = Excon.new($base_url) end end def list(page: nil, per_page: nil, sort: nil, q: nil, fields: nil) # Build hash for query parameters keyword_args = { :page => page, :per_page => per_page, :sort => sort, :q => q, :fields => fields } # Clean out null query parameters params = OneAndOne.clean_hash(keyword_args) # Build URL path = OneAndOne.build_url('/datacenters') # Perform request response = @connection.request(:method => :get, :path => path, :headers => $header, :query => params) # Check response status OneAndOne.check_response(response.body, response.status) #JSON-ify the response string JSON.parse(response.body) end def get(datacenter_id: nil) # Build URL path = OneAndOne.build_url("/datacenters/#{datacenter_id}") # Perform request response = @connection.request(:method => :get, :path => path, :headers => $header) # Check response status OneAndOne.check_response(response.body, response.status) #JSON-ify the response string JSON.parse(response.body) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
1and1-1.3.0 | lib/1and1/datacenter.rb |
1and1-1.2.0 | lib/1and1/datacenter.rb |
1and1-1.1 | lib/1and1/datacenter.rb |