Sha256: 0071e3a574bd2cd700075565073bae003409c95f179270e29a688e9bcfdc87a9

Contents?: true

Size: 851 Bytes

Versions: 2

Compression:

Stored size: 851 Bytes

Contents

module Totter
  class Client
    # Client methods for working with votes.
    module Votes
      # Create a vote.
      #
      # @param decision_user_id [Fixnum] the decision's owner's ID
      # @param decision_id [Fixnum] the decision's ID
      # @param choice_id [Fixnum] the choice's ID
      # @param options [Hash] specifiy `:unique_id` or `:invitation_slug`
      def create_vote(decision_user_id, decision_id, choice_id, options = {})
        unique_id = options[:unique_id]
        raise UniqueIDRequired unless unique_id or self.authenticated?

        path = "users/#{decision_user_id}/decisions/#{decision_id}/votes"
        params = { choice_id: choice_id, unique_id: unique_id }

        slug = options[:invitation_slug]
        params[:invitation] = { slug: slug } if slug

        post(path, params).body
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
totter-0.3.1 lib/totter/client/votes.rb
totter-0.3.0 lib/totter/client/votes.rb