Class: FractalApi::Forecasting::Balance

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/fractal_api/forecasting/balance.rb

Class Method Summary collapse

Methods inherited from BaseModel

#as_json, attribute_aliases, attributes, format_url, #format_url, get, #get, #initialize, key_transformer, post, #post, put, #put

Constructor Details

This class inherits a constructor from FractalApi::BaseModel

Class Method Details

.all(company_id, filters = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/fractal_api/forecasting/balance.rb', line 13

def self.all(company_id, filters = {})
  filters = filters.transform_keys { |key| key_transformer.transform(key) }

  Paginator.new('/forecasting/v2/balances', self) do |url|
    get(
      url,
      params: filters,
      headers: { 'X-Company-Id' => company_id }
    )
  end
end

.build(json:) ⇒ Object



25
26
27
28
29
# File 'lib/fractal_api/forecasting/balance.rb', line 25

def self.build(json:)
  super.tap do |record|
    record.date = Time.parse(record.date) if record.date
  end
end