Method: Forecasting::Client#create

Defined in:
lib/forecasting/client.rb

#create(entity) ⇒ Harvesting::Models::Base

Creates an ‘entity` in your Harvest account.

Parameters:

  • entity (Harvesting::Models::Base)

    A new record in your Harvest account

Returns:

  • (Harvesting::Models::Base)

    A subclass of ‘Harvesting::Models::Base` updated with the response from Harvest



160
161
162
163
164
165
166
# File 'lib/forecasting/client.rb', line 160

def create(entity)
  url = "#{host}/#{entity.path}"
  uri = URI(url)
  response = http_response(:post, uri, body: payload(entity))
  entity.attributes = JSON.parse(response.body)[entity.type]
  entity
end