Class: Vk::API::Polls

Inherits:
Schema::Namespace show all
Defined in:
lib/vk/api/methods.rb,
lib/vk/api/objects.rb,
lib/vk/api/responses.rb,
lib/vk/api/polls/poll.rb,
lib/vk/api/polls/voters.rb,
lib/vk/api/polls/methods/edit.rb,
lib/vk/api/polls/methods/create.rb,
lib/vk/api/polls/methods/add_vote.rb,
lib/vk/api/polls/methods/get_by_id.rb,
lib/vk/api/polls/methods/get_voters.rb,
lib/vk/api/polls/methods/delete_vote.rb,
lib/vk/api/polls/responses/edit_response.rb,
lib/vk/api/polls/responses/create_response.rb,
lib/vk/api/polls/responses/add_vote_response.rb,
lib/vk/api/polls/responses/get_by_id_response.rb,
lib/vk/api/polls/responses/get_voters_response.rb,
lib/vk/api/polls/responses/delete_vote_response.rb

Defined Under Namespace

Modules: Methods, Responses Classes: Poll, Voters

Instance Attribute Summary

Attributes inherited from Schema::Namespace

#client

DSL collapse

Methods inherited from Schema::Namespace

#call, #initialize

Constructor Details

This class inherits a constructor from Vk::Schema::Namespace

Instance Method Details

#add_vote(arguments = {}) ⇒ Vk::API::Polls::Responses::AddVoteResponse

Returns Adds the current user's vote to the selected answer in the poll.

Parameters:

  • arguments (Hash) (defaults to: {})

Options Hash (arguments):

Returns:

See Also:


4778
4779
4780
4781
4782
4783
4784
# File 'lib/vk/api/methods.rb', line 4778

def add_vote(arguments = {})
  require "vk/api/polls/methods/add_vote"
  method = Methods::AddVote.new(arguments)
  response = method.call(@client)
  require "vk/api/polls/responses/add_vote_response"
  Responses::AddVoteResponse.new(response.deep_symbolize_keys)
end

#create(arguments = {}) ⇒ Vk::API::Polls::Responses::CreateResponse

Returns Creates polls that can be attached to the users' or communities' posts.

Parameters:

  • arguments (Hash) (defaults to: {})

Options Hash (arguments):

  • :question (String)

    question text

  • :is_anonymous (Boolean)

    '1' – anonymous poll, participants list is hidden;; '0' – public poll, participants list is available;; Default value is '0'.

  • :owner_id (Integer)

    If a poll will be added to a communty it is required to send a negative group identifier. Current user by default.

  • :add_answers (String)

    available answers list, for example:; " ["yes","no","maybe"]"; There can be from 1 to 10 answers.

Returns:

See Also:


4825
4826
4827
4828
4829
4830
4831
# File 'lib/vk/api/methods.rb', line 4825

def create(arguments = {})
  require "vk/api/polls/methods/create"
  method = Methods::Create.new(arguments)
  response = method.call(@client)
  require "vk/api/polls/responses/create_response"
  Responses::CreateResponse.new(response.deep_symbolize_keys)
end

#delete_vote(arguments = {}) ⇒ Vk::API::Polls::Responses::DeleteVoteResponse

Returns Deletes the current user's vote from the selected answer in the poll.

Parameters:

  • arguments (Hash) (defaults to: {})

Options Hash (arguments):

Returns:

See Also:


4792
4793
4794
4795
4796
4797
4798
# File 'lib/vk/api/methods.rb', line 4792

def delete_vote(arguments = {})
  require "vk/api/polls/methods/delete_vote"
  method = Methods::DeleteVote.new(arguments)
  response = method.call(@client)
  require "vk/api/polls/responses/delete_vote_response"
  Responses::DeleteVoteResponse.new(response.deep_symbolize_keys)
end

#edit(arguments = {}) ⇒ Vk::API::Polls::Responses::EditResponse

Returns Edits created polls.

Parameters:

  • arguments (Hash) (defaults to: {})

Options Hash (arguments):

  • :owner_id (Integer)

    poll owner id

  • :poll_id (Integer)

    edited poll's id

  • :question (String)

    new question text

  • :add_answers (String)

    answers list, for example: ; "["yes","no","maybe"]"

  • :edit_answers (String)

    object containing answers that need to be edited;; key – answer id, value – new answer text.; Example:; \$1"382967099":"option1", "382967103":"option2"\$1"

  • :delete_answers (String)

    list of answer ids to be deleted. For example:; "[382967099, 382967103]"

Returns:

See Also:


4841
4842
4843
4844
4845
4846
4847
# File 'lib/vk/api/methods.rb', line 4841

def edit(arguments = {})
  require "vk/api/polls/methods/edit"
  method = Methods::Edit.new(arguments)
  response = method.call(@client)
  require "vk/api/polls/responses/edit_response"
  Responses::EditResponse.new(response.deep_symbolize_keys)
end

#get_by_id(arguments = {}) ⇒ Vk::API::Polls::Responses::GetByIdResponse

Returns detailed information about a poll by its ID.

Parameters:

  • arguments (Hash) (defaults to: {})

Options Hash (arguments):

  • :owner_id (Integer)

    ID of the user or community that owns the poll. Use a negative value to designate a community ID.

  • :is_board (Boolean)

    '1' – poll is in a board, '0' – poll is on a wall. ; '0' by default.

  • :poll_id (Integer)

    Poll ID.

Returns:

See Also:


4764
4765
4766
4767
4768
4769
4770
# File 'lib/vk/api/methods.rb', line 4764

def get_by_id(arguments = {})
  require "vk/api/polls/methods/get_by_id"
  method = Methods::GetById.new(arguments)
  response = method.call(@client)
  require "vk/api/polls/responses/get_by_id_response"
  Responses::GetByIdResponse.new(response.deep_symbolize_keys)
end

#get_voters(arguments = {}) ⇒ Vk::API::Polls::Responses::GetVotersResponse

Returns a list of IDs of users who selected specific answers in the poll.

Parameters:

  • arguments (Hash) (defaults to: {})

Options Hash (arguments):

  • :owner_id (Integer)

    ID of the user or community that owns the poll. Use a negative value to designate a community ID.

  • :poll_id (Integer)

    Poll ID.

  • :answer_ids (Array)

    Answer IDs.

  • :is_board (Boolean)
  • :friends_only (Boolean)

    '1' — to return only current user's friends; '0' — to return all users (default);

  • :offset (Integer)

    Offset needed to return a specific subset of voters.; '0' — (default)

  • :count (Integer)

    Number of user IDs to return (if the 'friends_only' parameter is not set, maximum '1000'; otherwise '10').; '100' — (default)

  • :fields (Array, 'sex')

    Profile fields to return. Sample values: 'nickname', 'screen_name', 'sex', 'bdate (birthdate)', 'city', 'country', 'timezone', 'photo', 'photo_medium', 'photo_big', 'has_mobile', 'rate', 'contacts', 'education', 'online', 'counters'.;

  • :name_case (String)

    Case for declension of user name and surname: ; 'nom' — nominative (default) ; 'gen' — genitive ; 'dat' — dative ; 'acc' — accusative ; 'ins' — instrumental ; 'abl' — prepositional

Returns:

See Also:


4811
4812
4813
4814
4815
4816
4817
# File 'lib/vk/api/methods.rb', line 4811

def get_voters(arguments = {})
  require "vk/api/polls/methods/get_voters"
  method = Methods::GetVoters.new(arguments)
  response = method.call(@client)
  require "vk/api/polls/responses/get_voters_response"
  Responses::GetVotersResponse.new(response.deep_symbolize_keys)
end