Sha256: c3506cfc33c3f1e25339c96b397806da721263e137a4c15d44d783e7e81621cd

Contents?: true

Size: 860 Bytes

Versions: 17

Compression:

Stored size: 860 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

17 entries across 17 versions & 1 rubygems

Version Path
totter-0.4.8 lib/totter/client/votes.rb
totter-0.4.7 lib/totter/client/votes.rb
totter-0.4.6 lib/totter/client/votes.rb
totter-0.4.5 lib/totter/client/votes.rb
totter-0.4.4 lib/totter/client/votes.rb
totter-0.4.3 lib/totter/client/votes.rb
totter-0.4.2 lib/totter/client/votes.rb
totter-0.4.1 lib/totter/client/votes.rb
totter-0.4.0 lib/totter/client/votes.rb
totter-0.3.9 lib/totter/client/votes.rb
totter-0.3.8 lib/totter/client/votes.rb
totter-0.3.7 lib/totter/client/votes.rb
totter-0.3.6 lib/totter/client/votes.rb
totter-0.3.5 lib/totter/client/votes.rb
totter-0.3.4 lib/totter/client/votes.rb
totter-0.3.3 lib/totter/client/votes.rb
totter-0.3.2 lib/totter/client/votes.rb