Class: BucketStatsRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/bstat2google/bucket_stats_request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ BucketStatsRequest

Returns a new instance of BucketStatsRequest.



4
5
6
# File 'lib/bstat2google/bucket_stats_request.rb', line 4

def initialize(attrs = {})
  attrs.each {|k,v| self.send("#{k}=", v)}
end

Instance Attribute Details

#apiObject

Returns the value of attribute api.



2
3
4
# File 'lib/bstat2google/bucket_stats_request.rb', line 2

def api
  @api
end

#idObject

Returns the value of attribute id.



2
3
4
# File 'lib/bstat2google/bucket_stats_request.rb', line 2

def id
  @id
end

Instance Method Details

#getObject



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/bstat2google/bucket_stats_request.rb', line 8

def get
  response = api.get url, content_type: :json, accept: :json
  if response.code >= 200 and response.code < 300
    return Response.new(code: response.code, payload: JSON.parse(response.body))
  else
    return Response.new(code: response.code, payload: response.description)
  end
rescue Exception => e 
  puts e.message
  puts e.backtrace.join("\n")
  return Response.new(code: 0, payload: e.message)
end

#urlObject



21
22
23
# File 'lib/bstat2google/bucket_stats_request.rb', line 21

def url
  "#{api.end_point}/case_blocks/bucket_stats/#{id}.json?auth_token=#{api.auth_token}"  
end