Method: Hive::Broadcast.create_proposal

Defined in:
lib/hive/broadcast.rb

.create_proposal(options, &block) ⇒ Object

Parameters:

  • options (Hash)

    options

Options Hash (options):

  • :wif (String)

    Active wif

  • :params (Hash)
    • :creator (String) Creator of the new proposal.

    • :receiver (String) Reciever of ‘daily_pay` (or creator if empty)

    • :start_date (String) When the proposal starts.

    • :end_date (String) When the proposal ends.

    • :daily_pay (String) Daily pay in HBD starting on the ‘start_date` and ending on the `end_date`.

    • :subject (String) Subject of the proposal.

    • :permlink (String) Proposal permlink must point to the article posted by creator or receiver.

  • :pretend (Boolean)

    Just validate, do not broadcast.

See Also:



1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
# File 'lib/hive/broadcast.rb', line 1308

def self.create_proposal(options, &block)
  required_fields = %i(creator start_date end_date daily_pay subject permlink)
  params = options[:params]
  
  check_required_fields(params, *required_fields)
  
  params[:start_date] = Time.parse(params[:start_date].to_s)
  params[:start_date] = params[:start_date].strftime('%Y-%m-%dT%H:%M:%S')
  params[:end_date] = Time.parse(params[:end_date].to_s)
  params[:end_date] = params[:end_date].strftime('%Y-%m-%dT%H:%M:%S')
  params[:daily_pay] = normalize_amount(options.merge amount: params[:daily_pay])
  
  ops = [[:create_proposal, params]]
  
  process(options.merge(ops: ops), &block)
end