hakamadare / rubygem-surveymonkey

Ruby API client for SurveyMonkey
https://rubygems.org/gems/surveymonkey
MIT License
4 stars 3 forks source link

Wrong # of Arguments #3

Open anishaetienne opened 8 years ago

anishaetienne commented 8 years ago

Getting the 'wrong # of arguments' error for:

sm = Surveymonkey::Client.new api_key: 'XXXXXXXXXXXX', access_token: 'YYYYYYYYYYYYYYYYYYYY'

Why would that error be thrown? Did something change?

hakamadare commented 8 years ago

yes! something did, and i utterly failed to update the README :( sorry about that. here's the relevant portion of lib/surveymonkey/client.rb:

  ##
  # Create a new Surveymonkey::Client object.  Requires the following parameters:
  # * baseuri
  # * access_token
  # * api_key

  def initialize(baseuri, access_token, api_key)
    begin
      @baseuri      = baseuri
      @access_token = access_token
      @api_key      = api_key

you have to pass three parameters, baseuri, access_token, and api_key.

however: what are you doing that you need to instantiate a Surveymonkey::Client? in general you should expose your API credentials via environment variables, and then call the class methods in Surveymonkey, i.e.

details = Surveymonkey.get_user_details

oh, and i also notice that SurveyMonkey has now published API version 3, which is very different (my client supports v2), i'll need to update the client. API v2 still works though, we use it every day.