Sha256: a6375821a2b7692aecd2738ccad66b73d32868fd5f49b7d41ca3f632d540e27c
Contents?: true
Size: 1.55 KB
Versions: 3
Compression:
Stored size: 1.55 KB
Contents
module OneAndOne class Log 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, period: 'LAST_24H', start_date: nil, end_date: nil) # Build hash for query parameters keyword_args = { :page => page, :per_page => per_page, :sort => sort, :q => q, :fields => fields, :period => period, :start_date => start_date, :end_date => end_date } # Clean out null query parameters params = OneAndOne.clean_hash(keyword_args) # Build URL path = OneAndOne.build_url('/logs') # 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(log_id: nil) # Build URL path = OneAndOne.build_url("/logs/#{log_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/log.rb |
1and1-1.2.0 | lib/1and1/log.rb |
1and1-1.1 | lib/1and1/log.rb |