Class: Blastengine::Usage

Inherits:
Base
  • Object
show all
Includes:
Blastengine
Defined in:
lib/blastengine/usage.rb

Constant Summary

Constants included from Blastengine

BASE_PATH, DOMAIN, VERSION

Instance Attribute Summary collapse

Attributes inherited from Base

#created_time, #delivery_id, #delivery_time, #delivery_type, #drop_count, #hard_error_count, #open_count, #sent_count, #soft_error_count, #status, #total_count

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Blastengine

#email, initialize

Methods inherited from Base

#cancel, #client, client, #delete, #get, #set, #sets, #unsubscribe

Constructor Details

#initialize(params) ⇒ Usage

Returns a new instance of Usage.



7
8
9
10
11
12
13
# File 'lib/blastengine/usage.rb', line 7

def initialize params
  @month = params["month"]
  @current = params["current"]
  @remaining = params["remaining"]
  @updated_time = params["updated_time"]
  @plan_id = params["plan_id"]
end

Instance Attribute Details

#currentObject

Returns the value of attribute current.



6
7
8
# File 'lib/blastengine/usage.rb', line 6

def current
  @current
end

#monthObject

Returns the value of attribute month.



6
7
8
# File 'lib/blastengine/usage.rb', line 6

def month
  @month
end

#plan_idObject

Returns the value of attribute plan_id.



6
7
8
# File 'lib/blastengine/usage.rb', line 6

def plan_id
  @plan_id
end

#remainingObject

Returns the value of attribute remaining.



6
7
8
# File 'lib/blastengine/usage.rb', line 6

def remaining
  @remaining
end

#updated_timeObject

Returns the value of attribute updated_time.



6
7
8
# File 'lib/blastengine/usage.rb', line 6

def updated_time
  @updated_time
end

Class Method Details

.all(month_ago = 1) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/blastengine/usage.rb', line 15

def self.all month_ago = 1
  # APIリクエスト用のパス
  path = "/usages?month_ago=#{month_ago}"
  res = @@client.get path
  res["data"].map do |params|
    self.new params
  end
end

.get(month = Date.today.strftime("%Y%m")) ⇒ Object



24
25
26
27
28
29
# File 'lib/blastengine/usage.rb', line 24

def self.get month = Date.today.strftime("%Y%m")
  # APIリクエスト用のパス
  path = "/usages/#{month}"
  res = @@client.get path
  self.new res
end

.latestObject



31
32
33
34
35
36
# File 'lib/blastengine/usage.rb', line 31

def self.latest
  # APIリクエスト用のパス
  path = "/usages/latest"
  res = @@client.get path
  self.new res
end